Fix dev search on validate-platform-backup script

During testing, validate-platform-backup.sh could not find the
parent path of the nvme0n1p4 partiton, and resulted in failure
to validate.

This fix adds an additional step to extract the parent path (disk)
of the "nvme0n1p4" partition (or any similar partition format).
This is done by removing the  trailing "p" and the number at the end
(partition number) using sed. Then, we check if the parent path is
not empty and set the device_path variable to the parent path
("/dev/nvme0n1" in this case) if the condition is met.

Test Plan
PASS: Fresh Install and Bootstrap (AIO-SX)
PASS: validate-platform-backup.sh returns SUCCESS

Closes-bug: 2028943

Change-Id: I313bcca2720512fd1457b6c622bb6a2ddf2c8a68
Signed-off-by: Matheus Guilhermino <matheus.machadoguilhermino@windriver.com>
This commit is contained in:
Matheus Guilhermino 2023-07-28 09:39:16 -03:00
parent 3aaecd747d
commit 9d9e07712c
1 changed files with 7 additions and 4 deletions

View File

@ -8,16 +8,19 @@
NAME=$(basename $0)
rootfs_part=$(findmnt -n -o SOURCE / | sed 's/\[[^]]*\]//g')
device_path=$(lsblk -pno pkname ${rootfs_part})
if [ -z $device_path ] ; then
if [ -z "$device_path" ] ; then
base_device=$(dmsetup deps -o devname ${rootfs_part%} | grep -wo "(.*.)")
device_path=$(find /dev -name "${base_device:1:-1}")
check_parent_path_1=$(lsblk -pno pkname ${device_path} | head -n 1)
if [ ! -z $check_parent_path_1 ] ; then
if [ -n "$check_parent_path_1" ] ; then
device_path=${check_parent_path_1}
fi
check_parent_path_2=$(dmsetup deps -o devname ${device_path} | grep -wo "(.*.)")
if [ ! -z $check_parent_path_2 ] ; then
device_path=$(find /dev -name "${check_parent_path_2:1:-1}")
if [ -n "$check_parent_path_2" ] ; then
parent_path=$(find /dev -name "${check_parent_path_2:1:-1}" | sed 's/p[0-9]$//')
if [ -n "$parent_path" ] ; then
device_path="$parent_path"
fi
fi
fi