121 lines
4.2 KiB
Bash
Executable file
121 lines
4.2 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
announce() { : \
|
|
&& printf >&2 ' \033[1m\033[7m <-- \033[0m\033[1m ' \
|
|
&& printf >&2 ' %30s %-30s ' "$1" "$2" \
|
|
&& printf >&2 ' \033[1m\033[7m --> \033[0m\n' \
|
|
;}
|
|
|
|
yes_retrieve() { : \
|
|
&& local ok=1 out= g= image="${1?missing argument}" && shift \
|
|
&& [ -d out ] && out="$(realpath out)" \
|
|
&& for f in "$@" \
|
|
;do announce retrieving "$f" \
|
|
&& g="out/${f##*/}" && { ! [ -e "$g" ] || mv "$g" "$g~" ;} || return \
|
|
;done \
|
|
&& podman run -v="$out":/out --rm --entrypoint /bin/busybox "$image" \
|
|
cp -- "$@" "/out/" \
|
|
&& for f in "$@" \
|
|
;do if g="out/${f##*/}" && [ -e "$g" ] \
|
|
;then ! [ -e "$g~" ] || rm "$g~" || return \
|
|
;else printf 'yes_retrieve: %s\n' "failed to copy file $f to $g"; ok=0 \
|
|
;fi ;done \
|
|
&& [ $ok = 1 ] \
|
|
;}
|
|
|
|
dbg_retrieve() { : \
|
|
&& local o=0 container="${1?missing argument}" && shift \
|
|
&& for f in "$@" \
|
|
;do [ $o = 0 ] && o=1 && set -- "$f" "$f.dbg" || set -- "$f" "$f.dbg" "$@" \
|
|
;done \
|
|
&& yes_retrieve "$container" "$@" \
|
|
;}
|
|
|
|
build() { : \
|
|
&& local t="${1?missing argument}" && shift \
|
|
&& announce building "$t" \
|
|
&& podman build -t "$t" "$t" "$@" \
|
|
;}
|
|
|
|
build_simple() { : \
|
|
&& for f in simple/*.Dockerfile \
|
|
;do t="${f%.*}" t=${t##*/} \
|
|
&& announce '(simple) packaging' "$t" \
|
|
&& podman build -t "$t" -f "$f" simple \
|
|
|| return \
|
|
;done \
|
|
;}
|
|
|
|
prep() { : \
|
|
&& [ "$(whoami)" != podman ] \
|
|
|| { : \
|
|
&& { [ -d ~/.config ] || mkdir ~/.config ;} \
|
|
&& { [ -d ~/.config/containers ] || mkdir ~/.config/containers ;} \
|
|
&& { [ -d ~/junk ] || mkdir ~/junk ;} \
|
|
&& printf '%s\n' >~/.config/containers/storage.conf \
|
|
'[storage]' 'driver = "overlay"' 'runroot = "$HOME/junk"' \
|
|
'graphroot = "$HOME/junk"' 'rootless_storage_path = "$HOME/junk"' \
|
|
'[storage.options]' 'additionalimagestores = [' ']' \
|
|
'[storage.options.overlay]' 'mountopt = "nodev"' \
|
|
'[storage.options.thinpool]' \
|
|
;} \
|
|
;}
|
|
|
|
: \
|
|
&& me="$(readlink -f "$0")" && cd "${me%/*}" && { [ -d out ] || mkdir out ;} \
|
|
&& prep \
|
|
\
|
|
`# phase 1` \
|
|
&& build notwa-util \
|
|
`# phase 2` \
|
|
&& build cosmo-bootstrap \
|
|
`# phase 3` \
|
|
&& build cosmo-all \
|
|
&& build cosmo-dist \
|
|
&& build rescue \
|
|
`# phase 4` \
|
|
&& build cosmo-base \
|
|
&& build_simple \
|
|
`# phase 5` \
|
|
&& build cosmo-kuroko \
|
|
&& build cosmo-muon \
|
|
&& build cosmo-perl \
|
|
&& build cosmo-yices \
|
|
`# other stuff` \
|
|
&& { [ ! -e cosmo-mini ] || build cosmo-mini ;} \
|
|
&& { [ ! -e cosmo-python311 ] || build cosmo-python311 ;} \
|
|
\
|
|
&& yes_retrieve cosmo-base /cosmopolitan/bin/ape \
|
|
&& dbg_retrieve cosmo-kuroko /bin/kuroko.com \
|
|
&& dbg_retrieve cosmo-muon /bin/muon.com \
|
|
&& dbg_retrieve cosmo-perl /bin/perl.com \
|
|
&& dbg_retrieve cosmo-yices /bin/kissat.com /bin/yices-sat.com \
|
|
/bin/yices-smt.com /bin/yices-smt2.com \
|
|
/bin/yices.com \
|
|
\
|
|
&& dbg_retrieve assimilate /bin/assimilate.com \
|
|
&& dbg_retrieve bd /bin/bd.com \
|
|
&& dbg_retrieve bing /bin/bing.com /bin/unbing.com \
|
|
&& dbg_retrieve blinkenlights /bin/blinkenlights.com \
|
|
&& dbg_retrieve cosmo-awk /bin/awk.com \
|
|
&& dbg_retrieve cosmo-chibicc /bin/chibicc.com \
|
|
&& dbg_retrieve cosmo-lua /bin/lua.com /bin/luac.com \
|
|
&& dbg_retrieve cosmo-make /bin/make.com \
|
|
&& dbg_retrieve cosmo-python /bin/python.com \
|
|
&& dbg_retrieve cosmo-quickjs /bin/qjs.com /bin/qjsc.com \
|
|
&& dbg_retrieve cosmo-sed /bin/sed.com \
|
|
&& dbg_retrieve cosmo-sqlite /bin/sqlite3.com \
|
|
&& dbg_retrieve fold /bin/fold.com \
|
|
&& dbg_retrieve greenbean /bin/greenbean.com \
|
|
&& dbg_retrieve hello /bin/hello.com \
|
|
&& dbg_retrieve life /bin/life.com \
|
|
&& dbg_retrieve memzoom /bin/memzoom.com \
|
|
&& dbg_retrieve mkdeps /bin/mkdeps.com \
|
|
&& dbg_retrieve pledge /bin/pledge.com \
|
|
&& dbg_retrieve printimage /bin/printimage.com \
|
|
&& dbg_retrieve printvideo /bin/printvideo.com \
|
|
&& dbg_retrieve redbean /bin/redbean.com \
|
|
&& dbg_retrieve tinyemu /bin/tinyemu.com \
|
|
&& dbg_retrieve unbourne /bin/unbourne.com \
|
|
&& dbg_retrieve unveil /bin/unveil.com \
|
|
;
|