Split mirrorlist dialog up and front load choices, add format/boot flag setup for boot partitions

This commit is contained in:
natemaia
2018-07-30 00:30:35 -07:00
parent cb21cf9f2d
commit 01c58d6dd4
11 changed files with 69 additions and 36 deletions

View File

@ -15,7 +15,7 @@
# immutable variables {
readonly DIST="Archlabs" # Linux distributor
readonly VER="1.6.18" # Installer version
readonly VER="1.6.19" # Installer version
readonly LIVE="liveuser" # Live session user
readonly TRN="/installer" # Translation path
readonly MNT="/mnt/install" # Install mountpoint
@ -133,6 +133,7 @@ initialize_variables() {
declare -g CURRENT_MENU="main"
declare -g MENU_HIGHLIGHT=0
declare -g EDITOR_CHOICE=""
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
# boolean checks
declare -g FIRST_PREP=false
@ -1027,6 +1028,12 @@ select_efi_partition() {
}
select_bios_boot_partition() {
format_as_ext4() {
infobox "$_FSTitle" "\nFormatting $1 as ext4.\n"
mkfs.ext4 -q "$1" >/dev/null 2>$ERR
check_for_errors "mkfs.ext4 -q $1" || return 1
}
tput civis
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title "$_PrepMount" \
--menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)"
@ -1034,8 +1041,21 @@ select_bios_boot_partition() {
if [[ $? != 0 || $BOOT_PART == "$_Skip" || $BOOT_PART == "" ]]; then
BOOT_PART=""
else
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormBiosBody $BOOT_PART $_FormUefiBody2"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format_as_ext4 "$BOOT_PART" || return 1
fi
else
format_as_ext4 "$BOOT_PART" || return 1
fi
# set BOOT_DEVICE for BIOS grub by removing digit from the end
BOOT_DEVICE="${BOOT_PART%[1-9]}"
PART_NUM="${BOOT_PART#$BOOT_DEVICE}"
parted -s $BOOT_DEVICE set $PART_NUM boot on 2>$ERR
check_for_errors "parted -s $BOOT_DEVICE set $PART_NUM boot on" || return 1
fi
return 0
@ -1071,7 +1091,7 @@ select_root_partition() {
select_mountpoint() {
tput cnorm
EXTRA_MNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1/home /var\n" "/")"
EXTRA_MNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1 /home /var\n" "/")"
[[ $? != 0 || $EXTRA_MNT == "" ]] && return 1
# bad mountpoint
@ -1122,8 +1142,8 @@ select_install_partitions() {
if [[ $BOOT_PART == "" ]]; then
if [[ $SYS == "UEFI" ]]; then
select_efi_partition || { BOOT_PART=""; return 1; }
else
(( COUNT > 0 )) && select_bios_boot_partition
elif (( COUNT > 0 )); then
select_bios_boot_partition || return 1
fi
else
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n"
@ -1644,6 +1664,9 @@ lvm_menu() {
install_main() {
if [[ $UNPACKED_BASE != true ]]; then
# whether to use a custom mirror sorting command later
update_mirrorlist_cmd || MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
# user can choose to bail at this point
unpack_base_system || { initialize_variables; return 1; }
UNPACKED_BASE=true
@ -1661,7 +1684,8 @@ install_main() {
setup_bootloader || return 1
if [[ $HAS_NETWORK == true && $DONE_UPDATE != true ]]; then
update_mirrorlist && update_system
update_mirrorlist
update_system
DONE_UPDATE=true
else
if pacman -Qsq archlabs-installer >/dev/null 2>&1; then
@ -1754,20 +1778,20 @@ update_system() {
--title " $_UpdSysTitle " --progressbox "$_UpdSysBody\n" 30 90
}
update_mirrorlist() {
local cmd="reflector --score 100 -l 50 -f 10 --sort rate"
update_mirrorlist_cmd() {
if ! yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic Sort" "Customize Sort"; then
infobox "$_MirrorTitle" "\nGathering mirror countries..\n"
local countries
countries="$(reflector --list-countries | awk 'NF > 1 {print $1 " -"}')"
if [[ $countries != "" ]]; then
local country
tput civis
local country
country="$(dialog --cr-wrap --stdout --backtitle "$BT" --title "$_MirrorTitle" \
--menu "$_MirrorCountry" 22 70 10 $countries)"
[[ $? != 0 || $country == "" ]] && return 1
cmd="reflector --country $country --score 80 --latest 40 --fastest 10 --sort rate"
MIRROR_CMD="reflector --country $country --score 80 --latest 40 --fastest 10 --sort rate"
fi
local ref=" --score n Limit the list to the n servers with the highest score.
@ -1779,16 +1803,20 @@ update_mirrorlist() {
'delay': MirrorStatus delay."
tput cnorm
cmd="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_MirrorTitle " \
MIRROR_CMD="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_MirrorTitle " \
--inputbox "$_MirrorCmd\n\n$ref\n" 0 0 "$cmd")"
[[ $? != 0 || $cmd == "" ]] && return 1
[[ $? != 0 || $MIRROR_CMD == "" ]] && return 1
fi
return 0
}
update_mirrorlist() {
infobox "$_MirrorTitle" "$_MirrorSort"
if ! $cmd --save $MNT/etc/pacman.d/mirrorlist; then
infobox "$_ErrTitle" "\nAn error occurred updating the mirrorlist\n"
update_mirrorlist || return 1
if ! $MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist; then
infobox "$_ErrTitle" "\nAn error occurred while updating the mirrorlist.\n\nFalling back to automatic sorting...\n"
reflector --score 100 -l 50 -f 10 --sort rate --save $MNT/etc/pacman.d/mirrorlist
fi
return 0
@ -2132,9 +2160,7 @@ edit_config_menu() {
done
if [[ $existing_files != "" ]]; 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
@ -2142,11 +2168,8 @@ edit_config_menu() {
EDITOR_CHOICE="vim -O"
vim -O $existing_files
fi
elif [[ $EDITOR_CHOICE != "" ]]; then
$EDITOR_CHOICE $existing_files
else
vim -O $existing_files
fi