diff --git a/archlabs-installer b/archlabs-installer index e729121..b2699ca 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,7 +5,7 @@ # Some ideas and code reworked from other resources # AIF, Calamares, and the Arch Wiki.. Credit where credit is due -VER=2.1.19 +VER=2.1.20 # default values { @@ -641,13 +641,9 @@ part_menu() part_show() { - local txt - if [[ $IGNORE_DEV ]]; then - txt="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/')" - else - txt="$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | awk '/disk|part|lvm|crypt|NAME/')" - fi - msg "Device Tree" "\n\n$txt\n\n" + msg "Device Tree" "\n\n$( + lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT | awk "!/${IGNORE_DEV:-NONEXX}/"' && /disk|part|lvm|crypt|NAME/' + )\n\n" } part_auto() @@ -696,35 +692,41 @@ part_auto() ############################################################################### # partition management functions -# these are helpers for use by other functions to do essential setup/teardown +# these are helpers used by other functions to do essential setup/teardown part_find() { + PARTS="" + COUNT=0 local regexp="$1" err='' - local pts dev size isize ptcount=0 + local s dev size isize - # string of partitions as /TYPE/PART SIZE.. eg. /dev/sda1 256G - if [[ $IGNORE_DEV ]]; then - PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$regexp/"' && !'"/$IGNORE_DEV/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2, $3}')" - else - PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$regexp/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')" - fi - - # ensure we have enough partitions for the system and action were trying to do - COUNT=$(wc -l <<< "$PARTS") - - while read -r dev size; do # walk partition list and skip ones that are too small + # string of partitions >= 80M as /TYPE/PART SIZE__FSTYPE + while read -r dev size; do [[ $dev && $size ]] || continue - size_t="${size: -1:1}" - isize=${size:0:-1} + s=${size%%__*} + size_t="${s: -1:1}" + isize=${s:0:-1} isize=${isize%.*} - [[ $size_t == 'K' || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); } - done <<< "$PARTS" + if ! [[ $size_t == 'K' || ($size_t == 'M' && $isize -lt 80) ]]; then + if [[ $PARTS ]]; then + PARTS+=$'\n'"$dev $size" + else + PARTS="$dev $size" + fi + (( COUNT++ )) + fi + done < <(lsblk -lno TYPE,NAME,SIZE,FSTYPE | + awk "/$regexp/"' && !'"/${IGNORE_DEV:-NONEXX}/"' { + sub(/^part/, "/dev/") + sub(/^lvm|^crypt/, "/dev/mapper/") + print $1$2, $3"__"$4 + }') case "$regexp" in - 'part|lvm|crypt') [[ $ptcount -lt 1 || ($SYS == 'UEFI' && $COUNT -lt 2) ]] && err="$_errpart" ;; - 'part|crypt') (( ptcount < 1 )) && err="$_lvmerr" ;; - 'part|lvm') (( ptcount < 2 )) && err="$_lukserr" ;; + 'part|lvm|crypt') [[ $COUNT -lt 1 || ($SYS == 'UEFI' && $COUNT -lt 2) ]] && err="$_errpart" ;; + 'part|crypt') (( COUNT < 1 )) && err="$_lvmerr" ;; + 'part|lvm') (( COUNT < 2 )) && err="$_lukserr" ;; esac if [[ $err ]]; then @@ -737,16 +739,18 @@ part_find() part_swap() { - if [[ $1 == "$MNT/swapfile" && $SWAP_S ]]; then - fallocate -l $SWAP_S "$1" 2> "$ERR" - errshow 0 "fallocate -l '$SWAP_S' '$1'" - chmod 600 "$1" 2> "$ERR" - errshow 0 "chmod 600 '$1'" + local swp="$1" + + if [[ $swp == "$MNT/swapfile" && $SWAP_S ]]; then + fallocate -l $SWAP_S "$swp" 2> "$ERR" + errshow 0 "fallocate -l '$SWAP_S' '$swp'" + chmod 600 "$swp" 2> "$ERR" + errshow 0 "chmod 600 '$swp'" fi - mkswap "$1" > /dev/null 2> "$ERR" - errshow 0 "mkswap '$1' > /dev/null" - swapon "$1" > /dev/null 2> "$ERR" - errshow 0 "swapon '$1' > /dev/null" + mkswap "$swp" > /dev/null 2> "$ERR" + errshow 0 "mkswap '$swp' > /dev/null" + swapon "$swp" > /dev/null 2> "$ERR" + errshow 0 "swapon '$swp' > /dev/null" return 0 } @@ -903,7 +907,7 @@ mount_menu() select_boot() { - local pts dev size isize ptcount=0 + local s pts dev size isize ptcount=0 if [[ -z $BOOT ]]; then if [[ $AUTO_BOOT && -z $LVM && -z $LUKS ]]; then @@ -913,40 +917,67 @@ select_boot() if (( COUNT )); then while read -r dev size; do # walk partition list and skip ones that are too small/big for boot - size_t="${size: -1:1}" - isize=${size:0:-1} + s=${size%%__*} + size_t="${s: -1:1}" + isize=${s:0:-1} isize=${isize%.*} - [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); } + if ! [[ $size_t == 'T' || ($size_t == 'G' && $isize -gt 2) ]]; then + pts+="$dev $size " + (( ptcount++ )) + fi done <<< "$PARTS" fi + local txt="\nNo partitions available that meet size requirements!!\n\nReturning to the main menu.\n" + case "$SYS" in UEFI) case "$ptcount" in - 0) msg "EFI Boot Partition" "\nNo partitions available that meet size requirements!!\n\nReturning to the main menu.\n" 2; return 1 ;; - 1) msg "EFI Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1; BOOT="$(awk 'NF > 0 {print $1}' <<< "$pts")" ;; - *) dlg BOOT menu "EFI Partition" "$_uefi" $pts ;; + 0) + msg "EFI Boot Partition" "$txt" 2 + return 1 + ;; + 1) + msg "EFI Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1 + BOOT="$(awk 'NF > 0 {print $1}' <<< "$pts")" + ;; + *) + dlg BOOT menu "EFI Partition" "$_uefi" $pts + ;; esac [[ $BOOT ]] || return 1 ;; BIOS) if [[ $LUKS && ! $LVM ]]; then case "$ptcount" in - 0) msg "Boot Partition" "\nLUKS without LVM requires a separate boot partition.\nNo partitions available that meet size requirements!!\n\nReturning to the main menu.\n" 2; return 1 ;; - 1) msg "Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1; BOOT="$(awk 'NF > 0 {print $1}' <<< "$pts")" ;; - *) dlg BOOT menu "Boot Partition" "$_biosluks" $pts ;; + 0) + txt="\nLUKS without LVM requires a separate boot partition.$txt" + msg "Boot Partition" "$txt" 2 + return 1 + ;; + 1) + msg "Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1 + BOOT="$(awk 'NF > 0 {print $1}' <<< "$pts")" + ;; + *) + dlg BOOT menu "Boot Partition" "$_biosluks" $pts + ;; esac [[ $BOOT ]] || return 1 else (( ptcount == 0 )) && return 0 dlg BOOT menu "Boot Partition" "$_bios" "skip" "no separate boot" $pts - [[ -z $BOOT || $BOOT == "skip" ]] && { BOOT=''; return 0; } + if [[ -z $BOOT || $BOOT == "skip" ]]; then + BOOT='' + return 0 + fi fi ;; esac fi - if ([[ $SYS == 'BIOS' ]] && grep -q 'ext[34]' <<< "$(fsck -N "$BOOT")") || ([[ $SYS == 'UEFI' ]] && grep -q 'fat' <<< "$(fsck -N "$BOOT")"); then + local fs="$(fsck -N "$BOOT")" + if ([[ $SYS == 'BIOS' ]] && grep -q 'ext[34]' <<< "$fs") || ([[ $SYS == 'UEFI' ]] && grep -q 'fat' <<< "$fs"); then yesno "Format Boot Partition" "\nIMPORTANT: The boot partition $BOOT $_format" "Format $BOOT" "Skip Formatting" 1 || return 0 fi @@ -968,19 +999,24 @@ select_root() else local pts dev size isize ptcount=0 - # walk partition list and skip ones that are too small for / (root) + # walk partition list and skip ones that are < 4G 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++ )); } + s=${size%%__*} + size_t="${s: -1:1}" + isize=${s:0:-1} + isize=${isize%.*} + if ! [[ $size_t == 'M' || ($size_t == 'G' && $isize -lt 4) ]]; then + pts+="$dev $size " + (( ptcount++ )) + fi done <<< "$PARTS" if (( ptcount == 1 )); then # only one available device msg "Root Partition (/)" "\nOnly one partition available that meets size requirements.\n" 2 ROOT="$(awk 'NF > 0 {print $1}' <<< "$pts")" else - local txt="\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 4G will not be shown here." + local txt="\nSelect the root (/) partition, this is where $DIST will be installed." + txt+="\n\nDevices smaller than 4G will not be shown here." dlg ROOT menu "Mount Root" "$txt" $pts fi fi @@ -998,17 +1034,20 @@ select_swap() local pts dev size isize if (( COUNT )) ; then - while read -r dev size; do # walk partition list and skip ones that are too small/big for swap - size_t="${size: -1:1}" - isize=${size:0:-1} + while read -r dev size; do # walk partition list and skip ones that are > 64G + s=${size%%__*} + size_t="${s: -1:1}" + isize=${s:0:-1} isize=${isize%.*} - [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 16) || ($size_t == 'M' && $isize -lt 100) ]] || pts+="$dev $size " + if ! [[ $size_t == 'T' || ($size_t == 'G' && $isize -gt 64) ]]; then + pts+="$dev $size " + fi done <<< "$PARTS" fi dlg SWAP menu "Swap Setup" "\nSelect whether to use a swapfile, swap partition, or none." \ - "none" "Don't allocate any swap space" \ - "swapfile" "Allocate $SYS_MEM at /swapfile" \ + "none" "No swap space" \ + "swapfile" "/swapfile (recommended -- editable size)" \ $pts if [[ -z $SWAP || $SWAP == "none" ]]; then @@ -1017,8 +1056,15 @@ select_swap() elif [[ $SWAP == "swapfile" ]]; then local i=0 until [[ ${SWAP_S:0:1} =~ [1-9] && ${SWAP_S: -1} =~ (M|G) ]]; do - (( i > 0 )) && msg "Swap Size Error" "\nSwap size must be 1(M|G) or greater, and can only contain whole numbers\n\nSize entered: $SWAP_S\n" 2 - dlg SWAP_S input "Swap Setup" "$_swapsize" "$SYS_MEM" || { SWAP=''; SWAP_S=''; return 1; } + if (( i > 0 )); then + msg "Swap Size Error" \ + "\nSwap size must be 1(M|G) or greater, and can only contain whole numbers\n\nSize entered: $SWAP_S\n" 2 + fi + if ! dlg SWAP_S input "Swap Setup" "$_swapsize" "$SYS_MEM"; then + SWAP='' + SWAP_S='' + return 1 + fi (( i++ )) done part_swap "$MNT/$SWAP" @@ -1035,10 +1081,11 @@ select_extra() { local part dev size - # walk partition list and skip ones that are too small to be usable + # walk partition list and skip ones that are < 1G if (( COUNT )); then while read -r dev size; do - [[ ${size: -1:1} =~ [KM] ]] && part_countdec "$dev" + s=${size%%__*} + [[ ${s: -1:1} == 'M' ]] && part_countdec "$dev" done <<< "$PARTS" fi @@ -1055,7 +1102,9 @@ select_extra() fi done - (( COUNT == 0 )) && msg "Mount Extra" "\nMounting Finished\n\nNo more partitions to mount, returning to main menu.\n" 2 + if (( COUNT == 0 )); then + msg "Mount Extra" "\nMounting Finished\n\nNo more partitions to mount, returning to main menu.\n" 2 + fi return 0 } @@ -1069,9 +1118,10 @@ select_mntopts() opts+="$i - off " done + yesno "$title" "\nPerform automatic mount with default options?\n" && return 1 until [[ $MNT_OPTS ]]; do dlg MNT_OPTS check "$title" "$_mount" $opts - [[ $MNT_OPTS ]] || return 1 + [[ $MNT_OPTS ]] || return 1 # no options is auto mount MNT_OPTS="${MNT_OPTS// /,}" yesno "$title" "\nConfirm the following options: $MNT_OPTS\n" || MNT_OPTS='' done @@ -1214,6 +1264,7 @@ install_base() chrun "locale-gen" chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZ /etc/localtime" + mkdir -pv "$MNT/etc/X11/xorg.conf.d" "$MNT/etc/default" cat > "$MNT/etc/X11/xorg.conf.d/00-keyboard.conf" <<- EOF # Use localectl(1) to instruct systemd-localed to update it. Section "InputClass" @@ -2047,7 +2098,6 @@ lvm_partitions() part_find 'part|crypt' || return 1 PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")" dlg LVM_PARTS check "$_lvmnew" "\nSelect the partition(s) to use for the physical volume (PV)." $PARTS - [[ $LVM_PARTS ]] } lvm_group_name() @@ -2564,11 +2614,7 @@ system_devices() { IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')" - if [[ $IGNORE_DEV ]]; then - SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')" - else - SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ {print "/dev/" $1 " " $2}')" - fi + SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/${IGNORE_DEV:-NONEXX}/"' {print "/dev/" $1 " " $2}')" if [[ -z $SYS_DEVS ]]; then msg "Device Error" "\nNo available devices...\n\nExiting..\n" 2 @@ -2643,7 +2689,7 @@ system_identify system_devices while :; do - dlg fontsize menu "Font Size" "\nSelect a font size from the list below." \ + dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \ 12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \ 20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \ 32 "setfont ter-i32n" || break