From be75d3c3d24452b05a4ff6cbdfb58092a94a8d32 Mon Sep 17 00:00:00 2001 From: Dmitriy Terekhin Date: Wed, 9 Jan 2019 15:12:47 +0400 Subject: [PATCH] need /.host/qemu* in the chroot if qemu is used The original commit broke system tar2fs use by accidentally moving TOPDIR definition into a separate shell execution; thanks iv@ for spotting and fixing it promptly. Co-authored-by: Ivan A. Melnikov" --- bin/tar2fs | 13 +++++++++++++ features.in/build-vm/lib/90-build-vm.mk | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/tar2fs b/bin/tar2fs index 80690c5c..90607562 100755 --- a/bin/tar2fs +++ b/bin/tar2fs @@ -218,6 +218,16 @@ if [ -n "$BOOTPART" ]; then echo "$BOOTDEV /boot $BOOTFSTYPE defaults 1 2" >> "$ROOTFS/etc/fstab" fi +# Query ARCH in chroot and redefine arch-dependent variable +ARCH="$(chroot "$ROOTFS" rpm --eval '%_host_cpu')" + +if [[ $ARCH = *86* ]] + then # NB: different storage modules might be needed for non-kvm + INITRD_MODULES="sd_mod ata_piix ahci virtio-scsi virtio-blk" +else + INITRD_MODULES= +fi + echo "MODULES_PRELOAD += $INITRD_MODULES $ROOTFSTYPE" >> "$ROOTFS/etc/initrd.mk" case "$ARCH" in @@ -315,3 +325,6 @@ fi if [ -n "$SUDO_USER" ]; then chown "$SUDO_USER:$(id -g "$SUDO_USER")" "$IMG" "$ROOTFS" "$WORKDIR" ||: fi +# maybe qemu interpreter was copied to chroot; +# this is no longer necessary, remove +rm -rf "$ROOTFS"/.host ||: diff --git a/features.in/build-vm/lib/90-build-vm.mk b/features.in/build-vm/lib/90-build-vm.mk index ef28d70f..9b9396b7 100644 --- a/features.in/build-vm/lib/90-build-vm.mk +++ b/features.in/build-vm/lib/90-build-vm.mk @@ -23,7 +23,11 @@ check-sudo: fi prepare-image: check-sudo - @if [ -x /usr/share/mkimage-profiles/bin/tar2fs ]; then \ + @# need to copy $(BUILDDIR)/.work/chroot/.host/qemu* into chroot + @#if qemu is used + @(cd "$(BUILDDIR)/.work/chroot/"; \ + tar -rf "$(VM_TARBALL)" ./.host/qemu*) ||:; \ + if [ -x /usr/share/mkimage-profiles/bin/tar2fs ]; then \ TOPDIR=/usr/share/mkimage-profiles; \ fi; \ if ! sudo $$TOPDIR/bin/tar2fs \