Skip to content

Instantly share code, notes, and snippets.

@SalvatoreNoschese
Last active March 24, 2024 12:29
Show Gist options
  • Save SalvatoreNoschese/278418b0f424510e6b82cb7d21668eb0 to your computer and use it in GitHub Desktop.
Save SalvatoreNoschese/278418b0f424510e6b82cb7d21668eb0 to your computer and use it in GitHub Desktop.
# Lista i file AUR
aurlist() { (echo -e "~\nQuesti i pacchetti aur Installati:\n~"; pacman -Qm; echo "~") }
# Installa pacchetto AUR
aurinstall() {
cd "$HOME" && mkdir -p "$HOME/AurBuild/"
(
cd "$HOME/AurBuild/"
# Controlla se l'utente ha passato un argomento
if [ $# -eq 0 ]; then
echo -e "~\nErrore: specificare l'URL del pacchetto AUR da installare.\n~"
else
# Verifica se la directory di destinazione esiste già
package_dir="$(basename "$1" .git)"
if [ -d "$package_dir" ]; then
echo -e "~\nErrore: La directory '$package_dir' esiste già e non è vuota.\n~\nUsare 'aurupdate $package_dir'\n~"
else
# Clona il repository AUR e installa il pacchetto
git clone "$1" && cd "$package_dir"
if [[ -f PKGBUILD ]]; then
(echo -e "~\nLeggi il PKGBUILD prima di continuare!!!\n~"; cat PKGBUILD; echo -e "~\nSe hai letto il PKGBUILD e vuoi procedere, premi 'q'\n~") | less
makepkg -si
else
echo -e "~\nErrore: Il repository AUR clonato non contiene un file PKGBUILD.\n~"
fi
fi
fi
)
}
# Aggiornare gli AUR
aurupdate() {
cd "$HOME" && mkdir -p "$HOME/AurBuild/"
(
cd "$HOME/AurBuild/"
# Se non ci sono argomenti, aggiorna tutti i pacchetti
if [ $# -eq 0 ]; then
echo "Aggiorno tutti i pacchetti AUR presenti!"
for package_dir in */; do
echo "Aggiornamento del pacchetto: $package_dir"
cd "$package_dir" || continue
git pull
(echo -e "~\nLeggi il PKGBUILD prima di continuare!!!\n~"; cat PKGBUILD; echo -e "~\nSe hai letto il PKGBUILD e vuoi procedere, premi 'q'\n~") | less
makepkg -si
cd ..
done
else
# Altrimenti, aggiorna solo i pacchetti specificati
for package_name in "$@"; do
if [ -d "$package_name" ]; then
echo "Aggiornamento del pacchetto: $package_name"
cd "$package_name" || continue
git pull
(echo -e "~\nLeggiaur_dir il PKGBUILD prima di continuare!!!\n~"; cat PKGBUILD; echo -e "~\nSe hai letto il PKGBUILD e vuoi procedere, premi 'q'\n~") | less
makepkg -si
cd ..
else
echo -e "~\nIl pacchetto $package_name non esiste in '$HOME/AurBuild/'\n~"
fi
done
fi
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment