From 4598187963f9fe976d56f4f0fc81f680cc215583 Mon Sep 17 00:00:00 2001 From: Andrew Donnellan Date: Tue, 6 Oct 2020 18:28:19 +1100 Subject: tools/create-image.sh: fix building of i386 images on x86_64 host When building an i386 image on an x86_64 host, we don't need to use qemu or check for the presence of an appropriate qemu binfmt_misc configuration. i386 binaries can run natively, so we also don't need to do debootstrap in two stages. Skip qemu checks and run debootstrap in one stage when building i386 on an x86_64 host. Signed-off-by: Andrew Donnellan --- tools/create-image.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/create-image.sh b/tools/create-image.sh index db710a27c..a9be8d10c 100755 --- a/tools/create-image.sh +++ b/tools/create-image.sh @@ -95,7 +95,16 @@ case "$ARCH" in esac # Foreign architecture + +FOREIGN=false if [ $ARCH != $(uname -m) ]; then + # i386 on an x86_64 host is exempted, as we can run i386 binaries natively + if [ $ARCH != "i386" -o $(uname -m) != "x86_64" ]; then + FOREIGN=true + fi +fi + +if [ $FOREIGN = "true" ]; then # Check for according qemu static binary if ! which qemu-$ARCH-static; then echo "Please install qemu static binary for architecture $ARCH (package 'qemu-user-static' on Debian/Ubuntu/Fedora)" @@ -125,15 +134,16 @@ sudo chmod 0755 $DIR # 1. debootstrap stage -DEBOOTSTRAP_PARAMS="--include=$PREINSTALL_PKGS --components=main,contrib,non-free $RELEASE $DIR" -if [ $ARCH != $(uname -m) ]; then - DEBOOTSTRAP_PARAMS="--arch=$DEBARCH --foreign $DEBOOTSTRAP_PARAMS" +DEBOOTSTRAP_PARAMS="--arch=$DEBARCH --include=$PREINSTALL_PKGS --components=main,contrib,non-free $RELEASE $DIR" +if [ $FOREIGN = "true" ]; then + DEBOOTSTRAP_PARAMS="--foreign $DEBOOTSTRAP_PARAMS" fi + sudo debootstrap $DEBOOTSTRAP_PARAMS # 2. debootstrap stage: only necessary if target != host architecture -if [ $ARCH != $(uname -m) ]; then +if [ $FOREIGN = "true" ]; then sudo cp $(which qemu-$ARCH-static) $DIR/$(which qemu-$ARCH-static) sudo chroot $DIR /bin/bash -c "/debootstrap/debootstrap --second-stage" fi -- cgit mrf-deployment