feat: reduce length of device names if under /dev/disk/by-id/

This commit is contained in:
oddlama 2022-05-13 22:55:15 +02:00
parent 50ec673974
commit 6b3f9c2a76
No known key found for this signature in database
GPG Key ID: 14EFE510775FE39A
2 changed files with 17 additions and 6 deletions

18
configure vendored
View File

@ -909,10 +909,12 @@ function PARTITIONING_BOOT_TYPE_menu() {
function PARTITIONING_BOOT_DEVICE_tag() { echo " ├ Boot Device"; }
function PARTITIONING_BOOT_DEVICE_label() {
local devshort=$PARTITIONING_BOOT_DEVICE
devshort=$(shorten_device "$devshort")
if [[ -e "$PARTITIONING_BOOT_DEVICE" ]]; then
echo " ├ ($PARTITIONING_BOOT_DEVICE)"
echo " ├ ($devshort)"
else
echo " ├ (\Z1$PARTITIONING_BOOT_DEVICE\Zn)"
echo " ├ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_BOOT_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
@ -957,10 +959,12 @@ function PARTITIONING_SWAP_menu() {
function PARTITIONING_SWAP_DEVICE_tag() { echo " │ └ Swap Device"; }
function PARTITIONING_SWAP_DEVICE_label() {
local dev=${PARTITIONING_SWAP_DEVICE:-/dev/sdB}
local devshort
devshort=$(shorten_device "$dev")
if [[ -e "$dev" ]]; then
echo " │ └ ($dev)"
echo " │ └ ($devshort)"
else
echo " │ └ (\Z1$dev\Zn)"
echo " │ └ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_SWAP_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && one_of "$PARTITIONING_SCHEME" "existing_partitions"; }
@ -1087,10 +1091,12 @@ function PARTITIONING_BTRFS_RAID_TYPE_menu() {
function PARTITIONING_DEVICE_tag() { echo " └ Device"; }
function PARTITIONING_DEVICE_label() {
local devshort=$PARTITIONING_DEVICE
devshort=$(shorten_device "$devshort")
if [[ -e "$PARTITIONING_DEVICE" ]]; then
echo " └ ($PARTITIONING_DEVICE)"
echo " └ ($devshort)"
else
echo " └ (\Z1$PARTITIONING_DEVICE\Zn)"
echo " └ (\Z1$devshort\Zn)"
fi
}
function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "existing_partitions"; }

View File

@ -239,6 +239,11 @@ function create_resolve_entry_device() {
DISK_ID_TO_RESOLVABLE[$id]="device:$dev"
}
# Returns the basename of the device, if its path starts with /dev/disk/by-id/
function shorten_dev() {
echo -n "${1#/dev/disk/by-id/}"
}
# Return matching device from /dev/disk/by-id/ if possible,
# otherwise return the parameter unchanged.
function canonicalize_device() {