From 887a5a9b5ab5c3efce274f162e63ccac5a617830 Mon Sep 17 00:00:00 2001 From: DustVoice Date: Mon, 17 Aug 2020 12:49:56 +0200 Subject: [PATCH] Update AUR/update with new functionality --- .ssh/known_hosts | 1 + AUR/update | 66 ++++++++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/.ssh/known_hosts b/.ssh/known_hosts index 3ddef7e..7676e3c 100644 --- a/.ssh/known_hosts +++ b/.ssh/known_hosts @@ -5,3 +5,4 @@ pc.dustvoice.de ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAy git.rwth-aachen.de,134.130.122.52 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIcyEfZ5DqwZFMd2XKFt3XDb07T0/qjdtOfnoXgOlUjBWK0BLbhA787VjyzoDrWrgNrb1/xEyTqGdP0hWRMiXMU= ssh.strato.de,81.169.145.126 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDazQi5TwecOL29s5HbSoAgLCu+YqKV9kqWlYRtwmaXVgR9fB/pFTf5Nnx7EfkZy4B/Ue2EWYdKOOQnAUpx4uUI= aur.archlinux.org,95.216.144.15 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= +2a01:4f9:c010:50::1 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= diff --git a/AUR/update b/AUR/update index 29af05c..2348971 100755 --- a/AUR/update +++ b/AUR/update @@ -1,26 +1,38 @@ #!/usr/bin/env bash -verbose=false +clean=false +fetch=false minimal=false -update=false noconfirm=false +pull=false +update=false +verbose=false for arg in "$@"; do - if [[ $arg == "-v" ]] || [[ $arg == "--verbose" ]]; then - verbose=true + if [[ $arg == "-c" ]] || [[ $arg == "--clean" ]]; then + clean=true + elif [[ $arg == "-f" ]] || [[ $arg == "--fetch" ]]; then + fetch=true elif [[ $arg == "-m" ]] || [[ $arg == "--minimal" ]]; then minimal=true - elif [[ $arg == "-u" ]] || [[ $arg == "--update" ]]; then - update=true elif [[ $arg == "--noconfirm" ]]; then noconfirm=true + elif [[ $arg == "--pull" ]]; then + pull=true + elif [[ $arg == "-u" ]] || [[ $arg == "--update" ]]; then + update=true + elif [[ $arg == "-v" ]] || [[ $arg == "--verbose" ]]; then + verbose=true elif [[ $arg == "-h" ]] || [[ $arg == "--help" ]]; then echo "Helper script for the AUR directory, which tells you what packages need an update. Usage: ./update.sh [options] Options: --v, --verbose Don't suppress the output of any command run within the script. +-c, --clean Do 'git reset HEAD --hard' and 'git clean -fdx'. +-f, --fetch Fetch the latest change from the upstream repos. -m, --minimal Only show directories in need for an update. --u, --update If an update is needed, pull the new updates, 'makepkg -si' and afterwards 'git reset HEAD --hard' and 'git clean -fdx'. - --noconfirm Pass the --noconfirm option to 'makepkg -si', if using the -u/--update option" +-u, --update If an update is needed, 'makepkg -si'. + --noconfirm Pass the --noconfirm option to 'makepkg -si', if using the -u/--update option + --pull Pull the latest changes from the repo before running any command. Note that this might fail! +-v, --verbose Don't suppress the output of any command run within the script." exit 0 fi done @@ -28,10 +40,12 @@ done for dir in *; do if [ -d "$dir" ]; then cd $dir - if $verbose; then - git fetch --all - else - git fetch --all > /dev/null + if $fetch; then + if $verbose; then + git fetch --all + else + git fetch --all --quiet + fi fi BEHIND=$(git rev-list HEAD...origin/master --count) @@ -43,10 +57,12 @@ for dir in *; do echo "[X] $(pwd) is $BEHIND commits behind" if $update; then - if $verbose; then - git pull --all - else - git pull --all > /dev/null + if $pull; then + if $verbose; then + git pull --all + else + git pull --all --quiet + fi fi if $noconfirm; then @@ -62,14 +78,16 @@ for dir in *; do makepkg -si > /dev/null fi fi + fi + fi - if $verbose; then - git reset HEAD --hard - git clean -fdx - else - git reset HEAD --hard > /dev/null - git clean -fdx > /dev/null - fi + if $clean; then + if $verbose; then + git reset HEAD --hard + git clean -fdx + else + git reset HEAD --hard --quiet + git clean -fdx --quiet fi fi