From f542a9468eca54efa87eb82012f64b5a124f8c34 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Tue, 16 Jan 2024 00:15:27 -0800 Subject: [PATCH] live-bootstrap refactor pass 1 --- src/bootstrap/bootstrap/Dockerfile | 18 ------- src/bootstrap/build.mk | 9 ++-- src/bootstrap/live-bootstrap/Dockerfile | 69 +++++++++++++++++++++++++ src/bootstrap/mes/Dockerfile | 32 ------------ src/bootstrap/stage0/Dockerfile | 50 +++++++++--------- 5 files changed, 97 insertions(+), 81 deletions(-) delete mode 100644 src/bootstrap/bootstrap/Dockerfile create mode 100644 src/bootstrap/live-bootstrap/Dockerfile delete mode 100644 src/bootstrap/mes/Dockerfile diff --git a/src/bootstrap/bootstrap/Dockerfile b/src/bootstrap/bootstrap/Dockerfile deleted file mode 100644 index b0512d7..0000000 --- a/src/bootstrap/bootstrap/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 as seed - -FROM seed as fetch -RUN set -ex; \ - apk update; \ - apk add gcc g++ libc-dev make linux-headers patch -RUN find / \ - \( -name sys \ - -o -name proc \ - -o -name dev \ - -o -path /etc/resolv.conf \ - -o -path /etc/hosts \ - \) \ - -prune \ - -o -type f \ - -exec touch -hcd "@0" "{}" + - -FROM fetch as package diff --git a/src/bootstrap/build.mk b/src/bootstrap/build.mk index c55927a..535c43c 100644 --- a/src/bootstrap/build.mk +++ b/src/bootstrap/build.mk @@ -1,13 +1,10 @@ .PHONY: bootstrap bootstrap: \ - out/bootstrap.tgz \ + out/live-bootstrap.tgz \ out/stage0.tgz -out/bootstrap.tgz: - $(call build,bootstrap,bootstrap) +out/live-bootstrap.tgz: out/stage0.tgz + $(call build,bootstrap,live-bootstrap) out/stage0.tgz: $(call build,bootstrap,stage0) - -out/mes.tgz: out/stage0.tgz - $(call build,bootstrap,mes) diff --git a/src/bootstrap/live-bootstrap/Dockerfile b/src/bootstrap/live-bootstrap/Dockerfile new file mode 100644 index 0000000..26eb3da --- /dev/null +++ b/src/bootstrap/live-bootstrap/Dockerfile @@ -0,0 +1,69 @@ +ARG REGISTRY=local +ARG VERSION=fc6eeb6bd75ea0d0025a79ea9fe45614bd60ba14 +ARG SRC_SITE=https://codeload.github.com/lrvick/live-bootstrap/legacy.tar.gz +ARG SRC_HASH=0c268b19cf9f4eefdaf45dab64ac393ccf8ee43de58f0721624cab358044bf78 +FROM debian@sha256:bac353db4cc04bc672b14029964e686cd7bad56fe34b51f432c1a1304b9928da as debian +FROM ${REGISTRY}/stage0 as stage0 + +FROM debian as fetch +ARG VERSION +ENV VERSION=${VERSION} +ARG SRC_SITE +ENV SRC_SITE=${SRC_SITE} +ARG SRC_HASH +ENV SRC_HASH=${SRC_HASH} +RUN apt update && apt install -y curl gcc +RUN set -eux; \ + curl ${SRC_SITE}/${VERSION} -o live-bootstrap.tar.gz; \ + echo "${SRC_HASH} live-bootstrap.tar.gz" | sha256sum -c; \ + tar -xvf live-bootstrap.tar.gz; \ + mv lrvick-live-bootstrap-* live-bootstrap +WORKDIR live-bootstrap +RUN ./download-distfiles.sh +RUN set -eux; \ + mkdir -p /rootfs; \ + mv steps distfiles seed/* /rootfs/ +RUN echo "\ +FORCE_TIMESTAMPS=False\n\ +CHROOT=True\n\ +UPDATE_CHECKSUMS=False\n\ +JOBS=10\n\ +SWAP_SIZE=0\n\ +FINAL_JOBS=10\n\ +INTERNAL_CI=False\n\ +INTERACTIVE=False\n\ +BARE_METAL=False\n\ +EXTERNAL_SOURCES=True\n\ +DISK=sda1\n\ +KERNEL_BOOTSTRAP=False\n\ +BUILD_KERNELS=False\ +" > /rootfs/steps/bootstrap.cfg +RUN cat /rootfs/steps/bootstrap.cfg + +FROM scratch as build +COPY --from=stage0 / . +COPY --from=fetch /rootfs . +ENV ARCH_DIR=x86 +ENV ARCH=x86 +RUN ["/x86/bin/kaem","--verbose","--strict","--file","./after.kaem"] + +FROM build as install +ENV PATH=/bin:/usr/sbin:/usr/bin +RUN set -eux; \ + rm -rf /usr/lib/python*/__pycache__; \ + mkdir -p /rootfs/etc /rootfs/home/user; \ + cp -R $(ls -d /etc/* | grep -v '\(resolv.conf\|hosts\)') /rootfs/etc/; \ + cp -R lib usr bin var /rootfs/; \ + echo "user:x:1000:" > /rootfs/etc/group; \ + echo "user:x:1000:1000::/home/user:/bin/bash" > /rootfs/etc/passwd; \ + find /rootfs -exec touch -hcd "@0" "{}" + + +FROM scratch as package +COPY --from=install /rootfs / +USER 1000:1000 +ENTRYPOINT ["/bin/bash"] +ENV TZ=UTC +ENV LANG=C.UTF-8 +ENV SOURCE_DATE_EPOCH=1 +ENV KCONFIG_NOTIMESTAMP=1 +ENV PS1="bootstrap$ " diff --git a/src/bootstrap/mes/Dockerfile b/src/bootstrap/mes/Dockerfile deleted file mode 100644 index e613dff..0000000 --- a/src/bootstrap/mes/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -ARG REGISTRY=local -ARG VERSION=0.26 -ARG SRC_SITE=https://gitlab.com/janneke/mes/-/archive/ -ARG SRC_HASH=f0750704013b7d7ec1ca19cf06b6cf28cdcf5581317386006cef074ed368b205 -FROM ${REGISTRY}/stage0 as stage0 -FROM busybox@sha256:ba76950ac9eaa407512c9d859cea48114eeff8a6f12ebaa5d32ce79d4a017dd8 as busybox - -FROM busybox as fetch -ARG VERSION -ENV VERSION=${VERSION} -ARG SRC_SITE -ENV SRC_SITE=${SRC_SITE} -ARG SRC_HASH -ENV SRC_HASH=${SRC_HASH} -RUN set -eux; \ - wget ${SRC_SITE}/v${VERSION}/mes-v${VERSION}.tar.gz -O mes.tgz; \ - echo "${SRC_HASH} mes.tgz" > mes.sha256 -COPY --from=stage0 / /stage0 -RUN ls -lah /stage0 - -FROM stage0 as build -ARG SRC_HASH -ENV SRC_HASH=${SRC_HASH} -ARG VERSION -ENV VERSION=${VERSION} -COPY --from=fetch /mes.tgz mes.tgz -COPY --from=fetch /mes.sha256 mes.sha256 -RUN ["/sha256sum","-c","mes.sha256"] -RUN ["/ungz","--file","mes.tgz","--output","mes.tar"] -RUN ["/untar","--verbose","--non-strict","--file","mes.tar"] -WORKDIR mes-v${VERSION} -RUN ["/M2-Planet","--debug","--architecture","amd64","-f","src/mes.c"] diff --git a/src/bootstrap/stage0/Dockerfile b/src/bootstrap/stage0/Dockerfile index 8287647..82f57ed 100644 --- a/src/bootstrap/stage0/Dockerfile +++ b/src/bootstrap/stage0/Dockerfile @@ -18,10 +18,10 @@ RUN set -eux; \ echo "${SRC_HASH} stage0-posix-${VERSION}.tar.gz" | sha256sum -c; \ tar -xf stage0-posix-${VERSION}.tar.gz WORKDIR stage0-posix-${VERSION} -RUN bootstrap-seeds/POSIX/AMD64/kaem-optional-seed -RUN mv AMD64/bin /rootfs/ +RUN bootstrap-seeds/POSIX/x86/kaem-optional-seed +RUN mkdir -p /rootfs && cp -R * /rootfs/ WORKDIR /rootfs -RUN sha256sum * > hashes.txt +RUN sha256sum x86/bin/* > hashes.txt FROM archlinux as build2 ARG VERSION @@ -36,10 +36,10 @@ RUN set -eux; \ echo "${SRC_HASH} stage0-posix-${VERSION}.tar.gz" | sha256sum -c; \ tar -xf stage0-posix-${VERSION}.tar.gz WORKDIR stage0-posix-${VERSION} -RUN bootstrap-seeds/POSIX/AMD64/kaem-optional-seed -RUN mv AMD64/bin /rootfs/ +RUN bootstrap-seeds/POSIX/x86/kaem-optional-seed +RUN mkdir -p /rootfs && cp -R * /rootfs/ WORKDIR /rootfs -RUN sha256sum * > hashes.txt +RUN sha256sum x86/bin/* > hashes.txt FROM alpine as build3 ARG VERSION @@ -54,10 +54,10 @@ RUN set -eux; \ echo "${SRC_HASH} stage0-posix-${VERSION}.tar.gz" | sha256sum -c; \ tar -xf stage0-posix-${VERSION}.tar.gz WORKDIR stage0-posix-${VERSION} -RUN bootstrap-seeds/POSIX/AMD64/kaem-optional-seed -RUN mv AMD64/bin /rootfs/ +RUN bootstrap-seeds/POSIX/x86/kaem-optional-seed +RUN mkdir -p /rootfs && cp -R * /rootfs/ WORKDIR /rootfs -RUN sha256sum * > hashes.txt +RUN sha256sum x86/bin/* > hashes.txt FROM scratch as compare COPY --from=build1 /rootfs/ /a @@ -66,27 +66,27 @@ COPY --from=build3 /rootfs/ /c FROM compare as test1 WORKDIR /a -RUN ["/a/sha256sum","-c","/a/hashes.txt"] -WORKDIR /b -RUN ["/a/sha256sum","-c","/a/hashes.txt"] -WORKDIR /c -RUN ["/a/sha256sum","-c","/a/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/a/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/b/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/c/hashes.txt"] FROM compare as test2 -WORKDIR /a -RUN ["/b/sha256sum","-c","/b/hashes.txt"] WORKDIR /b -RUN ["/b/sha256sum","-c","/b/hashes.txt"] -WORKDIR /c -RUN ["/b/sha256sum","-c","/b/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/a/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/b/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/c/hashes.txt"] FROM compare as test3 -WORKDIR /a -RUN ["/c/sha256sum","-c","/c/hashes.txt"] -WORKDIR /b -RUN ["/c/sha256sum","-c","/c/hashes.txt"] WORKDIR /c -RUN ["/c/sha256sum","-c","/c/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/a/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/b/hashes.txt"] +RUN ["x86/bin/sha256sum","-c","/c/hashes.txt"] + +FROM scratch as install +COPY --from=test1 /a/hashes.txt /a-hashes.txt +COPY --from=test2 /b/hashes.txt /b-hashes.txt +COPY --from=test3 /c/hashes.txt /c-hashes.txt +COPY --from=build1 /rootfs / FROM scratch as package -COPY --from=build1 /rootfs / +COPY --from=install / /