Skip to content

Commit

Permalink
Merge pull request #1624 from kacf/4.0.x
Browse files Browse the repository at this point in the history
fix: Resolve PARTUUID device paths in rootfs-image
  • Loading branch information
kacf committed May 14, 2024
2 parents a2cb380 + 4e02056 commit 9fa30d3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions support/modules/rootfs-image
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ else
SETENV=fw_setenv
fi

resolve_rootfs() {
case "$1" in
/dev/root|/dev/disk/by-partlabel/*|/dev/disk/by-partuuid/*)
# This is a symlink that points to the regular device
# (e.g. /dev/disk/by-partuuid/b3c4f349-1180-45e1-9a3d-0a6697f4960e --> /dev/sda2)
echo "$(readlink -f $1)"
;;

*)
# Keep any other path as-is
# (cf. https://github.com/mendersoftware/mender/pull/1613#discussion_r1584353642 for the reasoning)
echo "$1"
;;
esac
}

parse_conf_file() {
MENDER_ROOTFS_PART_A=""
MENDER_ROOTFS_PART_B=""
Expand Down Expand Up @@ -63,6 +79,11 @@ parse_conf_file() {
MENDER_ROOTFS_PART_A="$(echo $MENDER_ROOTFS_PART_A | sed -e 's,^ubi,/dev/ubi,')"
MENDER_ROOTFS_PART_B="$(echo $MENDER_ROOTFS_PART_B | sed -e 's,^ubi,/dev/ubi,')"

# Resolve paths if required.
MENDER_ROOTFS_PART_A="$(resolve_rootfs $MENDER_ROOTFS_PART_A)"
MENDER_ROOTFS_PART_B="$(resolve_rootfs $MENDER_ROOTFS_PART_B)"

# Extract the partition number from the regular device path (e.g. /dev/sda2 --> 2).
MENDER_ROOTFS_PART_A_NUMBER="$(echo "$MENDER_ROOTFS_PART_A" | grep -Eo '[0-9]+$' || true)"
MENDER_ROOTFS_PART_B_NUMBER="$(echo "$MENDER_ROOTFS_PART_B" | grep -Eo '[0-9]+$' || true)"

Expand Down

0 comments on commit 9fa30d3

Please sign in to comment.