From 9133dcb37c8e6071873971c3d3bfb20ff50c5e9b Mon Sep 17 00:00:00 2001 From: oddlama Date: Tue, 21 Apr 2020 23:15:29 +0200 Subject: [PATCH] Fixed PTUUID ambiguity leading to blkid not showing results --- scripts/functions.sh | 9 +++++---- scripts/internal_config.sh | 2 ++ scripts/utils.sh | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 46620d7..97b9351 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -132,9 +132,9 @@ resolve_id_to_device() { local arg="${disk_id_to_resolvable[$id]#*:}" case "$type" in - 'partuuid') get_device_by_partuuid "$arg" ;; - 'ptuuid') get_device_by_ptuuid "$arg" ;; - 'uuid') get_device_by_uuid "$arg" ;; + 'partuuid') get_device_by_partuuid "$arg" ;; + 'ptuuid') get_device_by_ptuuid "$arg" ;; + 'uuid') get_device_by_uuid "$arg" ;; *) die "Cannot resolve '$type:$arg' to device (unkown type)" esac } @@ -161,6 +161,7 @@ disk_create_gpt() { fi local ptuuid="${DISK_ID_TO_UUID[$new_id]}" + DISK_PTUUID_TO_DEVICE[${ptuuid,,}]="$device" disk_id_to_resolvable[$new_id]="ptuuid:$ptuuid" einfo "Creating new gpt partition table ($new_id) on $device_desc" @@ -202,7 +203,7 @@ disk_create_partition() { einfo "Creating partition ($new_id) with type=$type, size=$size on $device" # shellcheck disable=SC2086 - sgdisk -n "0:0:$arg_size" -t "0:$type" -u 0:"$partuuid" $extra_args "$device" >/dev/null \ + sgdisk -n "0:0:$arg_size" -t "0:$type" -u "0:$partuuid" $extra_args "$device" >/dev/null \ || die "Could not create new gpt partition ($new_id) on '$device' ($id)" partprobe "$device" } diff --git a/scripts/internal_config.sh b/scripts/internal_config.sh index 39be579..0ba82b3 100644 --- a/scripts/internal_config.sh +++ b/scripts/internal_config.sh @@ -27,6 +27,8 @@ declare -A DISK_PARTUUID_TO_GPT_UUID declare -A DISK_ID_TO_UUID # An associative set to check for correct usage of size=remaining in gpt tables declare -A DISK_GPT_HAD_SIZE_REMAINING +# An associative from PTUUID to device +declare -A DISK_PTUUID_TO_DEVICE only_one_of() { local previous="" diff --git a/scripts/utils.sh b/scripts/utils.sh index ab723b9..6d98b1d 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -135,7 +135,7 @@ get_device_by_partuuid() { } get_device_by_ptuuid() { - get_device_by_blkid_field 'PTUUID' "$1" + echo -n "${DISK_PTUUID_TO_DEVICE[${1,,}]}" } get_device_by_uuid() {