cip-dev.lists.cip-project.org archive mirror
 help / color / mirror / Atom feed
From: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>
To: cip-dev@lists.cip-project.org, jan.kiszka@siemens.com
Subject: [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists
Date: Wed, 30 Nov 2022 12:18:27 +0100	[thread overview]
Message-ID: <20221130111827.43184-1-Quirin.Gylstorff@siemens.com> (raw)

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
-- 
2.35.1



             reply	other threads:[~2022-11-30 11:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 11:18 Quirin Gylstorff [this message]
2022-12-08  9:30 ` [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221130111827.43184-1-Quirin.Gylstorff@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).