live-bootstrap refactor pass 1

This commit is contained in:
Lance Vick 2024-01-16 00:15:27 -08:00
parent f0038c8f9c
commit f542a9468e
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
5 changed files with 97 additions and 81 deletions

View File

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

View File

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

View File

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

View File

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

View File

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