Message ID | 20221130111827.43184-1-Quirin.Gylstorff@siemens.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [isar-cip-core] initramfs-abrootfs: check if /etc/os-release exists | expand |
On 30.11.22 12:18, Quirin Gylstorff wrote: > From: Quirin Gylstorff <quirin.gylstorff@siemens.com> > > 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@siemens.com> > --- > .../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 Thanks, applied. Jan
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