Add update-all command to aurfetch

main
Ensar Sarajčić 2022-05-09 18:02:15 +02:00
parent f80a2062a7
commit 654397e176
2 changed files with 29 additions and 19 deletions

View File

@ -12,6 +12,8 @@ usage () {
usage_uninstall; exit 0 ;;
update)
usage_update; exit 0 ;;
update-all)
usage_update_all; exit 0 ;;
esac
if [ ! -z "$1" ]; then
echo -e "Unknown command: $1 \n"
@ -22,6 +24,7 @@ usage () {
echo "Commands:"
echo " install - installs a new AUR package, no-op if already installed"
echo " update - updates a previously installed AUR package, fails if not found"
echo " update-all - updates all previously installed AUR package"
echo " uninstall - uninstalls an AUR package"
echo ""
echo "Options:"
@ -80,6 +83,20 @@ usage_update () {
echov ""
}
usage_update_all () {
echo "Aurfetch Update-all"
echo "Updates all installed AUR package."
echo -e "\nUsage: aurfetch update-all [options]\n"
echo ""
echo "Options:"
echo " -q --quick - skips diff previews"
echo " -h --help - prints this help message"
echo " -v --verbose - enables verbose logging"
echov "Examples:"
echov " > aurfetch update-all"
echov ""
}
POSITIONAL=()
QUICK=
HELP=0
@ -182,6 +199,13 @@ update() {
cd $LOC
}
update-all() {
PACKAGES=$(pacman -Qm)
for PAK in $PACKAGES; do
update $PAK
done
}
uninstall() {
if [ ! "$PACKAGE" = "pacman -Qm $PACKAGE" ]; then
echo "$PACKAGE is not installed!"
@ -197,7 +221,7 @@ uninstall() {
fi
}
if [ -z "$PACKAGE" ]; then
if [ -z "$PACKAGE" ] && [ "$COMMAND" != "update-all" ]; then
echo "Missing package name!"
exit 1
fi
@ -215,6 +239,9 @@ case $COMMAND in
update)
update
;;
update-all)
update-all
;;
uninstall)
uninstall
;;

View File

@ -13,24 +13,7 @@ then
sudo pacman -Syu
# Update AUR packages
LOC=$PWD
cd $AUR_INSTALL_HOME
for folder in *; do
cd $folder;
echo "Working in $PWD.";
if [ -z "$(ls -a | grep -w .git)" ]; then
echo "$folder is not a git directory!";
else
if [ "$(git pull)" == "Already up to date." ]; then
echo "Package $folder is up to date.";
else
makepkg -si
fi
fi
cd ..;
done
cd $LOC
aurfetch update-all -q
fi
if type apt > /dev/null 2>&1