Convert package lists to arrays to fix some issues.

This commit is contained in:
natemaia 2020-04-23 21:03:44 -07:00
parent 9c04406346
commit 2dec81e0a8

View File

@ -7,7 +7,7 @@
# shellcheck disable=SC2086,SC2046
VER=2.1.28
VER=2.1.30
# default values {
@ -29,31 +29,44 @@ USER_CMD="" # optional command(s) entered by the user to
export DIALOGOPTS="--cr-wrap" # dialog environment variable to hold default options, see `man dialog`
typeset -a PACKAGES USER_PKGS
# packages installed for all installation types as a baseline
BASE_PKGS="base base-devel xorg xorg-drivers git gvfs gtk3 libmad libmatroska tumbler "
BASE_PKGS+="playerctl pulseaudio pulseaudio-alsa pavucontrol sudo pamixer scrot xdg-user-dirs "
BASE_PKGS+="ffmpeg gstreamer gst-libav gst-plugins-base gst-plugins-good bash-completion xterm"
typeset -a BASE_PKGS=(
"base" "base-devel" "xorg" "xorg-drivers" "sudo" "git" "gvfs" "gtk3"
"libmad" "libmatroska" "tumbler" "ffmpeg" "gstreamer" "gst-libav" "pamixer"
"gst-plugins-base" "scrot" "gst-plugins-good" "bash-completion" "xterm"
"playerctl" "pulseaudio" "pulseaudio-alsa" "pavucontrol" "xdg-user-dirs"
)
# packages installed specific to archlabs, installed when any session is chosen
AL_BASE_PKGS="archlabs-keyring archlabs-icons archlabs-fonts archlabs-themes "
AL_BASE_PKGS+="archlabs-baph archlabs-wallpapers archlabs-scripts archlabs-skel-base"
typeset -a AL_PKGS=(
"archlabs-keyring" "archlabs-icons" "archlabs-fonts" "archlabs-themes"
"archlabs-baph" "archlabs-wallpapers" "archlabs-scripts" "archlabs-skel-base"
)
# packages installed for most window managers to provide some basic functionality
WM_BASE_PKGS="arandr nitrogen polkit-gnome network-manager-applet "
WM_BASE_PKGS+="volumeicon xclip exo laptop-detect xdotool picom wmctrl feh "
WM_BASE_PKGS+="gnome-keyring dunst gsimplecal xfce4-power-manager xfce4-settings"
typeset -a WM_PKGS=(
"arandr" "nitrogen" "polkit-gnome" "network-manager-applet" "feh"
"volumeicon" "xclip" "exo" "laptop-detect" "xdotool" "picom" "wmctrl"
"gnome-keyring" "dunst" "gsimplecal" "xfce4-power-manager" "xfce4-settings"
)
# packages installed when choosing to use pacstrap
ISO_PKGS="arch-install-scripts b43-firmware b43-fwcutter broadcom-wl btrfs-progs "
ISO_PKGS+="clonezilla crda darkhttpd ddrescue dhclient dhcpcd dialog diffutils dmraid "
ISO_PKGS+="dnsmasq dnsutils dosfstools elinks ethtool exfat-utils f2fs-tools fsarchiver "
ISO_PKGS+="ppp pptpclient refind-efi reiserfsprogs rp-pppoe rsync sdparm sg3_utils smartmontools "
ISO_PKGS+="linux-firmware lsscsi lvm2 man-db man-pages mc mdadm mtools nano ndisc6 netctl nfs-utils "
ISO_PKGS+="nilfs-utils nmap ntfs-3g ntp openconnect openssh openvpn p7zip partclone parted partimage "
ISO_PKGS+="gpm gptfdisk hdparm htop ipw2100-fw ipw2200-fw irssi iwd jfsutils lftp linux-atm gnu-netcat "
ISO_PKGS+="tcpdump testdisk unrar usb_modeswitch usbutils vi vim vpnc wget wireless-regdb wireless_tools "
ISO_PKGS+="wpa_supplicant wvdial xfsprogs xl2tpd alsa-firmware alsa-lib alsa-plugins geoclue2 lm_sensors "
ISO_PKGS+="lsb-release networkmanager pacman-contrib reflector terminus-font ttf-dejavu archlabs-keyring "
typeset -a ISO_PKGS=(
"arch-install-scripts" "b43-firmware" "b43-fwcutter" "broadcom-wl" "btrfs-progs"
"clonezilla" "crda" "darkhttpd" "ddrescue" "dhclient" "dhcpcd" "dialog" "diffutils"
"dmraid" "dnsmasq" "dnsutils" "dosfstools" "elinks" "ethtool" "exfat-utils" "f2fs-tools"
"fsarchiver" "ppp" "pptpclient" "reiserfsprogs" "rp-pppoe" "rsync" "sdparm" "sg3_utils"
"smartmontools" "linux-firmware" "lsscsi" "lvm2" "man-db" "man-pages" "mc" "mdadm" "mtools"
"nano" "ndisc6" "netctl" "nfs-utils" "nilfs-utils" "nmap" "ntfs-3g" "ntp" "openconnect"
"openssh" "openvpn" "p7zip" "partclone" "parted" "partimage" "gpm" "gptfdisk" "hdparm"
"htop" "ipw2100-fw" "ipw2200-fw" "irssi" "iwd" "jfsutils" "iputils" "lftp" "linux-atm"
"gnu-netcat" "tcpdump" "testdisk" "unrar" "usb_modeswitch" "usbutils" "vi" "vim" "vpnc"
"wget" "wvdial" "wireless-regdb" "wireless_tools" "wpa_supplicant" "xfsprogs" "xl2tpd"
"alsa-firmware" "alsa-lib" "alsa-plugins" "geoclue2" "lsb-release" "networkmanager"
"pacman-contrib" "reflector" "terminus-font" "ttf-dejavu" "archlabs-keyring" "lm_sensors"
)
SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024) "M"}' /proc/meminfo)"
LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if ($1) {print $1 " - "}}' /etc/locale.gen)"
@ -240,7 +253,7 @@ main()
select_show()
{
local pkgs="${USER_PKGS// / } ${PACKAGES// / }"
local pkgs="${USER_PKGS[*]} ${PACKAGES[*]}"
[[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu $pkgs"
pkgs="${pkgs// / }" pkgs="${pkgs# }"
msg "Show Configuration" "
@ -473,9 +486,9 @@ select_sessions()
cinnamon "A desktop environment combining traditional desktop with modern effects" "$(ofn cinnamon "${INSTALL_WMS[*]}")"
[[ $INSTALL_WMS ]] || return 0
WM_PKGS="${INSTALL_WMS/dwm/}"
WM_PKGS="${WM_PKGS// / }"
WM_PKGS="${WM_PKGS# }"
for i in ${INSTALL_WMS/dwm/}; do
WM_PKGS+=("$i")
done
for i in $INSTALL_WMS; do
LOGIN_CHOICES+="$i - "
@ -484,21 +497,25 @@ select_sessions()
yesno "${i^} Extra" \
"\nThere are some extra packages available for $i that you may want installed: ${WM_EXT[$i]}\n\n$txt\n\nWould you like to install them?\n" || continue
fi
[[ ${WM_EXT[$i]} && $WM_PKGS != *"${WM_EXT[$i]}"* ]] && WM_PKGS+=" ${WM_EXT[$i]}"
if [[ ${WM_EXT[$i]} ]]; then
for j in ${WM_EXT[$i]}; do
[[ ${WM_PKGS[*]} != *"$j"* ]] && WM_PKGS+=("$j")
done
fi
done
select_login || return 1
while IFS=' ' read -r pkg; do
[[ $PACKAGES != *"$pkg"* ]] && PACKAGES+=" $pkg"
done <<< "$WM_PKGS"
for pkg in "${WM_PKGS[@]}"; do
[[ ${PACKAGES[*]} != *"$pkg"* ]] && PACKAGES+=("$pkg")
done
return 0
}
select_packages()
{
dlg USER_PKGS check " Packages " "$_packages" \
dlg UPKGS check " Packages " "$_packages" \
abiword "A Fully-featured word processor" "$(ofn abiword "${USER_PKGS[*]}")" \
alacritty "A cross-platform, GPU-accelerated terminal emulator" "$(ofn alacritty "${USER_PKGS[*]}")" \
atom "An open-source text editor developed by GitHub" "$(ofn atom "${USER_PKGS[*]}")" \
@ -586,9 +603,13 @@ select_packages()
xreader "Document viewer for files like PDF and Postscript. X-Apps Project." "$(ofn xed "${USER_PKGS[*]}")" \
zathura "Minimalistic document viewer" "$(ofn zathura "${USER_PKGS[*]}")"
if [[ $USER_PKGS ]]; then # add any needed PKG_EXT to the list
for i in $USER_PKGS; do
[[ ${PKG_EXT[$i]} && $USER_PKGS != *"${PKG_EXT[$i]}"* ]] && USER_PKGS+=" ${PKG_EXT[$i]}"
if [[ $UPKGS ]]; then # add any needed PKG_EXT to the list
for i in $UPKGS; do
if [[ ${PKG_EXT[$i]} ]]; then
for j in ${PKG_EXT[$i]}; do
[[ ${USER_PKGS[*]} != *"$j"* ]] && USER_PKGS+=("$j")
done
fi
done
fi
@ -1257,8 +1278,13 @@ install_base()
if [[ $PACSTRAP == 1 ]]; then
# we have some customizations in /etc on the iso we want to preserve
if [[ $DIST == "ArchLabs" ]]; then
cp -aTvf /etc/skel/ "$MNT/etc/"
rm -rf "$MNT/etc/mkinitcpio-archiso.conf"
cp -vf /etc/dialogrc "$MNT/etc/dialogrc"
cp -vf /etc/os-release "$MNT/etc/os-release"
cp -vf /etc/lsb-release "$MNT/etc/lsb-release"
cp -vf /etc/skel/.zshrc "$MNT/etc/skel/.zshrc"
cp -vf /etc/pacman.conf "$MNT/etc/pacman.conf"
cp -vf /etc/modprobe.d/* "$MNT/etc/modprobe.d/"
cp -vf /etc/X11/xorg.conf.d/* "$MNT/etc/X11/xorg.conf.d/"
fi
else
# archiso files
@ -1268,17 +1294,17 @@ install_base()
# vmlinuz, if this isn't copied the standard kernel may fail mkinitcpio
cp -vf "$RUN/x86_64/vmlinuz" "$MNT/boot/vmlinuz-linux" 2> "$ERR"
errshow 1 "cp -vf '$RUN/x86_64/vmlinuz' '$MNT/boot/vmlinuz-linux'"
fi
# remove/disable customizations done to airootfs during building
chrun "systemctl disable pacman-init.service choose-mirror.service" > /dev/null 2>&1
rm -f "$MNT/etc/systemd/scripts/choose-mirror"
rm -f "$MNT/etc/systemd/system/"{choose-mirror.service,etc-pacman.d-gnupg.mount,pacman-init.service}
sed -i 's/#\(Storage=\)volatile/\1auto/' "$MNT/etc/systemd/journald.conf"
sed -i 's/\(HandleLidSwitch=\)ignore/#\1suspend/' "$MNT/etc/systemd/logind.conf"
sed -i 's/\(HandleSuspendKey=\)ignore/#\1suspend/' "$MNT/etc/systemd/logind.conf"
sed -i 's/\(HandleHibernateKey=\)ignore/#\1hibernate/' "$MNT/etc/systemd/logind.conf"
find "$MNT/boot" -name '*-ucode.img' -delete
# remove/disable customizations done to airootfs during building
chrun "systemctl disable pacman-init.service choose-mirror.service" > /dev/null 2>&1
rm -f "$MNT/etc/systemd/scripts/choose-mirror"
rm -f "$MNT/etc/systemd/system/"{choose-mirror.service,etc-pacman.d-gnupg.mount,pacman-init.service}
sed -i 's/#\(Storage=\)volatile/\1auto/' "$MNT/etc/systemd/journald.conf"
sed -i 's/\(HandleLidSwitch=\)ignore/#\1suspend/' "$MNT/etc/systemd/logind.conf"
sed -i 's/\(HandleSuspendKey=\)ignore/#\1suspend/' "$MNT/etc/systemd/logind.conf"
sed -i 's/\(HandleHibernateKey=\)ignore/#\1hibernate/' "$MNT/etc/systemd/logind.conf"
find "$MNT/boot" -name '*-ucode.img' -delete
fi
# changing distro name?
[[ $DIST != "ArchLabs" ]] || sed -i "s/ArchLabs/$DIST/g" "$MNT/etc/"{lsb-release,os-release}
@ -1387,7 +1413,7 @@ install_cleanup()
[[ $INSTALL_WMS =~ (fluxbox|bspwm|openbox) ]] || rm -rf "$MNT/home/$user/.config/jgmenu"
# remove geany configs if it wasn't installed
[[ $USER_PKGS != *geany* ]] && rm -rf "$MNT/home/$user/.config/geany"
[[ ${USER_PKGS[*]} != *geany* ]] && rm -rf "$MNT/home/$user/.config/geany"
# remove shell stuff for unused shells
[[ $NEWSHELL != 'bash' ]] && rm -rf "$MNT/home/$user/.bash"*
@ -1402,7 +1428,7 @@ install_cleanup()
[[ $LOGIN_WM == 'dwm' ]] && sed -i '/super/d; /picom/d' "$MNT/home/$user/.xprofile" "$MNT/root/.xprofile"
# remove some commands from ~/.xprofile when using self contained sessions
if [[ $LOGIN_WM =~ ($SELF_CONTAINED_SES) || ($LOGIN_TYPE != 'xinit' && $WM_PKGS =~ ($SELF_CONTAINED)) ]]; then
if [[ $LOGIN_WM =~ ($SELF_CONTAINED_SES) || ($LOGIN_TYPE != 'xinit' && ${WM_PKGS[*]} =~ ($SELF_CONTAINED)) ]]; then
sed -i '/super/d; /nitrogen/d; /picom/d' "$MNT/home/$user/.xprofile" "$MNT/root/.xprofile"
fi
@ -1466,32 +1492,52 @@ install_bootldr()
install_packages()
{
local rmpkg=""
local inpkg="$PACKAGES $USER_PKGS $AL_BASE_PKGS "
typeset -a inpkg rmpkg loginpkg
for i in "${PACKAGES[@]}"; do
inpkg+=("$i")
done
for i in "${USER_PKGS[@]}"; do
inpkg+=("$i")
done
for i in "${AL_PKGS[@]}"; do
inpkg+=("$i")
done
for i in ${LOGIN_PKGS[$LOGIN_TYPE]}; do
loginpkg+=("$i")
done
if [[ $NEWSHELL == 'zsh' ]]; then
inpkg+="zsh-completions "
elif [[ $PACSTRAP != 1 ]]; then
rmpkg+="archlabs-installer zsh "
if [[ $INSTALL_WMS =~ ($WM_PKG_SES) ]]; then
for i in "${WM_PKGS[@]}"; do
inpkg+=("$i")
done
fi
[[ $INSTALL_WMS =~ ($WM_PKG_SES) ]] && inpkg+="$WM_BASE_PKGS "
if [[ $NEWSHELL == 'zsh' ]]; then
inpkg+=("zsh-completions")
elif [[ $PACSTRAP != 1 ]]; then
rmpkg+=("archlabs-installer" "zsh")
fi
# update and install crucial packages first to avoid issues
chrun "pacman -Syyu --noconfirm" 2> "$ERR" 2>&1
chrun "pacman -S $BASE_PKGS $ISO_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $NEWSHELL --noconfirm --needed" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -S $BASE_PKGS $ISO_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $NEWSHELL --noconfirm --needed'"
errshow 1 "chrun 'pacman -Syyu --noconfirm'"
chrun "pacman -S ${BASE_PKGS[*]} ${loginpkg[*]} $NEWSHELL --noconfirm --needed" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -S ${BASE_PKGS[*]} ${loginpkg[*]} $NEWSHELL --noconfirm --needed'"
if [[ $PACSTRAP == 1 ]]; then
chrun "pacman -S ${ISO_PKGS[*]} --noconfirm --needed" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -S ${ISO_PKGS[*]} --noconfirm --needed'"
fi
# reinstalling iputils fixes the network issue for non-root users
chrun "pacman -S iputils $UCODE $KERNEL --noconfirm"
# remove the packages we don't want on the installed system
[[ $rmpkg ]] && chrun "pacman -Rnsc $rmpkg --noconfirm"
[[ ${rmpkg[*]} ]] && chrun "pacman -Rnsc ${rmpkg[*]} --noconfirm"
# install the packages chosen throughout the install
chrun "pacman -S $inpkg --needed --noconfirm" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -S $inpkg --needed --noconfirm'"
chrun "pacman -S ${inpkg[*]} --needed --noconfirm" 2> "$ERR" 2>&1
errshow 1 "chrun 'pacman -S ${inpkg[*]} --needed --noconfirm'"
# bootloader packages
if [[ $BOOTLDR == 'grub' ]]; then
@ -1679,8 +1725,9 @@ install_background()
PACSTRAP=1
(
install_mirrorlist "/etc/pacman.d/mirrorlist" > /tmp/bgout 2>&1 &&
pacstrap /mnt $BASE_PKGS > /tmp/bgout 2>&1 &&
pacstrap /mnt ${BASE_PKGS[*]} > /tmp/bgout 2>&1 &&
cp /etc/pacman.d/mirrorlist "$MNT/etc/pacman.d/mirrorlist"
cp /etc/pacman.conf "$MNT/etc/pacman.conf"
al_repo "$MNT/etc/pacman.conf"
chrun "systemctl enable NetworkManager.service" > /tmp/bgout 2>&1
) &
@ -1691,7 +1738,7 @@ install_background()
rsync -a /run/archiso/sfs/airootfs/ "$MNT/" &&
install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" > /tmp/bgout 2>&1 &&
al_repo "$MNT/etc/pacman.conf" &&
chrun "pacman -Sy && pacman -Syyu $BASE_PKGS --noconfirm --needed" > /tmp/bgout 2>&1
chrun "pacman -Sy && pacman -Syyu ${BASE_PKGS[*]} --noconfirm --needed" > /tmp/bgout 2>&1
) &
BG_PID=$!
fi
@ -2410,10 +2457,11 @@ live()
al_repo "/etc/pacman.conf"
pacman -Syyu --noconfirm || die 1
rm -rf /var/cache/pacman/pkg/*
pacman -S ${BASE_PKGS/base-devel /} $AL_BASE_PKGS xorg-xinit --needed --noconfirm || die 1
local pkgs="${BASE_PKGS[*]}"
pacman -S ${pkgs/base-devel /} ${AL_PKGS[*]} xorg-xinit --needed --noconfirm || die 1
rm -rf /var/cache/pacman/pkg/*
case "$ses" in
$WM_PKG_SES) pacman -S "$ses" $WM_BASE_PKGS ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;;
$WM_PKG_SES) pacman -S "$ses" ${WM_PKGS[*]} ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;;
$SELF_CONTAINED) pacman -S "$ses" ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;;
dwm) { pacman -S git --needed --noconfirm || die 1; }; install_suckless "/root" nochroot ;;
esac