aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Donnellan <ajd@linux.ibm.com>2020-10-06 18:28:19 +1100
committerDmitry Vyukov <dvyukov@google.com>2020-10-08 12:17:15 +0200
commit4598187963f9fe976d56f4f0fc81f680cc215583 (patch)
tree658575919828c31644ce380aa609f094fb82ae72
parent0e469495ddd1f4be4ba3a94e3865ae8acc3f165c (diff)
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 <ajd@linux.ibm.com>
-rwxr-xr-xtools/create-image.sh18
1 files changed, 14 insertions, 4 deletions
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