Export some crucial variables

This commit is contained in:
oddlama 2020-04-23 21:06:22 +02:00
parent 38437daebd
commit 826f232807
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
3 changed files with 16 additions and 17 deletions

View File

@ -26,15 +26,15 @@ USED_LUKS=false
# An array of disk related actions to perform # An array of disk related actions to perform
DISK_ACTIONS=() DISK_ACTIONS=()
# An associative array from disk id to a resolvable string # An associative array from disk id to a resolvable string
declare -A DISK_ID_TO_RESOLVABLE declare -Ax DISK_ID_TO_RESOLVABLE
# An associative from uuid to device # An associative from uuid to device
declare -A DISK_UUID_TO_DEVICE declare -Ax DISK_UUID_TO_DEVICE
# An associative array from disk id to parent gpt disk id (only for partitions) # An associative array from disk id to parent gpt disk id (only for partitions)
declare -A DISK_ID_PART_TO_GPT_ID declare -Ax DISK_ID_PART_TO_GPT_ID
# An associative array to check for existing ids (maps to uuids) # An associative array to check for existing ids (maps to uuids)
declare -A DISK_ID_TO_UUID declare -Ax DISK_ID_TO_UUID
# An associative set to check for correct usage of size=remaining in gpt tables # An associative set to check for correct usage of size=remaining in gpt tables
declare -A DISK_GPT_HAD_SIZE_REMAINING declare -Ax DISK_GPT_HAD_SIZE_REMAINING
only_one_of() { only_one_of() {
local previous="" local previous=""

View File

@ -119,12 +119,12 @@ install_kernel_bios() {
# Install syslinux MBR record # Install syslinux MBR record
einfo "Copying syslinux MBR record" einfo "Copying syslinux MBR record"
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
local gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_BIOS]}")" local gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_BIOS]}")"
try dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of="$gptdev" try dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of="$gptdev"
# Install syslinux # Install syslinux
einfo "Installing syslinux" einfo "Installing syslinux"
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
syslinux --install "$biosdev" syslinux --install "$biosdev"
} }

View File

@ -138,12 +138,11 @@ get_device_by_uuid() {
get_device_by_blkid_field 'UUID' "$1" get_device_by_blkid_field 'UUID' "$1"
} }
get_device_by_ptuuid() { get_device_by_stored_uuid() {
echo -n "${DISK_UUID_TO_DEVICE[${1,,}]}" local key="${1,,}"
} [[ -v "DISK_UUID_TO_DEVICE[$key]" ]] \
|| die "Could not resolve uuid $key to device"
get_device_by_mdadm_uuid() { echo -n "${DISK_UUID_TO_DEVICE[$key]}"
echo -n "${DISK_UUID_TO_DEVICE[${1,,}]}"
} }
get_device_by_luks_uuid() { get_device_by_luks_uuid() {
@ -203,11 +202,11 @@ resolve_device_by_id() {
local arg="${DISK_ID_TO_RESOLVABLE[$id]#*:}" local arg="${DISK_ID_TO_RESOLVABLE[$id]#*:}"
case "$type" in case "$type" in
'partuuid') get_device_by_partuuid "$arg" ;; 'partuuid') get_device_by_partuuid "$arg" ;;
'ptuuid') get_device_by_ptuuid "$arg" ;; 'ptuuid') get_device_by_ptuuid "$arg" ;;
'uuid') get_device_by_uuid "$arg" ;; 'uuid') get_device_by_uuid "$arg" ;;
'mdadm') get_device_by_mdadm_uuid "$arg" ;; 'mdadm') get_device_by_stored_uuid "$arg" ;;
'luks') get_device_by_luks_uuid "$arg" ;; 'luks') get_device_by_stored_uuid "$arg" ;;
*) die "Cannot resolve '$type:$arg' to device (unknown type)" *) die "Cannot resolve '$type:$arg' to device (unknown type)"
esac esac
} }