Optimize some mounting functions to only setup some variables when needed

eg. when using auto partition no further setup is needed

Also added dialog to give feedback when a partition is selected automatically
This commit is contained in:
natemaia 2019-08-18 14:22:41 -07:00
parent b3d7803cf0
commit 77c66897f4

View File

@ -5,7 +5,7 @@
# Some ideas and code reworked from other resources # Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
VER="2.0.50" # installer version VER="2.0.51" # installer version
DIST="ArchLabs" # linux distributor DIST="ArchLabs" # linux distributor
MNT="/mnt" # install mountpoint MNT="/mnt" # install mountpoint
ANS="/tmp/ans" # dialog answer file ANS="/tmp/ans" # dialog answer file
@ -1064,9 +1064,9 @@ part_cryptlv()
part_countdec() part_countdec()
{ {
for i in "$@"; do for pt; do
if (( COUNT > 0 )); then if (( COUNT > 0 )); then
PARTS="$(sed "/${i//\//\\/}/d" <<< "$PARTS")" PARTS="$(sed "/${pt//\//\\/}/d" <<< "$PARTS")"
(( COUNT-- )) (( COUNT-- ))
fi fi
done done
@ -1199,22 +1199,26 @@ select_filesystem()
select_efi_partition() select_efi_partition()
{ {
local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small/big for boot
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_BOOT_PART ]]; then if [[ $AUTO_BOOT_PART ]]; then
msg "EFI Boot Partition" "\nUsing partition created during automatic format." 1
BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here
elif (( ptcount == 1 )); then
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
else else
dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small/big for boot
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if (( ptcount == 1 )); then
msg "EFI Boot Partition" "\nOnly one partition that meets size requirements available." 1
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
else
dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts
fi
fi fi
[[ $BOOT_PART ]] || return 1 [[ $BOOT_PART ]] || return 1
@ -1233,24 +1237,27 @@ select_efi_partition()
select_boot_partition() select_boot_partition()
{ {
local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small/big for boot
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_BOOT_PART && ! $LVM ]]; then if [[ $AUTO_BOOT_PART && ! $LVM ]]; then
msg "BIOS Boot Partition" "\nUsing partition created during automatic format." 1
BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here
elif [[ $LUKS && ! $LVM ]]; then
dlg BOOT_PART menu "Boot Partition" "$_biosluks" $pts
[[ $BOOT_PART ]] || return 1
else else
dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $pts local pts size dev isize bsize ptcount=0
[[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; }
# walk partition list and skip ones that are too small/big for boot
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $LUKS && ! $LVM ]]; then
dlg BOOT_PART menu "Boot Partition" "$_biosluks" $pts
[[ $BOOT_PART ]] || return 1
else
dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $pts
[[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; }
fi
fi fi
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
@ -1266,24 +1273,28 @@ select_boot_partition()
select_root_partition() select_root_partition()
{ {
local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small for / (root)
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [MK] || ($size_t == 'G' && $isize -lt 4) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then
ROOT_PART="$AUTO_ROOT_PART" ROOT_PART="$AUTO_ROOT_PART"
msg "Select Root Partition (/)" "\nUsing partition created during automatic format." 1
part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; } part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; }
return 0 # we're done here return 0 # we're done here
elif (( ptcount == 1 )); then # only one available device
ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")"
else else
dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small for / (root)
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [MK] || ($size_t == 'G' && $isize -lt 4) ]] || { pts+="$dev $size "; (( ptcount++ )); }
done <<< "$PARTS"
if (( ptcount == 1 )); then # only one available device
msg "Select Root Partition (/)" "\nOnly one partition that meets size requirements available." 1
ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")"
else
dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts
fi
fi fi
[[ $ROOT_PART ]] || return 1 [[ $ROOT_PART ]] || return 1
@ -1295,16 +1306,16 @@ select_root_partition()
select_extra_partitions() select_extra_partitions()
{ {
local part pts size dev isize bsize ptcount=0 local part size dev
# walk partition list and skip ones that are too small to be usable # walk partition list and skip ones that are too small to be usable
while read -r dev size; do while read -r dev size; do
[[ ${size: -1:1} =~ [KM] ]] || { pts+="$dev $size "; (( ptcount++ )); } [[ ${size: -1:1} =~ [KM] ]] && part_countdec "$dev"
done <<< "$PARTS" done <<< "$PARTS"
while (( ptcount > 0 )); do while (( COUNT > 0 )); do
part='' part=''
dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $pts || break dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break
if [[ $part == 'done' ]]; then if [[ $part == 'done' ]]; then
break break
elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then