stagex/packages/iputils/Containerfile
2024-03-09 17:23:18 -08:00

114 lines
3.1 KiB
Docker

FROM scratch AS base
ENV VERSION=20240117
ENV SRC_HASH=a5d66e2997945b2541b8f780a7f5a5ec895d53a517ae1dc4f3ab762573edea9a
ENV SRC_FILE=${VERSION}.tar.gz
ENV SRC_SITE=https://github.com/iputils/iputils/archive/refs/tags/${SRC_FILE}
FROM base AS fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
FROM fetch AS build
COPY --from=stagex/busybox . /
COPY --from=stagex/binutils . /
COPY --from=stagex/libcap . /
COPY --from=stagex/gcc . /
COPY --from=stagex/meson . /
COPY --from=stagex/musl . /
COPY --from=stagex/python . /
COPY --from=stagex/zlib . /
RUN tar -xzf ${SRC_FILE}
WORKDIR iputils-${VERSION}
RUN --network=none <<-EOF
set -eux;
./configure
meson env2mfile \
--native \
--system=linux \
--cpu-family=x86_64 \
--cpu=x86_64 \
--endian=little \
-o meson.cross
meson setup \
--prefix=/usr \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--includedir=/usr/include \
--datadir=/usr/share \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localedir=/usr/share/locale \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--buildtype=plain \
--auto-features=auto \
--wrap-mode=nodownload \
--default-library=both \
--cross-file=meson.cross \
-Dbacktrace=disabled \
-Db_lto=false \
-Db_staticpic=true \
-Db_pie=true \
-Dpython.bytecompile=0 \
-Dwerror=false \
-Db_ndebug=true \
-Dbin_tests=false \
-Dbin_contrib=false \
-Dbin_programs=true \
-Dbacktrace=disabled \
-Dmulti_thread=enabled \
-Dlz4=disabled \
-Dlzma=disabled \
-Dzlib=disabled \
build/meson \
builddir
meson compile -C output
EOF
FROM build AS install
USER 0:0
RUN meson install DESTDIR=/rootfs
COPY --from=stagex/musl . /rootfs/
RUN find /rootfs -exec touch -hcd "@0" "{}" +
FROM base AS test
COPY --from=install /rootfs /
COPY --from=stagex/binutils . /
COPY --from=stagex/meson . /
COPY --from=stagex/musl . /
COPY --from=stagex/gcc . /
RUN /bin/sh <<-EOF
set -eux
ARPING_VERSION=$(arping -V)
CLOCKDIFF_VERSION=$(clockdiff -V)
PING_VERSION=$(ping -V)
TRACEPATH_VERSION=$(tracepath -V)
if [ "${ARPING_VERION}" != "arping from iputils ${VERSION}"]; then
echo "Expected arping version ${VERSION} but got ${ARPING_VERSION}"
exit 1
fi
if [ "${CLOCKDIFF_VERION}" != "arping from iputils ${VERSION}"]; then
echo "Expected arping version ${VERSION} but got ${CLOCKDIFF_VERSION}"
exit 1
fi
if [ "${PING_VERION}" != "arping from iputils ${VERSION}"]; then
echo "Expected arping version ${VERSION} but got ${PING_VERSION}"
exit 1
fi
if [ "${TRACEPATH_VERION}" != "arping from iputils ${VERSION}"]; then
echo "Expected arping version ${VERSION} but got ${TRACEPATH_VERSION}"
exit 1
fi
EOF
FROM stagex/filesystem AS package
COPY --from=install /rootfs /
USER 100:100
ENTRYPOINT ["/usr/bin/iputils"]
CMD ["--version"]