From 654397e17697e11e1393c7679a51bef113dffe1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Mon, 9 May 2022 18:02:15 +0200 Subject: [PATCH] Add update-all command to aurfetch --- symlinks/bin/aurfetch | 29 ++++++++++++++++++++++++++++- symlinks/bin/update-all-packages | 19 +------------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/symlinks/bin/aurfetch b/symlinks/bin/aurfetch index 1de4752..1dead45 100755 --- a/symlinks/bin/aurfetch +++ b/symlinks/bin/aurfetch @@ -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 ;; diff --git a/symlinks/bin/update-all-packages b/symlinks/bin/update-all-packages index 6deed41..d46b9cb 100755 --- a/symlinks/bin/update-all-packages +++ b/symlinks/bin/update-all-packages @@ -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