From 27eb375570164189898c2fb043fbc7cf6ca68de2 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 18 Aug 2019 13:37:49 -0700 Subject: [PATCH] Remove partitions too small/big for their use during mounting menus --- archlabs-installer | 92 +++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 30 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 358e420..05e1775 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,12 +5,11 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due -VER="2.0.49" # installer version +VER="2.0.50" # installer version DIST="ArchLabs" # linux distributor MNT="/mnt" # install mountpoint ANS="/tmp/ans" # dialog answer file - # ------------------------------------------------------ # # When manually mounting your partitions, you need # to set these values to avoid using the mount menu. @@ -176,7 +175,7 @@ declare -A WM_EXT=( # files that can be edited after install is complete { declare -A EDIT_FILES=( -[login]='' # populated once we know the new username and shell +[login]='' # login is populated once we know the username and shell [fstab]='/etc/fstab' [sudoers]='/etc/sudoers' [crypttab]='/etc/crypttab' @@ -189,7 +188,7 @@ declare -A EDIT_FILES=( [keyboard]='/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard' ) # } -# mkfs command for formatting each offered filesystem { +# mkfs command for filesystem formatting { declare -A FS_CMDS=( [f2fs]='mkfs.f2fs' [jfs]='mkfs.jfs -q' @@ -203,7 +202,7 @@ declare -A FS_CMDS=( [reiserfs]='mkfs.reiserfs -q' ) # } -# mount options for each offered filesystem (if any) { +# mount options for each filesystem (if any) { declare -A FS_OPTS=( [vfat]='' # NA [ntfs]='' # NA @@ -724,7 +723,7 @@ part_menu() part_device || return 1 device="$DEVICE" - while true; do + while :; do choice="" if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then dlg choice menu "Edit Partitions" "$_part" \ @@ -1200,13 +1199,22 @@ select_filesystem() select_efi_partition() { - if (( COUNT == 1 )); then - BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")" - elif [[ $AUTO_BOOT_PART ]]; then - BOOT_PART="$AUTO_BOOT_PART" - return 0 # were done here + 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+=$'\n'"$dev $size"; (( ptcount++ )); } + done <<< "$PARTS" + + if [[ $AUTO_BOOT_PART ]]; then + BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here + elif (( ptcount == 1 )); then + BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")" else - dlg BOOT_PART menu "EFI Partition" "$_uefi" $PARTS + dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts fi [[ $BOOT_PART ]] || return 1 @@ -1225,13 +1233,23 @@ select_efi_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+=$'\n'"$dev $size"; (( ptcount++ )); } + done <<< "$PARTS" + if [[ $AUTO_BOOT_PART && ! $LVM ]]; then BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here elif [[ $LUKS && ! $LVM ]]; then - dlg BOOT_PART menu "Boot Partition" "$_biosluks" $PARTS + 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" $PARTS + 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 @@ -1248,12 +1266,24 @@ select_boot_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+=$'\n'"$dev $size"; (( ptcount++ )); } + done <<< "$PARTS" + if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then ROOT_PART="$AUTO_ROOT_PART" - elif (( COUNT == 1 )); then - ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$PARTS")" + part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; } + return 0 # we're done here + elif (( ptcount == 1 )); then # only one available device + 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." $PARTS + 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 [[ $ROOT_PART ]] || return 1 @@ -1265,10 +1295,16 @@ select_root_partition() select_extra_partitions() { - local part - while (( COUNT > 0 )); do + local part pts size dev isize bsize ptcount=0 + + # walk partition list and skip ones that are too small to be usable + while read -r dev size; do + [[ ${size: -1:1} =~ [KM] ]] || { pts+=$'\n'"$dev $size"; (( ptcount++ )); } + done <<< "$PARTS" + + while (( ptcount > 0 )); do part='' - dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break + dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $pts || break if [[ $part == 'done' ]]; then break elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then @@ -1301,7 +1337,7 @@ install_main() chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" sleep 1 - while true; do + while :; do dlg choice menu "Finalization" "$_edit" \ finished "exit the installer and reboot" \ keyboard "${EDIT_FILES[keyboard]}" \ @@ -1987,7 +2023,7 @@ get_lv_size() { local txt="${VGROUP}: ${SIZE}$SIZE_UNIT (${VGROUP_MB}MB remaining).$_lvmlvsize" - while true; do + while :; do ERR_SIZE=0 dlg VOLUME_SIZE input "$_lvmnew (LV:$VOL_COUNT)" "$txt" '' if [[ -z $VOLUME_SIZE ]]; then @@ -2612,16 +2648,12 @@ msg "Welcome to the $DIST Installer" "\nThis will help you get $DIST setup on yo select_keymap || { clear; die 0; } -if lspci -vnn -d 14e4: | grep -q 'BCM4352'; then - load_bcm -fi +# try to fix problematic broadcom wireless chipset before network check +lspci -vnn -d 14e4: | grep -q 'BCM4352' && load_bcm -if ! net_connect; then - msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2 - die 1 -fi +net_connect || { msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2; die 1; } -while true; do +while :; do select_main done