From 57d9815a4882677ebdffec0d3d568e00addc34a8 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 11 Jan 2020 13:49:16 -0500 Subject: [PATCH 1/2] Drop copying qemu binaries and ensure qemu-user is configured on host Since Mageia 6, it has not been necessary to copy the qemu binaries and the binfmt files into the chroot to run ARM binaries inside a chroot. This change finally stops doing that. In order to make sure this works properly, we ensure that systemd-binfmt is restarted to apply binfmt changes on the system. This ensures that the host qemu-user-static is configured to execute binaries, even in chroots. --- create_arm_image.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/create_arm_image.sh b/create_arm_image.sh index 34549a1..b1d6324 100755 --- a/create_arm_image.sh +++ b/create_arm_image.sh @@ -111,6 +111,13 @@ function createchroot() error "line ${LINENO} can't start qemu-user-static : exiting" exit ${ERR_1} fi + else + title "Restarting systemd-binfmt.service" + /bin/systemctl restart systemd-binfmt.service + if [ ${?} -ne 0 ]; then + error "line ${LINENO} can't start qemu-user-static : exiting" + exit ${ERR_1} + fi fi return 0 } @@ -263,20 +270,6 @@ function preparechroot() { title "Preparing chrooting in ${BUILD_PATH}" - #Copying qemu - - /bin/cp /bin/qemu-arm-static "${BUILD_PATH}/usr/bin/" - if [ ${?} -ne 0 ]; then - error "line ${LINENO} can't copy /bin/qemu-user-static to ${BUILD_PATH}/usr/bin/ : exiting" - exit ${ERR_1} - fi - /bin/cp /usr/lib/binfmt.d/qemu-arm-static.conf "${BUILD_PATH}/usr/lib/binfmt.d" - if [ ${?} -ne 0 ]; then - error "line ${LINENO} can't copy /usr/lib/binfmt.d/qemu-arm-static.conf to ${BUILD_PATH}/usr/lib/binfmt.d : exiting" - exit ${ERR_1} - fi - - info "making /etc/hostname" echo "${HOSTNAME}" > "${BUILD_PATH}/etc/hostname" From 5b42a8d15b058f95e709b3d2c5564bfcfeed81b7 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sun, 12 Jan 2020 04:05:01 -0500 Subject: [PATCH 2/2] Work around issues with filesystem package by preparing chroot skeleton There are issues with the filesystem package in Mageia that lead to unpredictable setup for the filesystem hierarchy when setting up chroots. In order to work around this problem, let's create some of the basic paths ourselves while we wait for the issue to be fixed. Reference: https://bugs.mageia.org/show_bug.cgi?id=26044 --- create_arm_image.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/create_arm_image.sh b/create_arm_image.sh index b1d6324..b07e3ea 100755 --- a/create_arm_image.sh +++ b/create_arm_image.sh @@ -234,6 +234,19 @@ function installbasesystem() info "Build path exists" fi + # Workaround mga#26044. + info "Preparing root filesystem tree" + mkdir -p "${BUILD_PATH}/usr/bin" + mkdir -p "${BUILD_PATH}/usr/sbin" + mkdir -p "${BUILD_PATH}/usr/lib" + ln -sr "${BUILD_PATH}/usr/bin" "${BUILD_PATH}/bin" + ln -sr "${BUILD_PATH}/usr/sbin" "${BUILD_PATH}/sbin" + ln -sr "${BUILD_PATH}/usr/lib" "${BUILD_PATH}/lib" + if [ "${ARM_VERSION}" = "aarch64" ]; then + mkdir -p "${BUILD_PATH}/usr/lib64" + ln -sr "${BUILD_PATH}/usr/lib64" "${BUILD_PATH}/lib64" + fi + title "installing basesystem" /usr/bin/dnf --installroot="${BUILD_PATH}" ${DNF_MIRROROPTS} --assumeyes install shadow-utils basesystem-minimal if [ ${?} -ne 0 ]; then