package gen_initramfs and cpio

This commit is contained in:
Lance Vick 2024-01-31 03:15:42 -08:00
parent 41befd1345
commit 41469a293a
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
3 changed files with 57 additions and 0 deletions

View File

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

46
src/tools/cpio/Dockerfile Normal file
View File

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

View File

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