From 3d7a0c5c3951d2c3d41a543cedb1234dc3cbcd1a Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Wed, 2 Aug 2017 15:44:57 +0300 Subject: [PATCH] build-vm, tar2fs: unify kver handling No need to deduce kernel version again, just save it in a temporary file. The main reason to change what worked is that e2k kernel-image package has Linux bits named as image-$kver and not vmlinuz-$kver; the guessing logic taking all of this into account resulted in non-aesthetic patch. NB: there's a duplicating script within kernel feature; it wasn't easy to avoid this and it might differ when handling multiple kernels, I didn't think much about this now as vm images tend to ship with the sole one. --- bin/tar2fs | 10 ++++++++-- features.in/build-vm/image-scripts.d/07-kernel | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/tar2fs b/bin/tar2fs index 9246a3dd..f8764072 100755 --- a/bin/tar2fs +++ b/bin/tar2fs @@ -205,8 +205,14 @@ fi echo "MODULES_PRELOAD += $INITRD_MODULES $ROOTFSTYPE" >> "$ROOTFS/etc/initrd.mk" echo "FEATURES += qemu" >> "$ROOTFS/etc/initrd.mk" -KERNEL="$(readlink $ROOTFS/boot/vmlinuz | sed 's,vmlinuz-,,')" -chroot "$ROOTFS" make-initrd -k "$KERNEL" +# NB: don't stick BOOTFS here, it has slightly different semantics +pushd $ROOTFS/boot +if [ -s .origver ]; then + read KVER < .origver +fi +[ -n "$KVER" ] || fatal "unable to deduce kernel version" +chroot "$ROOTFS" make-initrd -k "$KVER" +rm -f .origver # ...target device too sed -i "s,$LOOPROOT,$ROOTDEV," "$ROOTFS/etc/fstab" diff --git a/features.in/build-vm/image-scripts.d/07-kernel b/features.in/build-vm/image-scripts.d/07-kernel index e78c52fa..4392c0fc 100755 --- a/features.in/build-vm/image-scripts.d/07-kernel +++ b/features.in/build-vm/image-scripts.d/07-kernel @@ -9,5 +9,12 @@ kver="$(rpm -qa 'kernel-image*' \ | cut -f 2 -d ' ' \ | sed 's/kernel-image-//')" -ln -s vmlinuz-$kver /boot/vmlinuz -ln -s initrd-$kver.img /boot/initrd.img +[ -n "$kver" ] || { echo "** unable to deduce kernel version" >&2; exit 1; } + +cd /boot +echo "$kver" > .origver # for tar2fs + +# NB: e2k kernel builds "image" instead of "vmlinuz" +[ -f vmlinuz-$kver ] && ln -s vmlinuz-$kver vmlinuz ||: +ln -s initrd-$kver.img initrd.img # missing at this stage +: