From 78c1cda400a78cd38280d504dd979ff2cebaab60 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 14 Oct 2022 23:22:01 -0700 Subject: [PATCH] cosmo: split into cosmo-bootstrap and cosmo-base --- build-all | 5 ++- cosmo-base/Dockerfile | 57 ++++++++++++++++++++++++++ {cosmo => cosmo-bootstrap}/Dockerfile | 55 ------------------------- {cosmo => cosmo-bootstrap}/make.com | Bin cosmo-kuroko/Dockerfile | 2 +- cosmo-muon/Dockerfile | 2 +- cosmo-perl/Dockerfile | 2 +- cosmo-yices/Dockerfile | 2 +- 8 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 cosmo-base/Dockerfile rename {cosmo => cosmo-bootstrap}/Dockerfile (60%) rename {cosmo => cosmo-bootstrap}/make.com (100%) diff --git a/build-all b/build-all index 4f41493..4c80333 100755 --- a/build-all +++ b/build-all @@ -28,14 +28,15 @@ dbg_retrieve() { : \ && me="$(readlink -f "$0")" && cd "${me%/*}" && { [ -d out ] || mkdir out ;} \ \ && podman build -t notwa-util notwa-util \ - && podman build -t cosmo cosmo \ + && podman build -t cosmo-bootstrap cosmo-bootstrap \ + && podman build -t cosmo-base cosmo-base \ && podman build -t cosmo-kuroko cosmo-kuroko \ && podman build -t cosmo-muon cosmo-muon \ && podman build -t cosmo-perl cosmo-perl \ && podman build -t cosmo-yices cosmo-yices \ \ && bin=/cosmopolitan/bin \ - && yes_retrieve cosmo $bin/ape $bin/awk.com $bin/gzip.com $bin/make.com \ + && yes_retrieve cosmo-base $bin/ape $bin/awk.com $bin/gzip.com $bin/make.com \ $bin/sed.com $bin/unbourne.com $bin/unzip.com $bin/zip.com \ && dbg_retrieve cosmo-kuroko /bin/kuroko.com \ && dbg_retrieve cosmo-muon /bin/muon.com \ diff --git a/cosmo-base/Dockerfile b/cosmo-base/Dockerfile new file mode 100644 index 0000000..aa70a3a --- /dev/null +++ b/cosmo-base/Dockerfile @@ -0,0 +1,57 @@ +FROM localhost/cosmo-bootstrap AS builder + +# install the basics (no executable binaries besides ape.elf) +RUN : \ + && . ./env \ + && mkdir dist "dist/$flavor" "dist/$flavor/public" \ + && echo /dist >>.gitignore \ + && ./expand cp -t "dist/$flavor" \ + a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ + a//ape.lds a//ape.macho a//ape.o \ + o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \ + && cp -t "dist/$flavor/public" "o/$mode/ape/public/ape.lds" \ +\ + && install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \ + && find libc -name '*.h' >headers.txt \ + && ./expand tar zcf dist/headers.tar.gz -T headers.txt \ + ape/config.h libc/integral T//gdtoa/gdtoa.h \ + T//getopt/getopt.h T//linenoise/linenoise.h T//musl/crypt.h \ + T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \ + T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \ + T//zlib/zconf.h T//zlib/zlib.h \ +; + +# install the rest +FROM builder AS distrib +RUN --mount=type=tmpfs,target=/tmp : \ + && . ./env \ + && find o -name '*.sym' -delete \ + && dedupe o/third_party/gcc /distrib/gcc/ \ + bin/x86_64-linux-musl-gcc \ + bin/x86_64-linux-musl-g++ \ + bin/x86_64-linux-musl-ld.bfd \ + && dedupe dist /distrib/dist/ "$flavor/cosmopolitan.h" \ + && mkdir /tmp/bin \ +# discover .com files by uncommenting this command: \ +#&& find o -name '*.com' ! -type d -exec printf '%s\n' cp -t /tmp/bin {} + | sort && exit 1 \ + && ./expand cp -t /tmp/bin \ + e//unbourne.com t//awk/awk.com t//make/make.com \ + t//sed/sed.com t//unzip/unzip.com t//zip/zip.com \ + b//ar.com b//assimilate.com b//cocmd.com \ + b//compile.com b//cp.com b//echo.com \ + b//fixupobj.com b//gzip.com b//mkdeps.com \ + b//mkdir.com b//package.com b//pwd.com \ + b//rm.com b//rollup.com b//symtab.com \ + b//touch.com b//unbundle.com b//zipobj.com \ + && dedupe /tmp/bin /distrib/bin/ \ +#&& ln -s "../dist/$flavor/ape.elf" /distrib/bin/ape \ + && cp "dist/$flavor/ape.elf" /distrib/bin/ape \ + && cp /cosmopolitan/env /distrib/env \ +; + +FROM alpine:3.16 AS runner +COPY --from=distrib /distrib /cosmopolitan +ENV PATH="/cosmopolitan/bin:/cosmopolitan/gcc/bin/:/cosmopolitan/gcc/x86_64-linux-musl/bin/:$PATH" +# FIXME: +#ARG COSMO_FLAVOR +#ENV COSMO_DIST="/cosmopolitan/dist/$COSMO_FLAVOR" diff --git a/cosmo/Dockerfile b/cosmo-bootstrap/Dockerfile similarity index 60% rename from cosmo/Dockerfile rename to cosmo-bootstrap/Dockerfile index 0eb0034..4ee2c50 100644 --- a/cosmo/Dockerfile +++ b/cosmo-bootstrap/Dockerfile @@ -84,58 +84,3 @@ RUN --mount=type=tmpfs,target=/tmp : \ e//unbourne.com t//awk/awk.com t//sed/sed.com \ t//unzip/unzip.com t//zip/zip.com b//assimilate.com \ ; - -# install the basics (no executable binaries besides ape.elf) -RUN : \ - && . ./env \ - && mkdir dist "dist/$flavor" "dist/$flavor/public" \ - && echo /dist >>.gitignore \ - && ./expand cp -t "dist/$flavor" \ - a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ - a//ape.lds a//ape.macho a//ape.o \ - o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \ - && cp -t "dist/$flavor/public" "o/$mode/ape/public/ape.lds" \ -\ - && install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \ - && find libc -name '*.h' >headers.txt \ - && ./expand tar zcf dist/headers.tar.gz -T headers.txt \ - ape/config.h libc/integral T//gdtoa/gdtoa.h \ - T//getopt/getopt.h T//linenoise/linenoise.h T//musl/crypt.h \ - T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \ - T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \ - T//zlib/zconf.h T//zlib/zlib.h \ -; - -# install the rest -FROM builder AS distrib -RUN --mount=type=tmpfs,target=/tmp : \ - && . ./env \ - && find o -name '*.sym' -delete \ - && dedupe o/third_party/gcc /distrib/gcc/ \ - bin/x86_64-linux-musl-gcc \ - bin/x86_64-linux-musl-g++ \ - bin/x86_64-linux-musl-ld.bfd \ - && dedupe dist /distrib/dist/ "$flavor/cosmopolitan.h" \ - && mkdir /tmp/bin \ -# discover .com files by uncommenting this command: \ -#&& find o -name '*.com' ! -type d -exec printf '%s\n' cp -t /tmp/bin {} + | sort && exit 1 \ - && ./expand cp -t /tmp/bin \ - e//unbourne.com t//awk/awk.com t//make/make.com \ - t//sed/sed.com t//unzip/unzip.com t//zip/zip.com \ - b//ar.com b//assimilate.com b//cocmd.com \ - b//compile.com b//cp.com b//echo.com \ - b//fixupobj.com b//gzip.com b//mkdeps.com \ - b//mkdir.com b//package.com b//pwd.com \ - b//rm.com b//rollup.com b//symtab.com \ - b//touch.com b//unbundle.com b//zipobj.com \ - && dedupe /tmp/bin /distrib/bin/ \ -#&& ln -s "../dist/$flavor/ape.elf" /distrib/bin/ape \ - && cp "dist/$flavor/ape.elf" /distrib/bin/ape \ - && cp /cosmopolitan/env /distrib/env \ -; - -FROM alpine:3.16 AS runner -COPY --from=distrib /distrib /cosmopolitan -ENV PATH="/cosmopolitan/bin:/cosmopolitan/gcc/bin/:/cosmopolitan/gcc/x86_64-linux-musl/bin/:$PATH" -ARG COSMO_FLAVOR -ENV COSMO_DIST="/cosmopolitan/dist/$COSMO_FLAVOR" diff --git a/cosmo/make.com b/cosmo-bootstrap/make.com similarity index 100% rename from cosmo/make.com rename to cosmo-bootstrap/make.com diff --git a/cosmo-kuroko/Dockerfile b/cosmo-kuroko/Dockerfile index 1952d40..e97b92f 100644 --- a/cosmo-kuroko/Dockerfile +++ b/cosmo-kuroko/Dockerfile @@ -11,7 +11,7 @@ RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \ && acquire from=github repo=kuroko-lang/kuroko dest=/kuroko env=KUROKO \ ; -FROM localhost/cosmo AS builder +FROM localhost/cosmo-base AS builder COPY --from=downloader /kuroko /kuroko WORKDIR /kuroko diff --git a/cosmo-muon/Dockerfile b/cosmo-muon/Dockerfile index 2084baf..ee66cfe 100644 --- a/cosmo-muon/Dockerfile +++ b/cosmo-muon/Dockerfile @@ -8,7 +8,7 @@ RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \ && acquire from=sourcehut repo=lattis/muon dest=/muon env=MUON \ ; -FROM localhost/cosmo AS builder +FROM localhost/cosmo-base AS builder RUN apk add --no-cache ninja COPY --chmod=0755 --from=localhost/notwa-util /nu/cosmocc /usr/bin/ diff --git a/cosmo-perl/Dockerfile b/cosmo-perl/Dockerfile index 74c81ee..6eacd83 100644 --- a/cosmo-perl/Dockerfile +++ b/cosmo-perl/Dockerfile @@ -26,7 +26,7 @@ RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \ && acquire \ ; -FROM localhost/cosmo AS builder +FROM localhost/cosmo-base AS builder COPY --from=downloader /perl /perl RUN : \ diff --git a/cosmo-yices/Dockerfile b/cosmo-yices/Dockerfile index 863b52b..c3366c3 100644 --- a/cosmo-yices/Dockerfile +++ b/cosmo-yices/Dockerfile @@ -28,7 +28,7 @@ RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \ && acquire from=github repo=arminbiere/kissat dest=/kissat env=KISSAT \ ; -FROM localhost/cosmo AS builder +FROM localhost/cosmo-base AS builder RUN apk add --no-cache autoconf gperf