diff --git a/.github/workflows/base-glibc-busybox-bash.yaml b/.github/workflows/base-glibc-busybox-bash.yaml index 38cb8480..cb7f96a7 100644 --- a/.github/workflows/base-glibc-busybox-bash.yaml +++ b/.github/workflows/base-glibc-busybox-bash.yaml @@ -53,12 +53,16 @@ jobs: buildah manifest create "${image_name}:${tag}" done + buildah bud \ + --build-arg=busybox_version='${{ env.BUSYBOX_VERSION }}' \ + --file=Dockerfile.busybox \ + --tag=busybox-build + for arch in amd64 arm64 ; do iidfile="$( mktemp )" buildah bud --layers \ --arch="${arch}" \ --iidfile="${iidfile}" \ - --build-arg=busybox_version='${{ env.BUSYBOX_VERSION }}' \ --build-arg=debian_version='${{ env.DEBIAN_VERSION }}' image_id="$( cat "${iidfile}" )" rm "${iidfile}" diff --git a/images/base-glibc-busybox-bash/Dockerfile b/images/base-glibc-busybox-bash/Dockerfile index b8240cf7..d0ef6ead 100644 --- a/images/base-glibc-busybox-bash/Dockerfile +++ b/images/base-glibc-busybox-bash/Dockerfile @@ -10,28 +10,15 @@ RUN [ ! -f /etc/apt/sources.list ] || sed --in-place= --regexp-extended \ /etc/apt/sources.list -# Build busybox ourselves to have more fine-grained control over what we want -# (or not want) to include. -# Use old Debian version to ensure compatible (low glibc requirement) binaries. -FROM debian:9-slim AS busybox_builder -RUN [ ! -f /etc/apt/sources.list ] || sed --in-place= --regexp-extended \ - '/ stretch/ { s,-updates,-backports, ; s,/(deb|security)\.,/archive., }' \ - /etc/apt/sources.list \ - && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive \ - apt-get install --yes --no-install-recommends \ - bzip2 curl ca-certificates tar gcc libc6-dev make patch - -WORKDIR /build -COPY build-busybox ./ -ARG busybox_version -RUN ./build-busybox "${busybox_version}" +FROM build_base AS rootfs_builder +COPY --from=localhost/busybox-build /build /build WORKDIR /busybox-rootfs -RUN mkdir -p ./bin ./sbin ./usr/bin ./usr/sbin \ +RUN arch="$( uname -m )" \ + && \ + mkdir -p ./bin ./sbin ./usr/bin ./usr/sbin \ && \ - cp -al /build/busybox ./bin/ \ + cp -al "/build/busybox.${arch}" ./bin/busybox \ && \ ldd ./bin/busybox \ | grep --only-matching --extended-regexp '/lib\S+' \ @@ -41,10 +28,6 @@ RUN mkdir -p ./bin ./sbin ./usr/bin ./usr/sbin \ && \ rm -rf ./lib* - -FROM build_base AS rootfs_builder - -COPY --from=busybox_builder /busybox-rootfs /busybox-rootfs WORKDIR /rootfs RUN mkdir -p ./etc ./home ./opt ./root ./run /tmp ./usr ./var/log \ diff --git a/images/base-glibc-busybox-bash/Dockerfile.busybox b/images/base-glibc-busybox-bash/Dockerfile.busybox new file mode 100644 index 00000000..fcbd60bd --- /dev/null +++ b/images/base-glibc-busybox-bash/Dockerfile.busybox @@ -0,0 +1,23 @@ +# Build busybox ourselves to have more fine-grained control over what we want +# (or not want) to include. +# Use old Debian version to ensure compatible (low glibc requirement) binaries. +FROM debian:9-slim AS busybox_builder +RUN [ ! -f /etc/apt/sources.list ] || sed --in-place= --regexp-extended \ + '/ stretch/ { s,-updates,-backports, ; s,/(deb|security)\.,/archive., }' \ + /etc/apt/sources.list \ + && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install --yes --no-install-recommends \ + bzip2 curl ca-certificates tar \ + gcc libc6-dev \ + gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ + make patch + +WORKDIR /build +COPY build-busybox ./ +ARG busybox_version +RUN ./build-busybox \ + "${busybox_version}" \ + x86_64 aarch64 + diff --git a/images/base-glibc-busybox-bash/build-busybox b/images/base-glibc-busybox-bash/build-busybox index db642e9e..902b3375 100755 --- a/images/base-glibc-busybox-bash/build-busybox +++ b/images/base-glibc-busybox-bash/build-busybox @@ -125,10 +125,16 @@ build() { main() { version="${1}" + shift download patch - config - build + for target ; do + export MAKEFLAGS="ARCH=${target} CROSS_COMPILE=${target}-linux-gnu-" + make clean + config + build + cp -al ./busybox "./busybox.${target}" + done } main "${@}"