stargazing/install-cosmo

49 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2022-09-23 14:46:24 -07:00
#!/usr/bin/env sh
: \
&& me="$(readlink -f "$0")" \
&& cd "${me%/*}" \
\
&& have() \
{ : \
&& if [ -z "$ZSH_VERSION" ] \
;then : \
&& which -- "$1" \
;else : \
&& whence -p -- "$1" \
;fi \
2022-09-23 17:08:36 -07:00
;} 2>/dev/null \
2022-09-23 14:46:24 -07:00
\
&& { [ -d out ] || mkdir out ;} \
&& out="$(realpath out)" \
&& { :\
&& super="$(have sudo)" \
|| super="$(have doas)" \
;} \
&& cd /opt \
&& { [ -w . ] || "$super" chown root:wheel . ;} \
&& { [ -w . ] || "$super" chmod 0775 . ;} \
&& now="$(date -u +%s)" \
&& podman run -v="$out":/out --rm localhost/cosmo-dist \
2022-09-23 14:46:24 -07:00
tar zcf "/out/cosmopolitan-$now.tar.gz" /cosmopolitan \
&& if [ -L cosmopolitan ] \
;then : \
&& rm cosmopolitan \
;elif [ -d cosmopolitan ] \
;then : \
&& timestamp="$(date -u -r cosmopolitan +%s)" \
&& mv cosmopolitan "cosmopolitan-$timestamp" \
;fi \
&& cd /opt \
&& tar zxf "$out/cosmopolitan-$now.tar.gz" \
&& mv cosmopolitan "cosmopolitan-$now" \
&& ln -s "cosmopolitan-$now" cosmopolitan \
&& cd cosmopolitan \
&& tar zxf dist/headers.tar.gz \
&& du -hd0 /opt/cosmopolitan/ \
&& . ./env \
&& COSMO=/opt/cosmopolitan \
&& COSMO_DIST="/opt/cosmopolitan/dist/$flavor" \
&& `#ADDPATH /opt/cosmopolitan/gcc/bin` \
;