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>
This commit is contained in:
Xin Zhang 2023-10-19 19:58:39 +08:00 committed by acrnsi-robot
parent fbe30d4001
commit d0fed9901d
2 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ GENERATED_PARAMS=(cpu_perf_policy=Performance)
#ACRN parameters End #ACRN parameters End
ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin" ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin"
type=$(lsblk -l |awk '$NF == "/" {print $1}') type=$(findmnt / |awk '$1 == "/" {print $2}')
pattern='^/dev/.* UUID="([^"]+)".* PARTUUID="([^"]+)"' pattern='^/dev/.* UUID="([^"]+)".* PARTUUID="([^"]+)"'
while IFS= read -r line; do while IFS= read -r line; do
@ -29,7 +29,7 @@ while IFS= read -r line; do
uuid="${BASH_REMATCH[1]}" uuid="${BASH_REMATCH[1]}"
partuuid="${BASH_REMATCH[2]}" partuuid="${BASH_REMATCH[2]}"
fi fi
done < <(blkid |grep ext4 |grep ${type}) done < <(blkid |grep ${type})
filename="/etc/grub.d/40_custom" filename="/etc/grub.d/40_custom"

View File

@ -3,7 +3,7 @@
# postinst script for acrn kernel # postinst script for acrn kernel
filename="/etc/grub.d/40_custom" filename="/etc/grub.d/40_custom"
menu=$(grep ACRN_deb_multiboot2 ${filename}) || true menu=$(grep ACRN_deb_multiboot2 ${filename}) || true
type=$(lsblk -l |awk '$NF == "/" {print $1}') type=$(findmnt / |awk '$1 == "/" {print $2}')
str=$(blkid |grep ${type}) str=$(blkid |grep ${type})
uuid=$(echo $str |cut -d " " -f 2|cut -d "=" -f 2) uuid=$(echo $str |cut -d " " -f 2|cut -d "=" -f 2)
str=$(blkid |grep ${type}) str=$(blkid |grep ${type})