From 41469a293adbce1a99c37504ba204deef1f3c779 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Wed, 31 Jan 2024 03:15:42 -0800 Subject: [PATCH] package gen_initramfs and cpio --- src/tools/build.mk | 7 +++++ src/tools/cpio/Dockerfile | 46 ++++++++++++++++++++++++++++++ src/tools/gen_initramfs/Dockerfile | 4 +++ 3 files changed, 57 insertions(+) create mode 100644 src/tools/cpio/Dockerfile diff --git a/src/tools/build.mk b/src/tools/build.mk index b5d8285..4df1b47 100644 --- a/src/tools/build.mk +++ b/src/tools/build.mk @@ -10,9 +10,16 @@ out/curl.tgz: \ out/gen_initramfs.tgz: \ out/gcc.tgz \ + out/binutils.tgz \ out/musl.tgz $(call build,tools,gen_initramfs) +out/cpio.tgz: \ + out/gcc.tgz \ + out/binutils.tgz \ + out/musl.tgz + $(call build,tools,cpio) + out/tofu.tgz: \ out/busybox.tgz \ out/go.tgz diff --git a/src/tools/cpio/Dockerfile b/src/tools/cpio/Dockerfile new file mode 100644 index 0000000..826c272 --- /dev/null +++ b/src/tools/cpio/Dockerfile @@ -0,0 +1,46 @@ +ARG REGISTRY=local +from ${REGISTRY}/binutils as binutils +from ${REGISTRY}/gcc as gcc +from ${REGISTRY}/musl as musl +from ${REGISTRY}/make as make +from ${REGISTRY}/busybox as busybox + +FROM busybox as base +ENV SRC_SITE=https://ftp.gnu.org/gnu/cpio +ENV SRC_VERSION=2.15 +ENV SRC_HASH=efa50ef983137eefc0a02fdb51509d624b5e3295c980aa127ceee4183455499e +ENV SRC_FILE=cpio-${SRC_VERSION}.tar.gz + +FROM base as fetch +RUN set -eux; \ + wget ${SRC_SITE}/${SRC_FILE}; \ + echo "${SRC_HASH} ${SRC_FILE}" | sha256sum -c + +FROM fetch as build +RUN tar -xzf ${SRC_FILE} +WORKDIR cpio-${SRC_VERSION} +COPY --from=gcc . / +COPY --from=binutils . / +COPY --from=make . / +COPY --from=musl . / +RUN set -eux; \ + mkdir -p /home/user/rootfs/lib; \ + ./configure \ + --build=x86_64-unknown-linux-musl \ + --host=x86_64-unknown-linux-musl \ + --prefix=/usr \ + --bindir=/bin \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info; \ + make + +FROM build as install +USER 0:0 +RUN make DESTDIR=/rootfs install +COPY --from=musl /usr/lib/libc.so /rootfs/lib/ld-musl-x86_64.so.1 +RUN find /rootfs -exec touch -hcd "@0" "{}" + + +FROM scratch as package +COPY --from=install /rootfs / +ENTRYPOINT ["/bin/cpio"] +CMD ["--version"] diff --git a/src/tools/gen_initramfs/Dockerfile b/src/tools/gen_initramfs/Dockerfile index 3db0b17..2d4f279 100644 --- a/src/tools/gen_initramfs/Dockerfile +++ b/src/tools/gen_initramfs/Dockerfile @@ -1,6 +1,7 @@ ARG REGISTRY=local FROM ${REGISTRY}/musl as musl FROM ${REGISTRY}/gcc as gcc +FROM ${REGISTRY}/binutils as binutils FROM ${REGISTRY}/busybox as busybox FROM busybox as base @@ -16,6 +17,9 @@ RUN echo "${SRC_HASH} linux-${SRC_VERSION}.tar.xz" | sha256sum -c FROM fetch as build RUN tar -xf linux-${SRC_VERSION}.tar.xz WORKDIR linux-${SRC_VERSION} +COPY --from=gcc . / +COPY --from=binutils . / +COPY --from=musl . / RUN gcc usr/gen_init_cpio.c -o usr/gen_init_cpio FROM build as install