From 4f3f9b8f036e8387b3f4becc76ac9646de0965f7 Mon Sep 17 00:00:00 2001 From: natemaia Date: Tue, 19 Mar 2019 00:22:06 -0700 Subject: [PATCH] Fix: package install syntax error --- archlabs-installer | 102 +++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 09c8dde..d307853 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,7 +5,7 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due -VER="2.0.27" # version +VER="2.0.28" # version DIST="ArchLabs" # distributor MNT="/mnt" # mountpoint ANS="/tmp/ans" @@ -91,12 +91,11 @@ AUTO_BOOT_PART='' # boot value from auto partition # iso base, pacstrap when running the installer from a stock arch iso ISO_BASE="arch-install-scripts b43-firmware b43-fwcutter broadcom-wl clonezilla dhclient dhcpcd ethtool " ISO_BASE+="exfat-utils f2fs-tools gptfdisk vim hdparm ipw2100-fw ipw2200-fw nfs-utils nilfs-utils ntfs-3g " -ISO_BASE+="pacman-contrib parted rsync sdparm smartmontools wget wireless_tools wpa_actiond xl2tpd dialog " -ISO_BASE+="parted alsa-firmware alsa-lib alsa-plugins pulseaudio pulseaudio-alsa networkmanager " -ISO_BASE+="wireless-regdb wpa_supplicant lm_sensors lsb-release p7zip pamixer reflector unrar htop ranger " -ISO_BASE+="w3m terminus-font ttf-dejavu archlabs-keyring" +ISO_BASE+="pacman-contrib parted rsync sdparm smartmontools wget wireless_tools wpa_actiond xl2tpd dialog parted " +ISO_BASE+="alsa-firmware alsa-lib alsa-plugins pulseaudio pulseaudio-alsa networkmanager w3m htop wireless-regdb " +ISO_BASE+="wpa_supplicant lm_sensors lsb-release p7zip pamixer reflector unrar ranger terminus-font ttf-dejavu archlabs-keyring" -# baseline +# baseline (usually installed in the background) BASE_PKGS="archlabs-skel-base archlabs-themes archlabs-dARK archlabs-icons archlabs-wallpapers " BASE_PKGS+="base-devel xorg xorg-drivers sudo git gvfs gtk3 gtk-engines gtk-engine-murrine pavucontrol tumbler " BASE_PKGS+="playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-base gst-plugins-good scrot" @@ -363,7 +362,7 @@ select_show() { local mnt="none" local cmd="${BCMDS[$BOOTLDR]}" - local pkgs="$USER_PKGS $PACKAGES" + local pkgs="${USER_PKGS// / } ${PACKAGES// / }" [[ $BOOT_PART ]] && mnt="/$BOOTDIR" [[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu $pkgs" msg "Show Configuration" " @@ -486,8 +485,8 @@ select_config() select_mkuser() { - local v='' u='' p='' p2='' rp='' rp2='' NEWUSER='' + local v='' u='' p='' p2='' rp='' rp2='' until [[ $NEWUSER ]]; do i=0 @@ -602,11 +601,9 @@ select_sessions() select_login || return 1 - # add unique wm packages to main package list - for i in $WM_PKGS; do - [[ $PACKAGES == *$i* ]] || PACKAGES+=" ${i# }" - done - + while IFS=' ' read -r pkg; do + [[ $PACKAGES != *"$pkg"* ]] && PACKAGES+=" $pkg" + done <<< "$WM_PKGS" return 0 } @@ -1240,21 +1237,13 @@ select_boot_partition() select_root_partition() { - typeset -i num - local pts - pts="$(awk '/[0-9.]*[GT]$/ {sub(/[GT]$/, ""); if ($2 > 8) {print $0 "G"} }' <<< "$PARTS")" - while read -r line; do - (( num++ )) - done <<< "$pts" - if [[ $AUTO_ROOT_PART && ! $LVM && ! $LUKS ]]; then ROOT_PART="$AUTO_ROOT_PART" - elif (( num == 1 )); then - ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")" + elif (( COUNT == 1 )); then + ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$PARTS")" else - dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts + dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $PARTS fi - [[ $ROOT_PART ]] || return 1 select_filesystem "$ROOT_PART" || { ROOT_PART=''; return 1; } @@ -1337,9 +1326,7 @@ install_base() { if [[ $RSYNC_PID || $MIRROR_PID ]]; then while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do - clear - printf "\nBackground install process is currently running...\n" - sleep 1 + clear; printf "\nOne or more background install processes are still running...\n"; sleep 1 done trap - EXIT unset RSYNC_PID MIRROR_PID @@ -1347,8 +1334,7 @@ install_base() rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR errshow 1 "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/" install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" - chrun "pacman -Syyu --noconfirm" - chrun "pacman -S $BASE_PKGS --needed --noconfirm" + chrun "pacman -Syyu --noconfirm && pacman -S $BASE_PKGS --needed --noconfirm" else mkdir -p /etc/pacman.d/mirrorlist install_mirrorlist "/etc/pacman.d/mirrorlist" @@ -1356,14 +1342,12 @@ install_base() errshow 1 "pacstrap $MNT base $KERNEL $ISO_BASE" mkdir -p $MNT/etc/pacman.d/mirrorlist cp -f "/etc/pacman.d/mirrorlist" "$MNT/etc/pacman.d/mirrorlist" - chrun "pacman -Syyu --noconfirm" - chrun "pacman -S $BASE_PKGS --needed --noconfirm" + chrun "pacman -Syyu --noconfirm && pacman -S $BASE_PKGS --needed --noconfirm" fi rm -rf $MNT/etc/mkinitcpio-archiso.conf find $MNT/usr/lib/initcpio -name 'archiso*' -type f -delete sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf - find $MNT/boot -name '*-ucode.img' -delete if [[ $VM ]]; then @@ -1565,10 +1549,8 @@ install_lightdm() { rm -rf $SERVICE rm -rf $MNT/home/$NEWUSER/.{xinitrc,profile,zprofile,bash_profile} - chrun 'systemctl set-default graphical.target' 2>$ERR - errshow 1 "systemctl set-default graphical.target" - chrun 'systemctl enable lightdm.service' 2>$ERR - errshow 1 "systemctl enable lightdm.service" + chrun 'systemctl set-default graphical.target && systemctl enable lightdm.service' 2>$ERR + errshow 1 "systemctl set-default graphical.target && systemctl enable lightdm.service" cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF # LightDM GTK+ Configuration @@ -1594,37 +1576,35 @@ install_packages() rm -f "$MNT/usr/bin/archlabs-installer" fi - [[ $UCODE ]] && inpkg+="$UCODE" + [[ $UCODE ]] && inpkg+=" $UCODE" [[ $MYSHELL == *mksh ]] && inpkg+=" mksh" [[ $KERNEL == 'linux' ]] || { inpkg+=" $KERNEL"; rmpkg+=" linux"; } - - # add xterm when not installing a terminal emulator or de that provides one [[ $inpkg =~ (term|urxvt|tilix|alacritty|sakura|tilda|plasma|cinnamon) || $INSTALL_WMS == *dwm* ]] || inpkg+=" xterm" - [[ $MYSHELL == '/usr/bin/zsh' ]] && inpkg+=" zsh-completions" [[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey" [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm|fluxbox) ]] && inpkg+=" $WM_BASE_PKGS" - chrun "pacman -Syyu --noconfirm" - if [[ $rmpkg ]]; then - chrun "pacman -Rns $rmpkg --noconfirm" - fi + [[ $rmpkg ]] && chrun "pacman -Rns $rmpkg --noconfirm" chrun "pacman -S iputils --noconfirm" - chrun "pacman -S $inpkg --needed --noconfirm" + chrun "pacman -S $inpkg --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S $inpkg --needed --noconfirm" if [[ $BOOTLDR == 'grub' ]]; then if [[ $SYS == 'BIOS' ]]; then - chrun "pacman -S grub os-prober --needed --noconfirm" + chrun "pacman -S grub os-prober --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S grub os-prober --needed --noconfirm" else - chrun "pacman -S grub os-prober efibootmgr --needed --noconfirm" + chrun "pacman -S grub os-prober efibootmgr --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S grub os-prober efibootmgr --needed --noconfirm" fi elif [[ $BOOTLDR == 'refind-efi' ]]; then - chrun "pacman -S refind-efi efibootmgr --needed --noconfirm" + chrun "pacman -S refind-efi efibootmgr --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S refind-efi efibootmgr --needed --noconfirm" elif [[ $SYS == 'UEFI' ]]; then - chrun "pacman -S efibootmgr --needed --noconfirm" + chrun "pacman -S efibootmgr --needed --noconfirm" 2>$ERR + errshow 1 "pacman -S efibootmgr --needed --noconfirm" fi - sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers return 0 } @@ -1683,10 +1663,10 @@ install_mirrorlist() install_background() { if [[ -d /run/archiso/sfs/airootfs/etc/skel ]] && grep -qw "$MNT" /proc/mounts && (grep -qw "$MNT/$BOOTDIR" /proc/mounts || [[ $SYS == 'BIOS' && -z $LUKS ]]); then - yesno "Background Install" "\nSome slower steps of the install can be done in the background before other configuration is needed, base system unpack, mirrorlist sort, updates, and base packages.\n\nThis will allow you to continue setting up the configuration and proceed at your own pace, while the installer is working.\n\nDo you want to use/start the background process?\n" || return 0 + yesno "Background Install" "\nSome parts of the install can be done in the background now, base unpack, mirrorlist sort, system update, and base packages.\n\nDo you want to start the background process?\n" || return 0 rsync -a /run/archiso/sfs/airootfs/ $MNT/ & RSYNC_PID=$! - ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" && chrun "pacman -Syyu --noconfirm && pacman -S $BASE_PKGS --needed --noconfirm" ) >/dev/null 2>&1 & + ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" && chrun "pacman -Syyu $BASE_PKGS --needed --noconfirm" ) >/dev/null 2>&1 & MIRROR_PID=$! trap "kill $RSYNC_PID 2>/dev/null; kill $MIRROR_PID 2>/dev/null" EXIT fi @@ -1756,7 +1736,6 @@ prerun_efistub() BCMDS[systemd-boot]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars >/dev/null 2>&1 efibootmgr -v -d $BOOT_DEV -p $BOOT_PART_NUM -c -L '${DIST} Linux' -l /vmlinuz-${KERNEL} \ -u 'root=$ROOT_PART_ID rw $([[ $UCODE ]] && printf 'initrd=\%s.img ' "$UCODE")initrd=\initramfs-${KERNEL}.img'" - return 0 } @@ -2292,6 +2271,7 @@ die() { local exitcode="$1" trap - INT + trap - TSTP tput cnorm if [[ -d $MNT ]] && command cd /; then umount_dir $MNT @@ -2390,6 +2370,19 @@ sigint() die 1 } +sigtstp() +{ + printf "\n^Z caught, cleaning up before backgrounding...\n" + tput cnorm + if [[ $TERM == 'linux' ]]; then + colors=("\e]P0191919" "\e]P1D15355" "\e]P2609960" "\e]P3FFCC66" + "\e]P4255A9B" "\e]P5AF86C8" "\e]P62EC8D3" "\e]P7949494" "\e]P8191919" "\e]P9D15355" + "\e]PA609960" "\e]PBFF9157" "\e]PC4E88CF" "\e]PDAF86C8" "\e]PE2ec8d3" "\e]PFE1E1E1") + printf "%b" "${colors[@]}" && clear && unset col + fi + kill -s TSTP $$ # pass through the signal +} + print4() { local str="$*" @@ -2565,7 +2558,8 @@ elif [[ $1 =~ (-d|--debug) ]]; then debug fi -trap sigint INT +trap sigint INT # ^C trap cleanup +trap sigtstp TSTP # ^Z trap cleanup system_identify system_devices