55 lines
1.6 KiB
Bash
Executable file
55 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/false
|
|
|
|
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 "localhost/$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 \
|
|
;}
|
|
|
|
build_base() { : \
|
|
&& sed 's/\bcosmo-bootstrap\b/cosmo-all/g' \
|
|
<cosmo-dist/Dockerfile >cosmo-dist/all.Dockerfile \
|
|
&& `# sed -i 's/#&& find o/ \&\& find o/' cosmo-dist/all.Dockerfile` \
|
|
&& build cosmo-dist -f cosmo-dist/all.Dockerfile \
|
|
&& build cosmo-base \
|
|
;}
|