Enable use of categories for packages

This commit is contained in:
Petar Kapriš 2025-04-23 14:36:45 +02:00
parent da2aa65f7c
commit e8ac82955e

66
bs.sh
View file

@ -130,6 +130,43 @@ usercheck() {
--yesno "The user \`$name\` already exists on this system. LARBS can install for a user already existing.\\n\\nLARBS will change $name's password to the one you just gave." 14 70
}
selectcategories() {
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) ||
curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv
selectedcats=$(whiptail --title "Select package categories" --separate-output \
--checklist "Categories" 20 100 12 \
"amd" "AMD specific packages" ON \
"anki" "Anki" ON \
"backup" "Packages for backing the system up (borg)" ON \
"crypto" "Cryptocurrencies" ON \
"cysec" "Packages i use for my work in Cybersecurity" ON \
"dumb" "silly things I like to have" ON \
"editing" "Audio/video editing" ON \
"electronics" "Packages used for electronics and FPGA work" ON \
"fonts" "Fonts" ON \
"go" "Packages for work with golang" ON \
"gui" "Packages needed for my GUI and dotfiles to work" ON \
"haskell" "Haskell and things needed for it" ON \
"latex" "LaTeX" ON \
"lisp" "All sorts of Lisps" ON \
"lowlev" "Packages for programming in low-level languages (C,C++,Rust,etc)" ON \
"mail" "Mail client and related programs" ON \
"matrix" "Matrix clients" ON \
"ml" "Machine learning" ON \
"office" "Office packages" ON \
"passwords" "Password manager and related" ON \
"python" "Packages for python programming" ON \
"retro" "Retrocomputing" ON \
"rss" "RSS" ON \
"stats" "Statistics (R)" ON \
"system" "Packages I expect on my system" ON \
"tcl" "Tcl/Tk and related" ON \
"torrent" "Torrent clients" ON \
"virtual" "Virtual machine packages" ON \
"webdev" "Web-development" ON \
"www" "Browsers" ON 3>&1 1>&2 2>&3 3>&1) || exit 1
}
preinstallmsg() {
whiptail --title "Let's get this party started!" --yes-button "Let's go!" \
--no-button "No, nevermind!" \
@ -193,15 +230,31 @@ manualinstall() {
}
maininstallations() {
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) ||
curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv
total=$(wc -l </tmp/progs.csv)
aurinstalled=$(pacman -Qqm)
# Field 1: install-type, Field 2: program, Field 3: comment
# Install pacman packages:
pacman --noconfirm -Rnd vim # Remove vim as it will conflict with gvim
awk -F "," '$1 ~ /^$/ { print $2 }' </tmp/progs.csv | xargs pacman --noconfirm --needed -S
awk -F "," '$1 ~ /^A$/ { print $2 }' </tmp/progs.csv | xargs sudo -u "$name" "$aurhelper" --noconfirm --needed -S
awk -F',' -v tags="${selectedcats}" '
BEGIN {
# Convert selectedcats string to an array in awk
n = split(tags, sel_cats, " ");
for (i = 1; i <= n; i++) {
selected[sel_cats[i]] = 1;
}
}
{
# Assuming tags are in the 3rd column
split($3, tag_list, "-");
for (i in tag_list) {
if (tag_list[i] in selected) {
print $0;
next;
}
}
}' /tmp/progs.csv >/tmp/filtered-progs.csv
awk -F "," '$1 ~ /^$/ { print $2 }' </tmp/filtered-progs.csv | xargs pacman --noconfirm --needed -S
awk -F "," '$1 ~ /^A$/ { print $2 }' </tmp/filtered-progs.csv | xargs sudo -u "$name" "$aurhelper" --noconfirm --needed -S
}
finalize() {
@ -226,6 +279,9 @@ getuserandpass || error "User exited."
# Give warning if user already exists.
usercheck || error "User exited."
# Select package categories to install
selectcategories || error "User exited."
# Last chance for user to back out before install.
preinstallmsg || error "User exited."