From 324c6cabe7d4740c4d51b1f80f011ff454d86ef7 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 15 Oct 2022 00:32:45 -0700 Subject: [PATCH] bootstrap: add optional rebuild feature (`COSMO_REBUILD=1`) --- cosmo-bootstrap/Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cosmo-bootstrap/Dockerfile b/cosmo-bootstrap/Dockerfile index 55127eb..600ea25 100644 --- a/cosmo-bootstrap/Dockerfile +++ b/cosmo-bootstrap/Dockerfile @@ -3,6 +3,7 @@ ARG COSMO_FLAVOR=def ARG COSMO_COMMIT=f52f65b2e351085250b743a5319dab418f2d48be ARG COSMO_SHA256=8a13f4be3d689b8895af6e1178d455db2f82a69e33ce5848e2f2f14f96760d4c +ARG COSMO_REBUILD=0 FROM localhost/notwa-util AS downloader ARG COSMO_COMMIT COSMO_SHA256 @@ -80,7 +81,34 @@ RUN --mount=type=tmpfs,target=/tmp : \ b//mkdir.com b//package.com b//pwd.com \ b//rm.com b//touch.com b//unbundle.com \ b//zipobj.com \ +# install the newly-built ape loader, just in case it has changed: \ + && ./expand install -m0755 a//ape.elf /usr/bin/ape \ +; + +# optionally use the newly-built bootstrapped binaries to build themselves again. +ARG COSMO_REBUILD +RUN --mount=type=tmpfs,target=/tmp : \ + && { [ "$COSMO_REBUILD" = 1 ] || exit 0 ;} \ + && rm -r o \ +\ + && ./expand ./makeit \ + a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ + a//ape.lds a//ape.macho a//ape.o \ + a//public/ape.lds o//cosmopolitan.a o//libc/crt/crt.o \ + o/cosmopolitan.h \ +# build some extra tools for other containers to stem off of: \ + && rebuild() { ./expand ./makeit "$@" && ./expand cp -t build/bootstrap "$@" ;} \ + && rebuild \ + t//make/make.com b//ar.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//touch.com b//unbundle.com \ + b//zipobj.com \ +; + # these are essential too! \ +RUN --mount=type=tmpfs,target=/tmp : \ && ./expand ./makeit \ e//unbourne.com t//awk/awk.com t//sed/sed.com \ t//unzip/unzip.com t//zip/zip.com b//assimilate.com \