cosmo: split into cosmo-bootstrap and cosmo-base

This commit is contained in:
Connor Olding 2022-10-14 23:22:01 -07:00
parent 0fa24ccc22
commit 78c1cda400
8 changed files with 64 additions and 61 deletions

View File

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

57
cosmo-base/Dockerfile Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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