Fix regressions introduced with recent changes.
This commit is contained in:
parent
99261c5661
commit
61b1f949be
100
src/installer
100
src/installer
@ -15,8 +15,8 @@
|
||||
# immutable variables {
|
||||
|
||||
readonly DIST="Archlabs" # Linux distributor
|
||||
readonly VER="1.6.11" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user name
|
||||
readonly VER="1.6.18" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly TRN="/installer" # Translation path
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
@ -99,6 +99,20 @@ noinline_data - off norecovery - off"
|
||||
)
|
||||
# }
|
||||
|
||||
luks_variable_init() {
|
||||
declare -g LUKS=0
|
||||
declare -g LVM=0
|
||||
declare -g VOL_GROUP_MB=0
|
||||
declare -g LUKS_NAME="cryptroot"
|
||||
declare -g LUKS_PART=""
|
||||
declare -g LUKS_PASS=""
|
||||
declare -g LUKS_UUID=""
|
||||
declare -g LUKS_DEV=""
|
||||
|
||||
declare -g MKINIT_HOOKS="shutdown"
|
||||
declare -g SEPERATE_BOOT=0
|
||||
}
|
||||
|
||||
initialize_variables() {
|
||||
# Modified during runtime and are all globally accessible
|
||||
# This is called once when the script is started, and again if/when an error occurs
|
||||
@ -118,21 +132,9 @@ initialize_variables() {
|
||||
|
||||
declare -g CURRENT_MENU="main"
|
||||
declare -g MENU_HIGHLIGHT=0
|
||||
|
||||
declare -g MKINIT_HOOKS="shutdown"
|
||||
declare -g SEPERATE_BOOT=0
|
||||
|
||||
declare -g LUKS=0
|
||||
declare -g LVM=0
|
||||
declare -g VOL_GROUP_MB=0
|
||||
declare -g LUKS_NAME="cryptroot"
|
||||
declare -g LUKS_PART=""
|
||||
declare -g LUKS_PASS=""
|
||||
declare -g LUKS_UUID=""
|
||||
declare -g LUKS_DEV=""
|
||||
declare -g EDITOR_CHOICE=""
|
||||
|
||||
# boolean checks
|
||||
declare -g HAS_NETWORK=false
|
||||
declare -g FIRST_PREP=false
|
||||
declare -g FIRST_CONFIG=false
|
||||
declare -g UNPACKED_BASE=false
|
||||
@ -176,8 +178,13 @@ chroot_cmd() {
|
||||
|
||||
show_devices() {
|
||||
tput civis
|
||||
if [[ $USB_DEVS != "" ]]; then
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk "!/$USB_DEVS/"' && /disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
else
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk '/disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
fi
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepShowDev " --textbox /tmp/.devlist 0 0
|
||||
}
|
||||
|
||||
@ -186,7 +193,7 @@ set_debug() {
|
||||
exec 3>| /tmp/debug-log
|
||||
BASH_XTRACEFD=3
|
||||
|
||||
[[ $DISPLAY ]] && { $TERM_CMD -e tail -f /tmp/debug-log & }
|
||||
[[ $DISPLAY ]] && { $TERM_CMD -e "tail -f /tmp/debug-log" & }
|
||||
}
|
||||
|
||||
select_language() {
|
||||
@ -244,6 +251,8 @@ identify_system() {
|
||||
}
|
||||
|
||||
check_requirements() {
|
||||
declare -g HAS_NETWORK=false
|
||||
|
||||
# I use some bashisms such as associative arrays, string manipulation, [[]], etc..
|
||||
# these require a more up to date version of bash
|
||||
[[ ${BASH_VERSION:0:1} -lt 4 ]] && { clear; echo "[ERROR]: Requires bash version >= 4.0"; tput cnorm; exit 1; }
|
||||
@ -301,6 +310,7 @@ check_for_errors() {
|
||||
|
||||
[[ -e $ERR ]] && rm -rf $ERR
|
||||
initialize_variables
|
||||
luks_variable_init
|
||||
fi
|
||||
|
||||
return 1
|
||||
@ -719,7 +729,11 @@ find_partitions() {
|
||||
local err='NONE'
|
||||
|
||||
# string of partitions as /TYPE/PART SIZE
|
||||
if [[ $USB_DEVS != "" ]]; then
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' && !'"/$USB_DEVS/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')"
|
||||
else
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')"
|
||||
fi
|
||||
|
||||
# number of partitions total
|
||||
COUNT=$(wc -l <<< "$PARTS")
|
||||
@ -873,7 +887,7 @@ select_device() {
|
||||
|
||||
if (( DEV_COUNT == 1 )); then
|
||||
DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")"
|
||||
infobox "$_PrepMount" "\nOnly one device available: $DEVICE\n"
|
||||
infobox "$_DevSelTitle" "\nOnly one device available$([[ $1 == 'boot' ]] && echo -n " for bootloader"): $DEVICE\n"
|
||||
elif (( DEV_COUNT > 1 )); then
|
||||
tput civis
|
||||
DEVICE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_DevSelTitle " \
|
||||
@ -912,20 +926,25 @@ select_mount_opts() {
|
||||
|
||||
select_filesystem() {
|
||||
local part="$1"
|
||||
local cur_fs="$(lsblk -lno FSTYPE $part)"
|
||||
local cur_fs
|
||||
cur_fs="$(lsblk -lno FSTYPE $part)"
|
||||
|
||||
tput civis
|
||||
|
||||
local choice
|
||||
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_FSTitle: $part" \
|
||||
--menu "\nPartition: $part\n$_FSBody" 0 0 0 $([[ $cur_fs != "" ]] && echo -n "$_Skip -") \
|
||||
--menu "\nPartition: ${part}$([[ $cur_fs != "" ]] && echo -n "\nCurrent: ${cur_fs}")\n$_FSBody" 0 0 0 $([[ $cur_fs != "" ]] && echo -n "$_Skip -") \
|
||||
"ext4" "${FS_CMDS[ext4]}" "ext3" "${FS_CMDS[ext3]}" \
|
||||
"ext2" "${FS_CMDS[ext2]}" "vfat" "${FS_CMDS[vfat]}" \
|
||||
"btrfs" "${FS_CMDS[btrfs]}" "ntfs" "${FS_CMDS[ntfs]}" \
|
||||
"f2fs" "${FS_CMDS[f2fs]}" "jfs" "${FS_CMDS[jfs]}" \
|
||||
"nilfs2" "${FS_CMDS[nilfs2]}" "reiserfs" "${FS_CMDS[reiserfs]}" \
|
||||
"xfs" "${FS_CMDS[xfs]}")"
|
||||
[[ $? != 0 || $choice == "$_Skip" || $choice == "" ]] && return 0
|
||||
if [[ $choice == "$_Skip" ]]; then
|
||||
return 0
|
||||
elif [[ $choice == "" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if yesno "$_FSTitle" "\nFormat $part as $choice?\n"; then
|
||||
infobox "$_FSTitle" "\nFormatting: $part\n\nCommand: ${FS_CMDS[$choice]}\n"
|
||||
@ -986,7 +1005,7 @@ select_efi_partition() {
|
||||
|
||||
if (( COUNT == 1 )); then
|
||||
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
|
||||
infobox "$_PrepMount" "\nOnly one partition available: $BOOT_PART\n"
|
||||
infobox "$_PrepMount" "\nOnly one partition available for EFI: $BOOT_PART\n"
|
||||
else
|
||||
tput civis
|
||||
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepMount " \
|
||||
@ -1013,13 +1032,12 @@ select_bios_boot_partition() {
|
||||
--menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)"
|
||||
|
||||
if [[ $? != 0 || $BOOT_PART == "$_Skip" || $BOOT_PART == "" ]]; then
|
||||
return 0
|
||||
BOOT_PART=""
|
||||
else
|
||||
decrease_part_count "$BOOT_PART"
|
||||
# set BOOT_DEVICE for BIOS grub by removing digit from the end
|
||||
BOOT_DEVICE="${BOOT_PART%[1-9]}"
|
||||
fi
|
||||
|
||||
# set BOOT_DEVICE for BIOS grub by removing digit from the end
|
||||
BOOT_DEVICE="${boot%[1-9]}"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -1030,9 +1048,10 @@ select_root_partition() {
|
||||
elif (( LUKS == 1 && LVM == 1 )); then
|
||||
decrease_part_count "$LUKS_PART"
|
||||
decrease_part_count "/dev/mapper/$LUKS_NAME"
|
||||
ROOT_PART=""
|
||||
fi
|
||||
|
||||
if (( COUNT == 1 )) && [[ $ROOT_PART == "" ]]; then
|
||||
if [[ $COUNT -eq 1 && $ROOT_PART == "" ]]; then
|
||||
ROOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
|
||||
infobox "$_PrepMount" "\nOnly one partition available for root (/): $ROOT_PART\n"
|
||||
elif [[ $ROOT_PART == "" || $LVM -eq 1 ]]; then
|
||||
@ -1104,16 +1123,14 @@ select_install_partitions() {
|
||||
if [[ $SYS == "UEFI" ]]; then
|
||||
select_efi_partition || { BOOT_PART=""; return 1; }
|
||||
else
|
||||
select_bios_boot_partition
|
||||
(( COUNT > 0 )) && select_bios_boot_partition
|
||||
fi
|
||||
else
|
||||
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n"
|
||||
fi
|
||||
|
||||
select_boot_setup || { BOOTLOADER=""; return 1; }
|
||||
|
||||
select_swap || return 1
|
||||
|
||||
select_extra_partitions || return 1
|
||||
|
||||
return 0
|
||||
@ -1329,7 +1346,7 @@ luks_keyfile() {
|
||||
local dev
|
||||
dev="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
|
||||
|
||||
(( LVM == 1 )) && dev="/dev/mapper/$dev" || dev="/dev/$dev"
|
||||
dev="/dev/$dev"
|
||||
|
||||
local keycmd
|
||||
keycmd="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin && chmod 000 /crypto_keyfile.bin &&
|
||||
@ -1516,6 +1533,7 @@ lvm_create() {
|
||||
|
||||
if [[ $LUKS -eq 1 && $LUKS_NAME != "" ]]; then
|
||||
VOL_GROUP_PARTS="/dev/mapper/$LUKS_NAME"
|
||||
infobox "$_LvmCreateVG" "\nUsing encrypted partition created earlier: $VOL_GROUP_PARTS\n"
|
||||
else
|
||||
find_partitions 'part|crypt'
|
||||
tput civis
|
||||
@ -1626,7 +1644,8 @@ lvm_menu() {
|
||||
|
||||
install_main() {
|
||||
if [[ $UNPACKED_BASE != true ]]; then
|
||||
unpack_base_system || return 0 # user can choose to bail at this point
|
||||
# user can choose to bail at this point
|
||||
unpack_base_system || { initialize_variables; return 1; }
|
||||
UNPACKED_BASE=true
|
||||
fi
|
||||
|
||||
@ -1663,7 +1682,7 @@ install_main() {
|
||||
|
||||
unpack_base_system() {
|
||||
# continue or bail
|
||||
local msg="Boot Device: ${BOOT_PART:-none}\nBootloader: $BOOTLOADER\nSwapfile: $SWAP_FILE"
|
||||
local msg="Boot Partition: ${BOOT_PART:-none}\nBootloader: $BOOTLOADER\nSwapfile: $SWAP_FILE"
|
||||
yesno "$_InstTitle" "$_BeginInst $ROOT_PART\n$msg\n\n$_ContinueYN" || return 1
|
||||
|
||||
# create a loading bar while copying files using find, < <(), and a loop
|
||||
@ -1921,7 +1940,6 @@ setup_bootloader() {
|
||||
# needed for os-prober module to work properly in the chroot
|
||||
local udevcmd="mkdir -p /run/udev && mount --rbind /run/udev /run/udev"
|
||||
$udevcmd >/dev/null 2>&1
|
||||
# chroot_cmd "$udevcmd" >/dev/null 2>&1
|
||||
BOOT_CMDS[grub]="$udevcmd ; ${BOOT_CMDS[grub]}"
|
||||
|
||||
# BIOS uses the base device name, eg. /dev/sda
|
||||
@ -1947,7 +1965,9 @@ setup_bootloader() {
|
||||
BOOT_DONE=true
|
||||
|
||||
if [[ $LUKS -eq 1 && $SYS != "BIOS" && $BOOTLOADER == "grub" ]]; then
|
||||
[[ $LUKS_PASS && $LUKS_UUID ]] && luks_keyfile
|
||||
if [[ $LUKS_PASS && $LUKS_UUID ]]; then
|
||||
luks_keyfile || return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -2112,12 +2132,21 @@ edit_config_menu() {
|
||||
done
|
||||
|
||||
if [[ $existing_files != "" ]]; then
|
||||
if [[ $DISPLAY ]] && hash geany >/dev/null 2>&1; then
|
||||
|
||||
if ! [[ $EDITOR_CHOICE ]] && [[ $DISPLAY ]] && hash geany >/dev/null 2>&1; then
|
||||
|
||||
if yesno "$_EditTitle" "\nOpen file(s) in Geany or Vim?\n" "Geany" "Vim"; then
|
||||
EDITOR_CHOICE="geany -i"
|
||||
geany -i $existing_files
|
||||
else
|
||||
EDITOR_CHOICE="vim -O"
|
||||
vim -O $existing_files
|
||||
fi
|
||||
|
||||
elif [[ $EDITOR_CHOICE != "" ]]; then
|
||||
|
||||
$EDITOR_CHOICE $existing_files
|
||||
|
||||
else
|
||||
vim -O $existing_files
|
||||
fi
|
||||
@ -2133,6 +2162,7 @@ for arg in "$@"; do
|
||||
done
|
||||
|
||||
initialize_variables
|
||||
luks_variable_init
|
||||
select_language
|
||||
check_requirements
|
||||
identify_system
|
||||
|
@ -94,7 +94,7 @@ _UpdSysBody="\nSystem package operation\n\nUpdate: pacman -Syyu\nInstall: iputil
|
||||
_InstBootTitle="Install Bootloader"
|
||||
_InstBootloader="\nInstalling bootloader:"
|
||||
_InstBootDev="Device or partition used:"
|
||||
_MntBootBody="\nSelect bootloader and boot partition mountpoint.\n\nGrub is the recommended default, especially for multiboot."
|
||||
_MntBootBody="\nSelect bootloader and boot partition mountpoint.\n\nGrub is recommended, especially for multiboot."
|
||||
_InstSysTitle="Install Syslinux"
|
||||
_InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?"
|
||||
|
||||
@ -146,7 +146,7 @@ _Password2="Password2:"
|
||||
_MntTitle="Mount Status"
|
||||
_MntSucc="\nMount Successful!\n"
|
||||
_MntFail="\nMount Failed!\n"
|
||||
_WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nPartitions can be mounted without formatting them by selecting the '$_Skip' option from the menu, otherwise the partition will be formatted.\n"
|
||||
_WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nPartitions with existing filesystems can be mounted without formatting them by selecting the '$_Skip' option from the menu, otherwise the partition will be formatted as the chosen filesystem.\n"
|
||||
_MntBody="\nUse [Space] to de/select the desired mount options.\n\nFor SSD's the 'discard' option provides active TRIM support.\n\nChoosing none will result in an automatic mount with system applied options."
|
||||
_MntConfBody="\nConfirm the following mount options:"
|
||||
|
||||
@ -155,7 +155,7 @@ _DevSelTitle="Select Device"
|
||||
_DevSelBody="\nSelect which device to use.\n\nDevices (/dev/) are the available drives on the system. /sda, /sdb, and so on."
|
||||
|
||||
# Extra Partitions
|
||||
_ExtPartBody="\nSelect additional partitions to mount, you will be asked to enter a mountpoint after. Select 'Done' to finish and continue install."
|
||||
_ExtPartBody="\nSelect additional partitions to mount, you will be asked to enter a mountpoint after. Select 'Done' to finish mounting and continue install."
|
||||
_ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a forward slash (/).\nSome examples include:\n"
|
||||
|
||||
# Auto partition
|
||||
@ -170,7 +170,6 @@ _PartAuto="Automatic Partitioning"
|
||||
_PartWipe="Secure Wipe Device (optional)"
|
||||
|
||||
# bootloader
|
||||
_InstSelBoot="\nSelect bootloader and boot partition mountpoint.\n\ngrub is the recommended default\n"
|
||||
_InstSysTitle="Install Syslinux"
|
||||
_InstSysBody="\nInstall syslinux to the Master Boot Record (MBR) or to root (/)?"
|
||||
|
||||
@ -178,7 +177,7 @@ _InstSysBody="\nInstall syslinux to the Master Boot Record (MBR) or to root (/)?
|
||||
_FSTitle="Choose Filesystem"
|
||||
_FSBody="\nRecommended: ext4\n\nNOTE: Some aren't usable for root (/) or boot (/boot) partitions."
|
||||
_SelRootBody="\nSelect root (/) partition.\n\nThis is the partition where $DIST will be installed."
|
||||
_SelBiosBody="\nDo you want a seperate boot (/boot) partition?\n\nThis partition is where the bootloader will be installed.\n\nNOTE: It should be formatted correctly beforehand, ext3/4 is recommended for BIOS systems.\n"
|
||||
_SelBiosBody="\nDo you want to use a seperate boot partition? (required for LUKS)\n\nThis partition is where the bootloader will be installed.\n\nNOTE: It should be formatted as ext3/4 and have the boot flag enabled.\n"
|
||||
_SelSwpFile="Swapfile"
|
||||
_SelSwpSetup="Swap Setup"
|
||||
_SwapSetup="\nDo you want to use a swapfile?"
|
||||
|
Reference in New Issue
Block a user