Replace install loops with singular commands

This commit is contained in:
Petar Kapriš 2025-04-20 21:53:52 +02:00
parent 7a6febe2ef
commit c219859dbb

38
bs.sh
View file

@ -191,33 +191,15 @@ manualinstall() {
makepkg --noconfirm -si >/dev/null 2>&1 || return 1 makepkg --noconfirm -si >/dev/null 2>&1 || return 1
} }
maininstall() { maininstallations() {
# Installs all needed programs from main repo.
whiptail --title "LARBS Installation" --infobox "Installing \`$1\` ($n of $total). $1 $2" 9 70
installpkg "$1"
}
aurinstall() {
whiptail --title "LARBS Installation" \
--infobox "Installing \`$1\` ($n of $total) from the AUR. $1 $2" 9 70
echo "$aurinstalled" | grep -q "^$1$" && return 1
sudo -u "$name" $aurhelper -S --noconfirm "$1" >/dev/null 2>&1
}
installationloop() {
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) || ([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) ||
curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv
total=$(wc -l </tmp/progs.csv) total=$(wc -l </tmp/progs.csv)
aurinstalled=$(pacman -Qqm) aurinstalled=$(pacman -Qqm)
while IFS=, read -r tag program comment; do # Field 1: install-type, Field 2: program, Field 3: comment
n=$((n + 1)) # Install pacman packages:
echo "$comment" | grep -q "^\".*\"$" && awk '$1 ~ /^$/ { print $2 }' | xargs pacman --noconfirm --needed -S </tmp/progs.csv
comment="$(echo "$comment" | sed -E "s/(^\"|\"$)//g")" awk '$1 ~ /^A$/ { print $2 }' | xargs "$aurhelper" --noconfirm --needed -S </tmp/progs.csv
case "$tag" in
"A") aurinstall "$program" "$comment" ;;
*) maininstall "$program" "$comment" ;;
esac
done </tmp/progs.csv
} }
finalize() { finalize() {
@ -251,11 +233,9 @@ preinstallmsg || error "User exited."
refreshkeys || refreshkeys ||
error "Error automatically refreshing Arch keyring. Consider doing so manually." error "Error automatically refreshing Arch keyring. Consider doing so manually."
for x in curl ca-certificates base-devel git ntp zsh dash; do whiptail --title "LARBS Installation" \
whiptail --title "LARBS Installation" \ --infobox "Installing software required to install and configure other programs." 8 70
--infobox "Installing \`$x\` which is required to install and configure other programs." 8 70 pacman --noconfirm --needed -S curl ca-certificates base-devel git ntp zsh dash
installpkg "$x"
done
whiptail --title "LARBS Installation" \ whiptail --title "LARBS Installation" \
--infobox "Synchronizing system time to ensure successful and secure installation of software..." 8 70 --infobox "Synchronizing system time to ensure successful and secure installation of software..." 8 70
@ -287,7 +267,7 @@ $aurhelper -Y --save --devel
# installs each needed program the way required. Be sure to run this only after # installs each needed program the way required. Be sure to run this only after
# the user has been created and has priviledges to run sudo without a password # the user has been created and has priviledges to run sudo without a password
# and all build dependencies are installed. # and all build dependencies are installed.
installationloop maininstallations
# Most important command! Get rid of the beep! # Most important command! Get rid of the beep!
rmmod pcspkr rmmod pcspkr