bootstrap: add optional rebuild feature (COSMO_REBUILD=1)

This commit is contained in:
Connor Olding 2022-10-15 00:32:45 -07:00
parent f9d7c4398d
commit 324c6cabe7

View file

@ -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 \