Update filesystem selection to use looping instead of recursion

This commit is contained in:
natemaia 2019-01-19 16:04:57 -08:00
parent 1e6f7a1438
commit 1e93f2b6c5
2 changed files with 173 additions and 142 deletions

View File

@ -139,14 +139,14 @@ _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?
# File System # File System
_FSTitle="Choose Filesystem" _FSTitle="Choose Filesystem"
_SelRootBody="\nSelect the system root (/) partition.\n\nThis is where $DIST will be installed." _SelRootBody="\nSelect the system root (/) partition.\n\nThis is where $DIST will be installed."
_SelBiosBody="\nDo you want to use a separate boot partition? (required for LUKS)\n\nThis partition is where the bootloader will be installed.\n" _SelBiosBody="\nSelect the boot partition, this is only required for LUKS."
_SelSwpNone="None" _SelSwpNone="None"
_SelSwpFile="Swapfile" _SelSwpFile="Swapfile"
_SelSwpSetup="Swap Setup" _SelSwpSetup="Swap Setup"
_SelSwpBody="\nSelect whether to use a swap partition, swapfile, or none." _SelSwpBody="\nSelect whether to use a swap partition, swapfile, or none."
_SelSwpErr="Swap Setup Error: Must be 1(M|G) or greater, and can only contain whole numbers\n\nSize Entered:" _SelSwpErr="Swap Setup Error: Must be 1(M|G) or greater, and can only contain whole numbers\n\nSize Entered:"
_SelSwpSize="\n\n\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\neg. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example the size has been filled in to the size of your system memory (RAM).\n\nMust be greater than 1, end in either M or G, and contain only whole numbers." _SelSwpSize="\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\neg. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example it is filled in to match the size of your system memory (RAM).\n\nMust be greater than 1, contain only whole numbers, and end with either M or G."
_SelUefiBody="\nSelect the system EFI boot partition.\n\nThis is a required partition for booting UEFI systems. It's usually the first partition on the drive, less than 512M, and will be formatted as vfat/fat32 if not already." _SelUefiBody="\nSelect the system EFI boot partition.\n\nThis is a required partition for booting UEFI systems. It's usually the first partition on the drive, less than 512M, and will be formatted as vfat/fat32 if not already."
_FormUefiBody="\nIMPORTANT: The EFI partition" _FormUefiBody="\nIMPORTANT: The EFI partition"
@ -181,12 +181,12 @@ _LvmPvSelBody="Select the partition(s) to use for the physical volume (PV)."
_LvmPvConfBody1="\nConfirm creation of volume group:" _LvmPvConfBody1="\nConfirm creation of volume group:"
_LvmPvConfBody2="With the following partition(s):" _LvmPvConfBody2="With the following partition(s):"
_LvmPvActBody1="\nCreating and activating volume group:" _LvmPvActBody1="\nCreating and activating volume group:"
_LvmPvDoneBody1="\nVolume group:" _LvmPvDoneBody1="Volume group:"
_LvmPvDoneBody2="has been created" _LvmPvDoneBody2="has been created"
_LvmLvNumBody1="\nUse [Spacebar] to select the number of logical volumes (LVs) to create in:" _LvmLvNumBody1="\nUse [Spacebar] to select the number of logical volumes (LVs) to create in:"
_LvmLvNumBody2="\nThe last (or only) logical volume will automatically use all remaining space in the volume group." _LvmLvNumBody2="\nThe last (or only) logical volume will automatically use all remaining space in the volume group."
_LvmLvNameBody1="Enter the name of the logical volume (LV) to create.\n\nThis is like setting a name or label for a partition.\n" _LvmLvNameBody1="Enter the name of the logical volume (LV) to create.\n\nThis is like setting a name or label for a partition.\n"
_LvmLvNameBody2="\nNOTE: This logical volume will use up all remaining space in the volume group" _LvmLvNameBody2="\nNOTE: This LV will use up all remaining space in the volume group"
_LvmLvSizeBody1="remaining" _LvmLvSizeBody1="remaining"
_LvmLvSizeBody2="\n\nEnter the size of the logical volume (LV) in megabytes (M) or gigabytes (G). For example, 100M will create a 100 megabyte LV. 10G will create a 10 gigabyte LV.\n" _LvmLvSizeBody2="\n\nEnter the size of the logical volume (LV) in megabytes (M) or gigabytes (G). For example, 100M will create a 100 megabyte LV. 10G will create a 10 gigabyte LV.\n"
_LvmCompBody="\nDone! all logical volumes have been created for the volume group.\n\nDo you want to view the device tree for the new LVM scheme?\n" _LvmCompBody="\nDone! all logical volumes have been created for the volume group.\n\nDo you want to view the device tree for the new LVM scheme?\n"

View File

@ -8,7 +8,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="1.8.42" # version VER="1.8.44" # version
DIST="ArchLabs" # distributor DIST="ArchLabs" # distributor
MNT="/mnt" # install mountpoint MNT="/mnt" # install mountpoint
@ -20,8 +20,8 @@ ROOT_PART="" # root partition
BOOT_PART="" # boot partition BOOT_PART="" # boot partition
BOOT_DEVICE="" # device used for BIOS grub install BOOT_DEVICE="" # device used for BIOS grub install
BOOTLDR="" # bootloader selected BOOTLDR="" # bootloader selected
EXTRA_MNT="" # holder for additional partitions while mounting EXMNT="" # holder for additional partitions while mounting
EXTRA_MNTS="" # when an extra partition is mounted append it's info EXMNTS="" # when an extra partition is mounted append it's info
SWAP_PART="" # swap partition or file path SWAP_PART="" # swap partition or file path
SWAP_SIZE="" # when using a swapfile use this size SWAP_SIZE="" # when using a swapfile use this size
NEWUSER="" # username for the primary user NEWUSER="" # username for the primary user
@ -30,7 +30,7 @@ ROOT_PASS="" # root password
LOGIN_WM="" # default login session LOGIN_WM="" # default login session
LOGIN_TYPE="" # login manager can be lightdm or xinit LOGIN_TYPE="" # login manager can be lightdm or xinit
INSTALL_WMS="" # space separated list of chosen wm/de INSTALL_WMS="" # space separated list of chosen wm/de
KERNEL="linux" # kernel can be linux or linux-lts KERNEL="linux" # can be linux, linux-lts, linux-zen, or linux-hardened
MYSHELL="" # login shell for root and the primary user MYSHELL="" # login shell for root and the primary user
PACKAGES="" # list of all packages to install including WM_PACKAGES PACKAGES="" # list of all packages to install including WM_PACKAGES
USER_PKGS="" # packages selected by the user during install USER_PKGS="" # packages selected by the user during install
@ -57,7 +57,7 @@ CONFIG_DONE=false # basic configuration is finished
BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352 BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352
CHECKED_NET=false # have we checked the network connection already CHECKED_NET=false # have we checked the network connection already
AUTO_ROOT_PART="" # values from auto partition AUTO_ROOT_PART="" # values from auto partition
AUTO_BOOT_PART="" AUTO_BOOT_PART=""
# sane baseline # sane baseline
@ -67,7 +67,7 @@ BASE_PKGS+="playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-
# sane extras for window managers # sane extras for window managers
WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip exo " WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip exo "
WM_BASE_PKGS+="xdotool compton gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect" WM_BASE_PKGS+="xdotool compton wmctrl gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect"
SEL=0 # currently selected menu item SEL=0 # currently selected menu item
ERR="/tmp/errlog" # error log used internally ERR="/tmp/errlog" # error log used internally
@ -109,7 +109,7 @@ CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
# command used to install each bootloader # command used to install each bootloader
declare -A BCMDS=( declare -A BCMDS=(
[grub]="grub-install --recheck --force" [grub]="grub-install --recheck --force"
[syslinux]="syslinux-install_update -iam" [syslinux]="syslinux-install_update -i -a -m"
[systemd-boot]="bootctl --path=/boot install" [systemd-boot]="bootctl --path=/boot install"
) )
@ -273,54 +273,56 @@ show_cfg()
---------- PARTITION CONFIGURATION ------------ ---------- PARTITION CONFIGURATION ------------
Root: ${ROOT_PART:-None} Root: ${ROOT_PART:-none}
Boot: ${BOOT_PART:-${BOOT_DEVICE:-None}} Boot: ${BOOT_PART:-${BOOT_DEVICE:-none}}
Swap: ${SWAP_PART:-None} Swap: ${SWAP_PART:-none}
Size: ${SWAP_SIZE:-None} Size: ${SWAP_SIZE:-none}
LVM: ${LVM:-None} LVM: ${LVM:-none}
LUKS: ${LUKS:-None} LUKS: ${LUKS:-none}
Extra Mounts: ${EXTRA_MNTS:-${EXTRA_MNT:-None}} Extra Mounts: ${EXMNTS:-${EXMNT:-none}}
Mkinit Hooks: ${HOOKS:-None} Mkinit Hooks: ${HOOKS:-none}
---------- BOOTLOADER CONFIGURATION ----------- ---------- BOOTLOADER CONFIGURATION -----------
Bootloader: ${BOOTLDR:-None} Bootloader: ${BOOTLDR:-none}
Mountpoint: ${mnt:-None} Mountpoint: ${mnt:-none}
Command: ${cmd:-None} Command: ${cmd:-none}
------------ SYSTEM CONFIGURATION ------------- ------------ SYSTEM CONFIGURATION -------------
Locale: ${LOCALE:-None} Locale: ${LOCALE:-none}
Keymap: ${KEYMAP:-None} Keymap: ${KEYMAP:-none}
Hostname: ${HOSTNAME:-None} Hostname: ${HOSTNAME:-none}
Timezone: ${ZONE:-None}/${SUBZONE:-None} Timezone: ${ZONE:-none}/${SUBZONE:-none}
------------ USER CONFIGURATION -------------- ------------ USER CONFIGURATION --------------
User: ${NEWUSER:-None} User: ${NEWUSER:-none}
Shell: ${MYSHELL:-None} Shell: ${MYSHELL:-none}
Session: ${LOGIN_WM:-None} Session: ${LOGIN_WM:-none}
Autologin: ${AUTOLOGIN:-None} Autologin: ${AUTOLOGIN:-none}
Login Method: ${LOGIN_TYPE:-None} Login Method: ${LOGIN_TYPE:-none}
------------ PACKAGES AND MIRRORS ------------- ------------ PACKAGES AND MIRRORS -------------
Kernel: ${KERNEL:-None} Kernel: ${KERNEL:-none}
Sessions: ${INSTALL_WMS:-None} Sessions: ${INSTALL_WMS:-none}
Mirrors: ${MIRROR_CMD:-None} Mirrors: ${MIRROR_CMD:-none}
Packages: $(print4 "${pkgs:-None}") Packages: $(print4 "${pkgs:-none}")
" "
} }
cfg_menu() cfg_menu()
{ {
local err=0
tput civis tput civis
if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"; then if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"; then
return 1 return 1
@ -335,9 +337,13 @@ cfg_menu()
return 1 return 1
fi fi
select_timezone || return 1 select_timezone || return 1
if ! KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" 'linux' '-' 'linux-lts' '-')"; then KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" \
return 1 'linux' 'Vanilla Linux kernel and modules, with a few patches applied.' \
fi 'linux-lts' 'Long-term support (LTS) Linux kernel and modules.' \
'linux-zen' 'A collaborative effort of kernel hackers to provide the best Linux kernel for everyday systems' \
'linux-hardened' 'A security-focused Linux kernel with hardening patches to mitigate kernel and userspace exploits')"
err=$?
(( err == 0 )) || return 1
select_mirrorcmd || return 1 select_mirrorcmd || return 1
CONFIG_DONE=true CONFIG_DONE=true
return 0 return 0
@ -887,9 +893,9 @@ partition_menu()
local root_size msg ret table boot_fs local root_size msg ret table boot_fs
root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 { root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 {
if ($1 ~ "G") { if ($1 ~ "G") {
sub(/G/, ""); print ($1 * 1000 - 512) / 1000"G" sub(/G/, ""); print ($1 * 1000 - 512) / 1000 "G"
} else { } else {
sub(/M/, ""); print ($1 - 512)"M" sub(/M/, ""); print ($1 - 512) "M"
} }
}') }')
@ -899,7 +905,7 @@ partition_menu()
msg="$_PartBody2"; table="gpt"; boot_fs="fat32" msg="$_PartBody2"; table="gpt"; boot_fs="fat32"
fi fi
if yesno "$_PrepParts" "$_PartBody1 $device $msg ($size)$_PartBody3"; then if yesno "$_PrepParts" "$_PartBody1 $device $msg ($root_size)$_PartBody3"; then
auto_partition "$device" "$table" "$boot_fs" "$root_size" || return 1 auto_partition "$device" "$table" "$boot_fs" "$root_size" || return 1
else else
partition_menu "$device" partition_menu "$device"
@ -916,15 +922,6 @@ format_as()
errshow "${FS_CMDS[$2]} $1" errshow "${FS_CMDS[$2]} $1"
} }
decr_count()
{
# remove a partition from the dialog list and decrement the number partitions left
local p="$1"
PARTS="$(sed "s~${p} [0-9]*[G-M]~~; s~${p} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
(( COUNT > 0 )) && (( COUNT-- ))
return 0
}
enable_swap() enable_swap()
{ {
if [[ $1 == "$MNT/swapfile" && $SWAP_SIZE ]]; then if [[ $1 == "$MNT/swapfile" && $SWAP_SIZE ]]; then
@ -983,12 +980,12 @@ confirm_mount()
[[ $mount == "$MNT" ]] && local m="/ (root)" || local m="${mount#$MNT}" [[ $mount == "$MNT" ]] && local m="/ (root)" || local m="${mount#$MNT}"
if [[ $(mount) == *"$mount"* ]]; then if [[ $(mount) == *"$mount"* ]]; then
infobox "$_MntTitle" "$_MntSucc\nPartition: $part\nMountpoint: $m\n" 1 infobox "$_MntTitle" "$_MntSucc\nPartition: $part\nMountpoint: $m\n" 1
decr_count "$part" PARTS="$(sed "s~${part} [0-9]*[G-M]~~; s~${part} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
(( COUNT > 0 )) && (( COUNT-- ))
else else
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 infobox "$_MntTitle" "$_MntFail\n$msg\n" 1
return 1 return 1
fi fi
return 0 return 0
} }
@ -1203,7 +1200,8 @@ select_swap()
SWAP_PART="/swapfile" SWAP_PART="/swapfile"
else else
enable_swap "$SWAP_PART" enable_swap "$SWAP_PART"
decr_count "$SWAP_PART" PARTS="$(sed "s~${SWAP_PART} [0-9]*[G-M]~~; s~${SWAP_PART} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
(( COUNT > 0 )) && (( COUNT-- ))
SWAP_SIZE="$(lsblk -lno SIZE $SWAP_PART)" SWAP_SIZE="$(lsblk -lno SIZE $SWAP_PART)"
fi fi
return 0 return 0
@ -1211,72 +1209,92 @@ select_swap()
select_mountpoint() select_mountpoint()
{ {
local err=0
tput cnorm tput cnorm
EXTRA_MNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1" "/" nolimit)" || return 1 while true; do
if [[ ${EXTRA_MNT:0:1} != "/" || ${#EXTRA_MNT} -le 1 || $EXTRA_MNT =~ \ |\' || $EXTRA_MNTS == *"$EXTRA_MNT"* ]]; then EXMNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1" "/" nolimit)"
msgbox "$_ErrTitle" "$_ExtErrBody" err=$?
select_mountpoint || return 1 (( err == 0 )) || break
fi if [[ ${EXMNT:0:1} != "/" || ${#EXMNT} -le 1 || $EXMNT =~ \ |\' || $EXMNTS == *"$EXMNT"* ]]; then
return 0 msgbox "$_ErrTitle" "$_ExtErrBody"
else
break
fi
done
return $err
} }
select_mount_opts() select_mount_opts()
{ {
local part="$1" local part="$1" fs="$2" err=0
local fs="$2"
local title="${fs^} Mount Options" local title="${fs^} Mount Options"
local opts="${FS_OPTS[$fs]}" local opts="${FS_OPTS[$fs]}"
tput civis if is_ssd "$part" >/dev/null 2>&1; then
is_ssd "$part" >/dev/null 2>&1 && opts=$(sed 's/discard - off/discard - on/' <<< "$opts") opts=$(sed 's/discard - off/discard - on/' <<< "$opts")
MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist "$_MntBody" 0 0 0 $opts)" fi
[[ $MNT_OPTS ]] && MNT_OPTS="$(sed 's/ /,/g; $s/,$//' <<< "$MNT_OPTS" )" || return 1
yesno "$title" "$_MntConfBody $MNT_OPTS\n" || { select_mount_opts "$part" "$fs" || return 1; }
return 0 tput civis
while true; do
MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $title " --checklist "$_MntBody" 0 0 0 $opts)"
if [[ $MNT_OPTS ]]; then
MNT_OPTS="$(sed 's/ /,/g; $s/,$//' <<< "$MNT_OPTS" )"
yesno "$title" "$_MntConfBody $MNT_OPTS\n" && break
else
err=1; break
fi
done
return $err
} }
select_filesystem() select_filesystem()
{ {
local part="$1" local part="$1" fs="" cur_fs="" err=0
local fs cur_fs
cur_fs="$(lsblk -lno FSTYPE "$part" 2>/dev/null)" cur_fs="$(lsblk -lno FSTYPE "$part" 2>/dev/null)"
local msg="\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-None}\nDefault: ext4" local msg="\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-none}\nDefault: ext4"
[[ $part == $ROOT_PART && $ROOT_PART == $AUTO_ROOT_PART && $LUKS == "" && $LVM == "" ]] && return 0 [[ $part == $ROOT_PART && $ROOT_PART == $AUTO_ROOT_PART && $LUKS == "" && $LVM == "" ]] && return 0
tput civis
if [[ $cur_fs && $part != "$ROOT_PART" ]]; then while true; do
fs="$(menubox "$_FSTitle: $part" "$msg" \ tput civis
"$_Skip" "-" \ if [[ $cur_fs && $part != "$ROOT_PART" ]]; then
"ext4" "${FS_CMDS[ext4]}" \ fs="$(menubox "$_FSTitle: $part" "$msg" \
"ext3" "${FS_CMDS[ext3]}" \ "$_Skip" "-" \
"ext2" "${FS_CMDS[ext2]}" \ "ext4" "${FS_CMDS[ext4]}" \
"vfat" "${FS_CMDS[vfat]}" \ "ext3" "${FS_CMDS[ext3]}" \
"ntfs" "${FS_CMDS[ntfs]}" \ "ext2" "${FS_CMDS[ext2]}" \
"f2fs" "${FS_CMDS[f2fs]}" \ "vfat" "${FS_CMDS[vfat]}" \
"jfs" "${FS_CMDS[jfs]}" \ "ntfs" "${FS_CMDS[ntfs]}" \
"xfs" "${FS_CMDS[xfs]}"\ "f2fs" "${FS_CMDS[f2fs]}" \
"nilfs2" "${FS_CMDS[nilfs2]}" \ "jfs" "${FS_CMDS[jfs]}" \
"reiserfs" "${FS_CMDS[reiserfs]}")" "xfs" "${FS_CMDS[xfs]}"\
[[ $fs == "$_Skip" ]] && return 0 "nilfs2" "${FS_CMDS[nilfs2]}" \
else "reiserfs" "${FS_CMDS[reiserfs]}")"
fs="$(menubox "$_FSTitle: $part" "$msg" \
"ext4" "${FS_CMDS[ext4]}" \ [[ $fs == "$_Skip" ]] && break
"ext3" "${FS_CMDS[ext3]}" \ else
"ext2" "${FS_CMDS[ext2]}" \ fs="$(menubox "$_FSTitle: $part" "$msg" \
"ntfs" "${FS_CMDS[ntfs]}" \ "ext4" "${FS_CMDS[ext4]}" \
"f2fs" "${FS_CMDS[f2fs]}" \ "ext3" "${FS_CMDS[ext3]}" \
"jfs" "${FS_CMDS[jfs]}" \ "ext2" "${FS_CMDS[ext2]}" \
"xfs" "${FS_CMDS[xfs]}" \ "ntfs" "${FS_CMDS[ntfs]}" \
"nilfs2" "${FS_CMDS[nilfs2]}" \ "f2fs" "${FS_CMDS[f2fs]}" \
"reiserfs" "${FS_CMDS[reiserfs]}")" "jfs" "${FS_CMDS[jfs]}" \
fi "xfs" "${FS_CMDS[xfs]}" \
[[ $fs ]] || return 1 "nilfs2" "${FS_CMDS[nilfs2]}" \
if yesno "$_FSTitle" "\nFormat $part as $fs?\n"; then "reiserfs" "${FS_CMDS[reiserfs]}")"
format_as "$part" "$fs" || return 1
else fi
select_filesystem "$part" || return 1
fi [[ $fs ]] || { err=1; break; }
return 0
yesno "$_FSTitle" "\nFormat $part as $fs?\n" && break
done
(( err == 0 )) || return $err
[[ $fs == "$_Skip" ]] || format_as "$part" "$fs"
} }
select_efi_partition() select_efi_partition()
@ -1311,7 +1329,7 @@ select_efi_partition()
select_boot_partition() select_boot_partition()
{ {
tput civis tput civis
if [[ $AUTO_BOOT_PART == "$BOOT_PART" ]]; then if [[ $AUTO_BOOT_PART && $AUTO_BOOT_PART == "$BOOT_PART" ]]; then
BOOT_PART="$AUTO_BOOT_PART" BOOT_PART="$AUTO_BOOT_PART"
return 0 # were done here return 0 # were done here
else else
@ -1353,13 +1371,13 @@ select_extra_partitions()
while (( COUNT > 0 )); do while (( COUNT > 0 )); do
tput civis tput civis
part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the last menu" $PARTS)" part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)"
if [[ $part == "$_Done" || $part == "" ]]; then if [[ $part == "$_Done" || $part == "" ]]; then
break break
elif select_filesystem "$part" && select_mountpoint && mount_partition "$part" "$EXTRA_MNT"; then elif select_filesystem "$part" && select_mountpoint && mount_partition "$part" "$EXMNT"; then
EXTRA_MNTS="$EXTRA_MNTS $part: $EXTRA_MNT" EXMNTS="$EXMNTS $part: $EXMNT"
[[ $EXTRA_MNT == '/usr' && $HOOKS != *usr* ]] && HOOKS="usr $HOOKS" [[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS="usr $HOOKS"
else else
break; return 1 break; return 1
fi fi
@ -1427,7 +1445,7 @@ EOF
if [[ -e /run/archiso/sfs/airootfs ]]; then if [[ -e /run/archiso/sfs/airootfs ]]; then
printf "Copying vmlinuz and ucode to /boot\n" printf "Copying vmlinuz and ucode to /boot\n"
[[ $KERNEL != 'linux-lts' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux [[ $KERNEL == 'linux' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
[[ $UCODE && ! $VM ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/${UCODE}.img [[ $UCODE && ! $VM ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/${UCODE}.img
fi fi
@ -1530,7 +1548,7 @@ setup_xinit()
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' $MNT/home/$NEWUSER/.xinitrc; then if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' $MNT/home/$NEWUSER/.xinitrc; then
sed -i "/exec/ c exec ${LOGIN_WM}" $MNT/home/$NEWUSER/.xinitrc sed -i "/exec/ c exec ${LOGIN_WM}" $MNT/home/$NEWUSER/.xinitrc
else else
printf "exec %s\n" "$LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc printf "exec %s\n" "$LOGIN_WM" >> $MNT/home/$NEWUSER/.xinitrc
fi fi
# automatic startx for login shells # automatic startx for login shells
@ -1567,10 +1585,7 @@ EOF
loginrc=".zprofile" loginrc=".zprofile"
esac esac
if ! [[ ${EDIT_FILES[login]} =~ $loginrc ]]; then [[ ${EDIT_FILES[login]} == *"$loginrc"* ]] || EDIT_FILES[login]+=" /home/$NEWUSER/$loginrc"
# add the shell login file to the edit list after install
EDIT_FILES[login]+=" /home/$NEWUSER/$loginrc"
fi
if [[ $AUTOLOGIN == true ]]; then if [[ $AUTOLOGIN == true ]]; then
sed -i "s/root/${NEWUSER}/g" $SERVICE/autologin.conf sed -i "s/root/${NEWUSER}/g" $SERVICE/autologin.conf
@ -1666,7 +1681,19 @@ package_operations()
[[ $MYSHELL == *mksh* ]] && inpkg+=" mksh" [[ $MYSHELL == *mksh* ]] && inpkg+=" mksh"
[[ $BOOTLDR == 'grub' ]] && inpkg+=" grub" [[ $BOOTLDR == 'grub' ]] && inpkg+=" grub"
[[ $KERNEL == 'linux-lts' ]] && { inpkg+=" linux-lts"; rmpkg+=" linux"; }
if [[ $KERNEL == 'linux-lts' ]]; then
inpkg+=" linux-lts"; rmpkg+=" linux"
elif [[ $KERNEL == 'linux-zen' ]]; then
inpkg+=" linux-zen"; rmpkg+=" linux"
elif [[ $KERNEL == 'linux-hardened' ]]; then
inpkg+=" linux-hardened"; rmpkg+=" linux"
fi
if [[ $MYSHELL == '/usr/bin/zsh' ]]; then
inpkg+=" zsh-completions zsh-history-substring-search"
fi
[[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm) ]] && inpkg+=" $WM_BASE_PKGS" [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm) ]] && inpkg+=" $WM_BASE_PKGS"
[[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey" [[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey"
@ -1726,13 +1753,13 @@ setup_grub()
EDIT_FILES[bootloader]="/etc/default/grub" EDIT_FILES[bootloader]="/etc/default/grub"
if [[ $SYS == 'BIOS' ]]; then if [[ $SYS == 'BIOS' ]]; then
[[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; } [[ $BOOT_DEVICE ]] || { select_device 'boot' || return 1; }
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE" BCMDS[grub]="grub-install --recheck --force --target=i386-pc $BOOT_DEVICE"
else else
if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then
luks_pass "$_LuksOpen" 1 || return 1 luks_pass "$_LuksOpen" 1 || return 1
fi fi
BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true && BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true &&
${BCMDS[grub]} --bootloader-id=$DIST" grub-install --recheck --force --bootloader-id=$DIST"
grep -q $efidir/efivars <<< "$(mount)" || mount -t efivarfs efivarfs $efidir/efivars grep -q $efidir/efivars <<< "$(mount)" || mount -t efivarfs efivarfs $efidir/efivars
fi fi
@ -1787,7 +1814,7 @@ prerun_grub()
prerun_systemd-boot() prerun_systemd-boot()
{ {
# no LVM then systemd-boot uses PARTUUID # no LVM then systemd-boot uses PARTUUID
[[ $ROOT_PART =~ /dev/mapper ]] || ROOT_PART_ID="PART$ROOT_PART_ID" [[ $ROOT_PART == */dev/mapper* ]] || ROOT_PART_ID="PART$ROOT_PART_ID"
# create the boot entry configs # create the boot entry configs
mkdir -p ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries mkdir -p ${MNT}${BMNTS[$SYS-systemd-boot]}/loader/entries
@ -1830,8 +1857,7 @@ prerun_syslinux()
{ {
mkdir -pv $MNT${BMNTS[$SYS-syslinux]}/syslinux mkdir -pv $MNT${BMNTS[$SYS-syslinux]}/syslinux
cp -rfv /usr/lib/syslinux/bios/* $MNT${BMNTS[$SYS-syslinux]}/syslinux/ cp -rfv /usr/lib/syslinux/bios/* $MNT${BMNTS[$SYS-syslinux]}/syslinux/
cat > $MNT${BMNTS[$SYS-syslinux]}/syslinux/syslinux.cfg << EOF
cat > $cfgdir/syslinux.cfg << EOF
UI menu.c32 UI menu.c32
PROMPT 0 PROMPT 0
@ -1850,16 +1876,27 @@ MENU LABEL $DIST Linux Fallback
LINUX ../vmlinuz-$KERNEL LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
INITRD ../initramfs-$KERNEL-fallback.img$([[ $UCODE ]] && printf "\nINITRD %s" "../${UCODE}.img") INITRD ../initramfs-$KERNEL-fallback.img$([[ $UCODE ]] && printf "\nINITRD %s" "../${UCODE}.img")
#LABEL grub2
#MENU LABEL Grub2
#COM32 chain.c32
#APPEND file=../grub/boot.img
#LABEL windows
#MENU LABEL Windows
#COM32 chain.c32
#APPEND hd0 3
EOF EOF
return 0 return 0
} }
install_bootloader() install_bootloader()
{ {
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then if [[ $ROOT_PART == */dev/mapper* ]]; then
ROOT_PART_ID="UUID=$(blkid -s PARTUUID -o value $ROOT_PART)"
else
ROOT_PART_ID="$ROOT_PART" ROOT_PART_ID="$ROOT_PART"
else
ROOT_PART_ID="UUID=$(blkid -s UUID -o value $ROOT_PART)"
fi fi
if [[ $SYS == 'UEFI' ]]; then if [[ $SYS == 'UEFI' ]]; then
@ -1909,20 +1946,19 @@ lvm_menu()
local choice local choice
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \ choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepLVM " --menu "$_LvmMenu" 0 0 6 \ --title " $_PrepLVM " --menu "$_LvmMenu" 0 0 0 \
"$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \ "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \
"$_LvmDelVG" "vgremove -f" \ "$_LvmDelVG" "vgremove -f" \
"$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \ "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \
"$_Back" "Return to the main menu")" "$_Back" "Return to the main menu")"
case $choice in case $choice in
"$_LvmCreateVG") lvm_create && return 0 ;; "$_LvmCreateVG") lvm_create || return 1 ;;
"$_LvmDelVG") lvm_del_vg ;; "$_LvmDelVG") lvm_del_vg ;;
"$_LvMDelAll") lvm_del_all ;; "$_LvMDelAll") lvm_del_all ;;
*) return 0
esac esac
lvm_menu return 0
} }
lvm_detect() lvm_detect()
@ -2002,7 +2038,7 @@ lvm_volume_name()
tput cnorm tput cnorm
local name local name
if ! name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg" "$default" nolimit)"; then if ! name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$msg" "$default" nolimit)"; then
return 1 return 1
fi fi
@ -2039,7 +2075,7 @@ lvm_extra_lvs()
get_lv_size || { break; return 1; } get_lv_size || { break; return 1; }
lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR
errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME" errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME"
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$_Done LV $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2." msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$_Done Logical Volume (LV) $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2.\n"
(( VOL_COUNT-- )) (( VOL_COUNT-- ))
done done
@ -2103,9 +2139,7 @@ lvm_mkgroup()
lvm_create() lvm_create()
{ {
VOLUME_GROUP="" VOLUME_GROUP=""; LVM_PARTS=(); VGROUP_MB=0
LVM_PARTS=()
VGROUP_MB=0
umount_dir $MNT umount_dir $MNT
lvm_partitions || return 1 lvm_partitions || return 1
lvm_mkgroup || return 1 lvm_mkgroup || return 1
@ -2114,10 +2148,8 @@ lvm_create()
lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VGROUP_MB}MB)" || return 1 lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VGROUP_MB}MB)" || return 1
lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR
errshow "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME" errshow "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME"
LVM='logical volume' LVM='logical volume'; tput civis; sleep 0.5
tput civis local msg="\n$_Done $_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2.\n"
sleep 0.5
local msg="${_Done}$_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2."
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n" msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n"
} }
@ -2165,13 +2197,12 @@ luks_menu()
"$_Back" "Return to the main menu")" "$_Back" "Return to the main menu")"
case $choice in case $choice in
"$_LuksEncrypt") luks_default && return 0 ;; "$_LuksEncrypt") luks_default || return 1 ;;
"$_LuksOpen") luks_open && return 0 ;; "$_LuksOpen") luks_open || return 1 ;;
"$_LuksEncryptAdv") luks_keycmd && return 0 ;; "$_LuksEncryptAdv") luks_keycmd || return 1 ;;
*) return 0
esac esac
luks_menu return 0
} }
luks_open() luks_open()