From 6b1f11fda43be75bf5d181450c3919535026c9c6 Mon Sep 17 00:00:00 2001 From: TheMuso <9444357+TheMuso@users.noreply.github.com> Date: Nov 06 2020 02:35:26 +0000 Subject: Only use qemu when running on a host architecture other than aarch64 (#51) Co-authored-by: Nikhil Jha --- diff --git a/00-selftest.sh b/00-selftest.sh index 9d7b939..31dffef 100755 --- a/00-selftest.sh +++ b/00-selftest.sh @@ -3,6 +3,8 @@ set -e source .env +HOSTARCH=$(uname -m) + echo "==============" echo "00-selftest.sh" echo "==============" @@ -24,7 +26,11 @@ fi command -v mkfs.f2fs >/dev/null 2>&1 || { echo >&2 "I require mkfs.f2fs but it's not installed. Aborting."; exit 1; } command -v mkfs.vfat >/dev/null 2>&1 || { echo >&2 "I require mkfs.vfat but it's not installed. Aborting."; exit 1; } -command -v qemu-aarch64-static >/dev/null 2>&1 || { echo >&2 "I require qemu-aarch64-static but it's not installed. Aborting."; exit 1; } + +if [[ $HOSTARCH -ne "aarch64" ]]; then + command -v qemu-aarch64-static >/dev/null 2>&1 || { echo >&2 "I require qemu-aarch64-static but it's not installed. Aborting."; exit 1; } +fi + command -v rsync >/dev/null 2>&1 || { echo >&2 "I require rsync but it's not installed. Aborting."; exit 1; } command -v mkimage >/dev/null 2>&1 || { echo >&2 "I require mkimage but it's not installed. Aborting."; exit 1; } diff --git a/05-setup-user.sh b/05-setup-user.sh index a404adc..dd39b18 100755 --- a/05-setup-user.sh +++ b/05-setup-user.sh @@ -3,6 +3,8 @@ set -e source .env +HOSTARCH=$(uname -m) + echo "================" echo "05-setup-user.sh" echo "================" @@ -41,23 +43,31 @@ then mkdir -p rootfs/boot mount $PP_PARTA rootfs/boot - infecho "Installing qemu in rootfs..." - cp /usr/bin/qemu-aarch64-static rootfs/usr/bin + if [[ $HOSTARCH -ne "aarch64" ]]; then + infecho "Installing qemu in rootfs..." + cp /usr/bin/qemu-aarch64-static rootfs/usr/bin + fi + cp phone-scripts/* rootfs/root infecho "Mounting your /dev into the rootfs..." infecho "This is neccesary for dnf to work, because reasons." mount --bind /dev rootfs/dev - + infecho "Copy resolv.conf /etc/tmp-resolv.conf" cp /etc/resolv.conf rootfs/etc/tmp-resolv.conf - infecho "Chrooting with qemu into rootfs..." - chroot rootfs qemu-aarch64-static /bin/bash /root/all.sh + if [[ $HOSTARCH -ne "aarch64" ]]; then + infecho "Chrooting with qemu into rootfs..." + chroot rootfs qemu-aarch64-static /bin/bash /root/all.sh + + infecho "KILLING ALL QEMU PROCESSES, MAKE SURE YOU HAVE NO MORE RUNNING!" + killall -9 /usr/bin/qemu-aarch64-static + else + infecho "Chrooting into rootfs..." + chroot rootfs /bin/bash /root/all.sh + fi - infecho "KILLING ALL QEMU PROCESSES, MAKE SURE YOU HAVE NO MORE RUNNING!" - killall -9 /usr/bin/qemu-aarch64-static - infecho "Unmounting your /dev from the rootfs..." sleep 3 umount rootfs/dev