From 3db9f0eff9f1fc731f08420a3d6564e76716898b Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 23 Sep 2022 14:46:24 -0700 Subject: [PATCH] add install-cosmo script --- install-cosmo | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 install-cosmo diff --git a/install-cosmo b/install-cosmo new file mode 100755 index 0000000..967556b --- /dev/null +++ b/install-cosmo @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +: \ + && me="$(readlink -f "$0")" \ + && cd "${me%/*}" \ +\ + && have() \ + { : \ + && if [ -z "$ZSH_VERSION" ] \ + ;then : \ + && which -- "$1" \ + ;else : \ + && whence -p -- "$1" \ + ;fi \ + ;} 2>/dev/null \ +\ + && { [ -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 \ + 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` \ +;