Split the large amount of varaible setup to a lib file

This commit is contained in:
natemaia 2018-09-01 12:16:12 -07:00
parent e948933780
commit 432e82f651
3 changed files with 110 additions and 148 deletions

View File

@ -12,23 +12,27 @@
# immutable variables {
readonly DIST="ArchLabs" # Linux distributor
readonly VER="1.6.67" # Installer version
readonly VER="1.6.69" # Installer version
readonly LIVE="liveuser" # Live session user
readonly MNT="/mnt/install" # Install mountpoint
readonly ERR="/tmp/errlog" # Built-in error log
readonly EFI="/sys/firmware/efi/efivars"
readonly LIB="/usr/share/archlabs/installer/lib"
readonly TRN="/usr/share/archlabs/installer/lang"
readonly RUN="/run/archiso/bootmnt/arch/boot"
readonly VM="$(dmesg | grep -i "hypervisor")"
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
if [[ $IGNORE_DEV ]]; then
readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')"
else
@ -43,11 +47,12 @@ elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) ]]; then
readonly UCODE="amd-ucode.img"
fi
# create associative array for SUBZONES[zone], value is: 'sub-zone country_code'
declare -Ag SUBZONES
# create associative array for SUBZONES[zone]
declare -A SUBZONES
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
done
readonly SUBZONES # make it read only
if [[ $DISPLAY && $TERM != 'linux' ]]; then
@ -71,19 +76,22 @@ tz Swahili ke Swahili bw Tswana ph Filipino id Indonesian my Malay tm Turkmen bt
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer
az Azerbaijani"
declare -Agr BMNTS=(
declare -Ar BMNTS=(
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
[BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot"
)
declare -Agr BOOTLDRS=([BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}"
declare -Ar BOOTLDRS=([BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}"
[UEFI]="grub ${BMNTS[UEFI-grub]} systemd-boot ${BMNTS[UEFI-systemd-boot]} syslinux ${BMNTS[UEFI-syslinux]}"
)
declare -Agr FS_CMDS=(
declare -Ar FS_CMDS=(
[ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q"
[f2fs]="mkfs.f2fs" [jfs]="mkfs.jfs -q" [xfs]="mkfs.xfs -f" [nilfs2]="mkfs.nilfs2 -q"
[ntfs]="mkfs.ntfs -q" [reiserfs]="mkfs.reiserfs -q" [vfat]="mkfs.vfat -F32"
)
declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
declare -Ar FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
[ext4]="dealloc - off discard - off nofail - off noacl - off relatime - off noatime - off nobarrier - off nodelalloc - off"
[jfs]="discard - off errors=continue - off errors=panic - off nointegrity - off"
[reiserfs]="acl - off nolog - off notail - off replayonly - off user_xattr - off"
@ -91,41 +99,43 @@ declare -Agr FS_OPTS=([vfat]="" [ntfs]="" [ext2]="" [ext3]=""
[nilfs2]="discard - off nobarrier - off errors=continue - off errors=panic - off order=relaxed - off order=strict - off norecovery - off"
[f2fs]="data_flush - off disable_roll_forward - off disable_ext_identify - off discard - off fastboot - off flush_merge - off inline_xattr - off inline_data - off inline_dentry - off no_heap - off noacl - off nobarrier - off noextent_cache - off noinline_data - off norecovery - off"
)
# }
init_variables() {
declare -g BT="$DIST Installer - (x86_64) - Version $VER"
declare -g ROOT_PART=""
declare -g BOOT_DEVICE=""
declare -g BOOT_PART=""
declare -g BOOTLDR=""
declare -g EXTRA_MNT=""
declare -g EXTRA_MNTS=""
declare -g SWAP="none"
declare -g SWAP_SIZE="${SYS_MEM}M"
declare -g NEWUSER=""
declare -g USER_PASS=""
declare -g ROOT_PASS=""
declare -g LOGIN_WM=""
declare -g LOGIN_TYPE=""
declare -g INSTALL_WMS=""
declare -g KERNEL="linux"
declare -g WM_PACKAGES=""
declare -g EXTRA_PACKAGES=""
declare -g MKINIT_HOOKS="shutdown"
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
BT="$DIST Installer - (x86_64) - Version $VER"
ROOT_PART=""
BOOT_DEVICE=""
BOOT_PART=""
BOOTLDR=""
EXTRA_MNT=""
EXTRA_MNTS=""
SWAP="none"
SWAP_SIZE="${SYS_MEM}M"
NEWUSER=""
USER_PASS=""
ROOT_PASS=""
LOGIN_WM=""
LOGIN_TYPE=""
INSTALL_WMS=""
KERNEL="linux"
WM_PACKAGES=""
EXTRA_PACKAGES=""
MKINIT_HOOKS="shutdown"
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
declare -g IS_64BIT=false
declare -g AUTOLOGIN=false
declare -g CONFIG_DONE=false
declare -g SEPERATE_BOOT=false
IS_64BIT=false
AUTOLOGIN=false
CONFIG_DONE=false
SEPERATE_BOOT=false
declare -Ag BCMDS=(
declare -A BCMDS=(
[syslinux]="syslinux-install_update -iam"
[grub]="grub-install --recheck --force"
[systemd-boot]="bootctl --path=${BMNTS[UEFI-systemd-boot]} install"
[systemd-boot]="bootctl --path=/boot install"
)
declare -Ag FILES=(
declare -A FILES=(
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
[3]="/etc/locale.conf /etc/default/locale"
[4]="/etc/hostname /etc/hosts"
@ -139,15 +149,9 @@ init_variables() {
}
source_file() {
. $1 2>/dev/null && return 0
echo -e "\nFailed to source library file $1"
die 1
. $1 2>/dev/null && return 0 || { echo -e "\nFailed to source library file $1"; die 1; }
}
######################################################################
## Setup ##
######################################################################
user_setup() {
tput cnorm
@ -212,7 +216,7 @@ select_language() {
"9" "Magyar (hu_HU)" "10" "Chinese (zh_CN)")
source_file $TRN/english.trans
declare -g FONT="ter-i16n"
FONT="ter-i16n"
case $lang in
1) LOC="en_US.UTF-8" ;;
@ -241,7 +245,6 @@ select_language() {
setup_keymap() {
tput civis
declare -g KEYMAP
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 $KEYMAPS)"
[[ $? != 0 || $KEYMAP == "" ]] && return 1
@ -266,13 +269,11 @@ setup_keymap() {
setup_timezone() {
tput civis
declare -g ZONE
ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 America - Australia - \
Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -)"
[[ $? != 0 || $ZONE == "" ]] && return 1
declare -g SUBZONE
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"
[[ $? != 0 || $SUBZONE == "" ]] && return 1
@ -471,13 +472,10 @@ mirrorlist_cmd() {
return 0
}
######################################################################
## Menus ##
######################################################################
display_selection() {
local msg="Configuration values used for install
Root Partition: $ROOT_PART
Boot Partition: $BOOT_PART
@ -510,12 +508,10 @@ Packages: $EXTRA_PACKAGES"
configure_install() {
tput cnorm
declare -g HOSTNAME
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
[[ $? != 0 || $HOSTNAME == "" ]] && return 1
tput civis
declare -g LOCALE
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
[[ $? != 0 || $LOCALE == "" ]] && return 1
@ -525,11 +521,8 @@ configure_install() {
user_setup || return 1
window_manager || return 1
if yesno 'Choose Kernel' "\nUse the current Linux kernel or the LTS kernel?\n" 'Current' 'LTS'; then
KERNEL='linux'
else
KERNEL='linux-lts'
fi
local msg="\nUse the current Linux kernel or the LTS kernel?\n"
yesno 'Choose Kernel' "$msg" 'Current' 'LTS' && KERNEL='linux' || KERNEL='linux-lts'
extra_packages || return 1
CONFIG_DONE=true
@ -541,7 +534,7 @@ edit_configs() {
MENU_HIGHLIGHT=1
CURRENT_MENU="edit"
elif (( MENU_HIGHLIGHT < 10 )); then
((MENU_HIGHLIGHT++))
(( MENU_HIGHLIGHT++ ))
fi
tput civis
@ -550,8 +543,9 @@ edit_configs() {
"1" "$_Done" "2" "keyboard" "3" "language + locale" "4" "hostname" "5" "sudoers" \
"6" "mkinitcpio.conf" "7" "fstab" "8" "crypttab" "9" "$BOOTLDR" "10" "pacman.conf" \
"11" "$LOGIN_TYPE")
if [[ $MENU_HIGHLIGHT == "" || $MENU_HIGHLIGHT == 1 ]]; then
wrap_up "$_InstFinBody" 'Exit & Reboot' 'Go Back' 'reboot'
wrap_up "$_InstFinBody" 'Reboot' 'Back' 'reboot'
else
local existing_files=""
for f in $(echo "${FILES[$MENU_HIGHLIGHT]}"); do
@ -559,11 +553,7 @@ edit_configs() {
done
if [[ $existing_files != "" ]]; then
if [[ $DISPLAY && $TERM != 'linux' ]] && hash geany >/dev/null 2>&1; then
geany -i $existing_files
else
vim -O $existing_files
fi
vim -O $existing_files
else
msgbox "$_ErrTitle" "$_NoFileErr"
fi
@ -606,15 +596,16 @@ main() {
esac
}
for file in utils mount boot lvm luks install; do
source_file $LIB/$file.sh
for file in /usr/share/archlabs/installer/lib/?*.sh; do
source_file $file
done
trap sigint INT # trap Ctrl-C and call sigint() to properly exit
# trap Ctrl-C to properly exit
trap sigint INT
for arg in "$@"; do
[[ $arg == "--debug" || $arg == "-d" ]] && debug
done
for arg in $@; do case $arg in
--debug|-d) debug ;;
esac done
init_variables
select_language

View File

@ -42,32 +42,34 @@ shim_secure_boot() {
}
uefi_boot_fallback() {
# some UEFI firmware is finicky and requires a specific folder in
# /boot/efi/EFI/ and named 'boot', 'Boot', or 'BOOT'
# copy the bootloaders efi stub to that directory as bootx64.efi
# some UEFI firmware requires a directory in the ESP and a generic bootx64.efi
# see: https://wiki.archlinux.org/index.php/GRUB#UEFI
# also: https://wiki.archlinux.org/index.php/syslinux#UEFI_Systems
local boot_dir="$DIST"
[[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
local default="boot"
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
for i in $(find "$esp/EFI/" -maxdepth 1 -mindepth 1 -type d 2>/dev/null); do
grep -qi "boot" <<< "$(basename $i)" && { default="$(basename $i)"; break; }
done
[[ -d $esp/EFI/$default ]] && rm -f $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
local default
default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d)"
[[ $default ]] && default="$(basename $default)" || default="boot"
if [[ $1 == 'syslinux' ]]; then
cp -rf $esp/EFI/$boot_dir/* $esp/EFI/$default/
cp -f $esp/EFI/$boot_dir/syslinux.efi $esp/EFI/$default/bootx64.efi
else
local grub_file="grubx64.efi"
local boot_file="bootx64.efi"
# directory exists: remove everything inside, otherwise mkdir it
[[ -d $esp/EFI/$default ]] && rm -rf $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
# copy efi stub to the new default location
if [[ $BOOTLDR == 'syslinux' ]]; then
# syslinux requires the whole boot setup be copied, not just the stub
cp -rf $esp/EFI/syslinux/* $esp/EFI/$default/
cp -f $esp/EFI/syslinux/syslinux.efi $esp/EFI/$default/bootx64.efi
elif [[ $BOOTLDR == 'grub' ]]; then
# grub uses different names for the stub depending on architecture
if [[ $IS_64BIT != true ]]; then
local grub_file="grubia32.efi"
local boot_file="bootia32.efi"
else
local grub_file="grubx64.efi"
local boot_file="bootx64.efi"
fi
cp -f $esp/EFI/$boot_dir/$grub_file $esp/EFI/$default/$boot_file
cp -f $esp/EFI/$DIST/$grub_file $esp/EFI/$default/$boot_file
fi
return 0
}
@ -101,12 +103,8 @@ prep_for_grub() {
}
prep_for_systemd-boot() {
local ucode="$1"
# no LVM then systemd-boot uses PARTUUID
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
ROOT_PART_ID="PART$ROOT_PART_ID"
fi
! [[ $ROOT_PART =~ /dev/mapper ]] && ROOT_PART_ID="PART$ROOT_PART_ID"
# create the boot entry configs
mkdir -p $MNT/boot/loader/entries
@ -118,7 +116,7 @@ EOF
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
title $DIST Linux
linux /vmlinuz-${KERNEL}$([[ $ucode ]] && echo -en "\ninitrd /$ucode")
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && echo -en "\ninitrd /$UCODE")
initrd /initramfs-$KERNEL.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
EOF
@ -142,7 +140,6 @@ EOF
}
prep_for_syslinux() {
local ucode="$1"
local cfgdir="$MNT/boot/syslinux"
local cfgsrcdir="/usr/lib/syslinux/bios/"
FILES[9]="/boot/syslinux/syslinux.cfg"
@ -169,21 +166,19 @@ MENU LABEL $DIST Linux
LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
INITRD ../initramfs-$KERNEL.img
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
LABEL ${DIST}fallback
MENU LABEL $DIST Linux Fallback
LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
INITRD ../initramfs-$KERNEL-fallback.img
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
EOF
return 0
}
install_bootloader() {
chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl"
# not an LVM we can use the UUID for booting otherwise use the partition label
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
ROOT_PART_ID="UUID=$(blkid -s PARTUUID $ROOT_PART | sed 's/.*=//g; s/"//g')"
@ -191,21 +186,12 @@ install_bootloader() {
ROOT_PART_ID="$ROOT_PART"
fi
# needed for os-prober module to work properly in the chroot
mkdir -p $MNT/run && mount --rbind /run $MNT/run/
# make sure efivarfs has been mounted and remove old boot entries
if [[ $SYS == 'UEFI' ]]; then
mount -o remount,rw -t efivarfs efivarfs $EFI >/dev/null 2>&1
BCMDS[$BOOTLDR]="mount -o remount,rw -t efivarfs efivarfs $EFI; ${BCMDS[$BOOTLDR]}"
local esp="$MNT/boot/efi/EFI/"
[[ ! -d $MNT/boot/efi/EFI && -d $MNT/boot/EFI ]] && esp="$MNT/boot/EFI/"
find $esp -maxdepth 1 -mindepth 1 \( -name '[aA][rR][cC][hH][lL]abs' -o -name '[Bb][oO][oO][tT]' \) -type d -exec rm -rf '{}' \; >/dev/null 2>&1
fi
# remove old UEFI boot entries
[[ $SYS == 'UEFI' ]] && find $MNT${BMNTS[$SYS-$BOOTLDR]}/EFI/ -maxdepth 1 -mindepth 1 \
-name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
prep_for_$BOOTLDR "$UCODE"
prep_for_$BOOTLDR
# run the bootloader command
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR

View File

@ -51,11 +51,11 @@ install_base() {
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
# for virtual machines remove configs for xorg, these cause mouse issues
if [[ $VM ]]; then
# in a VM remove xorg configs, these cause issues
rm -rf $MNT/etc/X11/xorg.conf.d
elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then
# setup xorg vsync config for intel graphics
# xorg config for intel, this should never happen in a VM
cat > $MNT/etc/X11/xorg.conf.d/20-intel.conf <<EOF
Section "Device"
Identifier "Intel Graphics"
@ -71,11 +71,6 @@ EOF
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
[[ $UCODE ]] && cp -f $RUN/${UCODE/-/_} $MNT/boot/$UCODE
setup_configs
return 0
}
setup_configs() {
# copy network settings
cp -rf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
cp -f /etc/resolv.conf $MNT/etc/
@ -124,7 +119,7 @@ EOF
create_user() {
local _home="$MNT/home/$LIVE"
local serve="$MNT/etc/systemd/system/getty@tty1.service.d"
local service="$MNT/etc/systemd/system/getty@tty1.service.d"
# set root password
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd"
@ -138,29 +133,22 @@ create_user() {
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
[[ $AUTOLOGIN == true ]] && groups="$groups,nopasswdlogin"
rm -rf $_home/.{zprofile,xinitrc}
rm -rf $serve
rm -rf $service
else
if [[ $AUTOLOGIN == true ]]; then
sed -i "s/${LIVE}/${NEWUSER}/g" $serve/autologin.conf
sed -i "s/${LIVE}/${NEWUSER}/g" $service/autologin.conf
else
rm -rf $service
fi
sed -i "s/openbox-session/${LOGIN_WM}/g" $_home/.xinitrc
sed -i '/archlabs-installer/d' $_home/.zprofile
cat >> $_home/.zprofile << EOF
[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null
EOF
sed -i 's|exec sudo archlabs-installer|exec startx -- vt1 &>/dev/null|' $_home/.zprofile
fi
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.config/gtk-3.0/bookmarks
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.mozilla/firefox/archlabs.default/prefs.js
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.mozilla/firefox/archlabs.default/sessionstore.js
sed -i "s/${LIVE}/${NEWUSER}/g" $_home/.config/gtk-3.0/bookmarks $_home/.mozilla/firefox/archlabs.default/{prefs,sessionstore}.js
if ! [[ $INSTALL_WMS =~ openbox ]]; then
rm -rf $_home/.config/openbox
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
rm -rf $_home/.config/{bspwm,sxhkd}
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
rm -rf $_home/.config/i3
fi
! [[ $INSTALL_WMS =~ openbox ]] && rm -rf $_home/.config/{openbox}
! [[ $INSTALL_WMS =~ bspwm ]] && rm -rf $_home/.config/{bspwm,sxhkd}
! [[ $INSTALL_WMS =~ i3-gaps ]] && rm -rf $_home/.config/i3
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER"
chroot_cmd "usermod -aG $groups $NEWUSER"
@ -172,9 +160,7 @@ EOF
run_mkinitcpio() {
# setup a keyfile for LUKS.. Only when choosing grub and system is UEFI
if [[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]]; then
luks_keyfile
fi
[[ $LUKS -eq 1 && $LVM != 1 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
# new hooks needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
local add
@ -182,6 +168,7 @@ run_mkinitcpio() {
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
local conf="$MNT/etc/mkinitcpio.conf"
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $conf
tput civis
@ -210,27 +197,25 @@ update_system() {
fi
# for gnome and cinnamon we don't need the xfce provided stuff
if [[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then
rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
fi
[[ $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]] && rmpkg="$(pacman -Qssq 'xfce4*' 2>/dev/null)"
if [[ $BOOTLDR != 'grub' ]]; then
rmpkg="$rmpkg grub"
rm -f $MNT/etc/default/grub
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
elif [[ $BOOTLDR != 'syslinux' ]]; then
find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1
fi
local update="pacman -Syyu --noconfirm"
local network="pacman -S iputils --noconfirm"
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
local remove="pacman -Rs $rmpkg --noconfirm"
chroot_cmd "$update; $network; $install; $remove" 2>/dev/null
chroot_cmd "pacman -Syyu --noconfirm; pacman -S iputils --noconfirm; $install; $remove" 2>/dev/null
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
mkdir -p $MNT/home$LIVE/.config/nvim
cp -f $MNT/home/$LIVE/.vimrc $MNT/home$LIVE/.config/nvim/init.vim
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home$LIVE/.config/nvim/colors
mkdir -p $MNT/home/$LIVE/.config/nvim
cp -f $MNT/home/$LIVE/.vimrc $MNT/home/$LIVE/.config/nvim/init.vim
cp -rf $MNT/home/$LIVE/.vim/colors $MNT/home/$LIVE/.config/nvim/colors
fi
if [[ $INSTALL_WMS =~ dwm ]]; then