Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkimage-iso-efi should always build for architecture of its tar input stream #4667

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions pkg/mkimage-iso-efi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# to have access to packages for alternate arches
# hadolint ignore=DL3029
FROM --platform=linux/amd64 lfedge/eve-alpine:591df01e581889c3027514c8a91feaca1c8ad49f AS build-amd64
# hadolint ignore=DL3029
FROM --platform=linux/arm64 lfedge/eve-alpine:591df01e581889c3027514c8a91feaca1c8ad49f AS build-arm64

# the one we build is our local
FROM lfedge/eve-alpine:591df01e581889c3027514c8a91feaca1c8ad49f AS build

ENV PKGS dosfstools libarchive-tools binutils mtools xorriso mkinitfs squashfs-tools
Expand All @@ -22,12 +15,6 @@ RUN if ! grep -q -w /sbin/nlplug-findfs /out/etc/mkinitfs/features.d/base.files
fi
RUN echo /bin/grep >> /out/etc/mkinitfs/features.d/base.files

# for alternate architectures
COPY --from=build-amd64 /bin/busybox /out/arch/amd64/bin/
COPY --from=build-amd64 /lib/ld-musl* /out/arch/amd64/lib/
COPY --from=build-arm64 /bin/busybox /out/arch/arm64/bin/
COPY --from=build-arm64 /lib/ld-musl* /out/arch/arm64/lib/

FROM scratch
COPY --from=build /out /
COPY . /
Expand Down
7 changes: 2 additions & 5 deletions pkg/mkimage-iso-efi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ In addition, the following will be created:
1. An El Torito compliant FAT32 image that can be booted by UEFI firmware.
1. An `initrd.img` that can be used to boot the kernel and mount the ISO filesystem.

The `initrd.img` will be for the architecture on which you are running, for example linux/amd64. If you wish to
build for another architecture, do one of the following:

* `docker run --platform <other-platform>`, e.g. `docker run --platform linux/arm64` while on `linux/amd64`
* pass the target architecture as `TARGETARCH` environment variable, e.g. `docker run -e TARGETARCH=arm64` while on `linux/amd64`
The `initrd.img` will be for the architecture of the input filesystem tar stream. All executables placed in the initrd, if
needed, will be taken from the tar.

## Usage

Expand Down
13 changes: 2 additions & 11 deletions pkg/mkimage-iso-efi/make-efi
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,14 @@ if [ -n "$VOLUME_LABEL" ]; then
VOL_LABEL="-V $VOLUME_LABEL"
fi

# we copy over to the initrd the image for the appropriate architecture. If none provided, use ours.
CPBASE=
if [ -n "$TARGETARCH" ]; then
# canonicalize the architecture
[ "$TARGETARCH" = "x86_64" ] && TARGETARCH="amd64"
[ "$TARGETARCH" = "aarch64" ] && TARGETARCH="arm64"
CPBASE=/arch/${TARGETARCH}
fi

if [ ! -e boot/initrd.img ]; then
# all of the things we need to make a simple initrd
mkdir -p /tmp/initrd
(cd /tmp/initrd
mkdir -p bin lib sbin etc proc sys newroot
cp /initrd.sh init
cp "${CPBASE}"/bin/busybox bin/
cp "${CPBASE}"/lib/ld-musl* lib/
cp "${ROOTFS}"/bin/busybox bin/
cp "${ROOTFS}"/lib/ld-musl* lib/
/bin/busybox --install -s /tmp/initrd/bin
find . | cpio -H newc -o | gzip > /tmp/initrd.img)
mv /tmp/initrd.img boot/initrd.img
Expand Down
Loading