acrn-hypervisor/misc/packaging/acrn-kernel.postinst
Xin Zhang d0fed9901d Fix Debian packaging postinst partition finding
If the root partition is bind mounted with / and another, the current
postinst script (using command lsblk) will fail to find the partition:
$type will be "/" only and cause the following command may find the
wrong partition.

Ubuntu 22.04 desktop with firefox snap by default:
```
> lsblk
nvme0n1      259:19   0 931.5G  0 disk
├─nvme0n1p1  259:20   0   243M  0 part /boot/efi
├─nvme0n1p2  259:21   0 927.5G  0 part /var/snap/firefox/common/host-hunspell
│                                      /
```

And current command forces the root partition to be ext4.

This patch fixes the two issues.

Tracked-On: #8532

Signed-off-by: Xin Zhang <xin.x.zhang@intel.com>
2024-06-26 13:56:01 +08:00

35 lines
921 B
Bash

#!/bin/bash
#* Copyright (c) 2020-2022 Intel Corporation.
# postinst script for acrn kernel
filename="/etc/grub.d/40_custom"
menu=$(grep ACRN_deb_multiboot2 ${filename}) || true
type=$(findmnt / |awk '$1 == "/" {print $2}')
str=$(blkid |grep ${type})
uuid=$(echo $str |cut -d " " -f 2|cut -d "=" -f 2)
str=$(blkid |grep ${type})
partuuid=$(echo ${str##*PARTUUID=})
if [ -z "$menu" ]
then
cat>"${filename}"<<EOF
#!/bin/sh
exec tail -n +3 \$0
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
load_video
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set $uuid
multiboot2 /boot/acrn.bin root=PARTUUID=$partuuid
}
EOF
fi
sed -i '/module/d' ${filename} || true
bzImage=$(cat /boot/version.txt)
sed -i '/multiboot2 \/boot/a\module2 /boot/'${bzImage}' Linux_bzImage' ${filename}
sync
update-grub