From d2b5b879220c975430bc423993dfdf819515d372 Mon Sep 17 00:00:00 2001 From: Eric Chanudet Date: Mon, 2 Jul 2018 18:37:56 -0400 Subject: [PATCH] installer: Amend disk/partition for efibootmgr Add two functions to the common script library to parse devnodes disk and partition and use them with efibootmgr when writting efi boot entries for a new OpenXT installation. Signed-off-by: Eric Chanudet OXT-1372 --- common/stages/Functions/library | 27 +++++++++++++++++++++++++++ part2/stages/Functions/install-main | 5 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/common/stages/Functions/library b/common/stages/Functions/library index 5a1f837..4953a0f 100644 --- a/common/stages/Functions/library +++ b/common/stages/Functions/library @@ -396,3 +396,30 @@ reread_partition_table() udevadm settle >&2 } +#----------------------------------------------------------- +# Usage: get_devnode_disk /dev/(sd[a-z]\+[0-9]\+|/dev/nvme[0-9]\+n[0-9]\+p[0-9]\+) +# Prints the disk component of the argument devnode on stdout. +get_devnode_disk() { + local devnode="$1" + local disk + + case "${devnode}" in + "/dev/nvme"*) disk="${devnode%p*}" ;; + "/dev/sd"*) disk="${devnode%%[!/a-z]*}" ;; + esac + echo "${disk}" +} + +#----------------------------------------------------------- +# Usage: get_devnode_partition /dev/(sd[a-z]\+[0-9]\+|/dev/nvme[0-9]\+n[0-9]\+p[0-9]\+) +# Prints the partition component of the argument devnode on stdout. +get_devnode_partition() { + local devnode="$1" + local part + + case "${devnode}" in + "/dev/nvme"*"p"*) part="${devnode##*nvme*n*p}" ;; + "/dev/sd"*) part="${devnode##*/sd*[!0-9]}" ;; + esac + echo "${part}" +} diff --git a/part2/stages/Functions/install-main b/part2/stages/Functions/install-main index 95864c7..4d7c7a3 100644 --- a/part2/stages/Functions/install-main +++ b/part2/stages/Functions/install-main @@ -555,8 +555,9 @@ remove_efi_boot_entries() create_efi_boot_entries() { - local DISK_DEV="$( echo ${1} | sed -e 's/[[:digit:]]*$//' )" - local PART="${1#$DISK_DEV}" + local DEVNODE="$1" + local DISK_DEV="$(get_devnode_disk ${DEVNODE})" + local PART="$(get_devnode_partition ${DEVNODE})" remove_efi_boot_entries