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 ;; usage_uninstall; exit 0 ;;
update) update)
usage_update; exit 0 ;; usage_update; exit 0 ;;
update-all)
usage_update_all; exit 0 ;;
esac esac
if [ ! -z "$1" ]; then if [ ! -z "$1" ]; then
echo -e "Unknown command: $1 \n" echo -e "Unknown command: $1 \n"
@ -22,6 +24,7 @@ usage () {
echo "Commands:" echo "Commands:"
echo " install - installs a new AUR package, no-op if already installed" 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 - 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 " uninstall - uninstalls an AUR package"
echo "" echo ""
echo "Options:" echo "Options:"
@ -80,6 +83,20 @@ usage_update () {
echov "" 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=() POSITIONAL=()
QUICK= QUICK=
HELP=0 HELP=0
@ -182,6 +199,13 @@ update() {
cd $LOC cd $LOC
} }
update-all() {
PACKAGES=$(pacman -Qm)
for PAK in $PACKAGES; do
update $PAK
done
}
uninstall() { uninstall() {
if [ ! "$PACKAGE" = "pacman -Qm $PACKAGE" ]; then if [ ! "$PACKAGE" = "pacman -Qm $PACKAGE" ]; then
echo "$PACKAGE is not installed!" echo "$PACKAGE is not installed!"
@ -197,7 +221,7 @@ uninstall() {
fi fi
} }
if [ -z "$PACKAGE" ]; then if [ -z "$PACKAGE" ] && [ "$COMMAND" != "update-all" ]; then
echo "Missing package name!" echo "Missing package name!"
exit 1 exit 1
fi fi
@ -215,6 +239,9 @@ case $COMMAND in
update) update)
update update
;; ;;
update-all)
update-all
;;
uninstall) uninstall)
uninstall uninstall
;; ;;

View File

@ -13,24 +13,7 @@ then
sudo pacman -Syu sudo pacman -Syu
# Update AUR packages # Update AUR packages
LOC=$PWD aurfetch update-all -q
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
fi fi
if type apt > /dev/null 2>&1 if type apt > /dev/null 2>&1