[isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists


Quirin Gylstorff
 

From: Quirin Gylstorff <quirin.gylstorff@...>

If a valid root file system does not contain /etc/os-release the
script aborts before checking other root file systems. This occurs
for example if the boot occurs from a USB stick and a ext4 root
file system exists on internal memory.

Also ensure that IMAGE_UUID and TARGET_IMAGE_UUID are not empty
before comparing to each other.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@...>
---
.../initramfs-abrootfs-hook/files/abrootfs.script | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
index 23bbfe7..848e829 100644
--- a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
+++ b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
@@ -35,9 +35,12 @@ find_root_via_image_uuid()
for part in $partitions; do
if [ "$(blkid -p "${part}" --match-types novfat -s USAGE -o value)" = "filesystem" ]; then
mount -o ro -t "$(get_fstype "${part}")" "${part}" "${rootmnt}"
- . "${rootmnt}/etc/os-release"
+ if [ -e "${rootmnt}/etc/os-release" ]; then
+ . "${rootmnt}/etc/os-release"
+ fi
umount "${rootmnt}"
- if [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
+ if [ -n "${IMAGE_UUID}" ] && [ -n "${TARGET_IMAGE_UUID}" ] &&
+ [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
found_root="${part}"
break
fi
--
2.35.1

Join {cip-dev@lists.cip-project.org to automatically receive all group messages.