2020-04-01 02:42:36 +02:00
|
|
|
#!/usr/bin/env bash
|
2020-08-17 12:49:56 +02:00
|
|
|
clean=false
|
|
|
|
fetch=false
|
2020-04-01 02:42:36 +02:00
|
|
|
minimal=false
|
|
|
|
noconfirm=false
|
2020-08-17 12:49:56 +02:00
|
|
|
pull=false
|
|
|
|
update=false
|
|
|
|
verbose=false
|
2020-04-01 02:42:36 +02:00
|
|
|
|
|
|
|
for arg in "$@"; do
|
2020-08-17 12:49:56 +02:00
|
|
|
if [[ $arg == "-c" ]] || [[ $arg == "--clean" ]]; then
|
|
|
|
clean=true
|
|
|
|
elif [[ $arg == "-f" ]] || [[ $arg == "--fetch" ]]; then
|
|
|
|
fetch=true
|
2020-04-01 02:42:36 +02:00
|
|
|
elif [[ $arg == "-m" ]] || [[ $arg == "--minimal" ]]; then
|
|
|
|
minimal=true
|
|
|
|
elif [[ $arg == "--noconfirm" ]]; then
|
|
|
|
noconfirm=true
|
2020-08-17 12:49:56 +02:00
|
|
|
elif [[ $arg == "--pull" ]]; then
|
|
|
|
pull=true
|
|
|
|
elif [[ $arg == "-u" ]] || [[ $arg == "--update" ]]; then
|
|
|
|
update=true
|
|
|
|
elif [[ $arg == "-v" ]] || [[ $arg == "--verbose" ]]; then
|
|
|
|
verbose=true
|
2020-04-01 02:42:36 +02:00
|
|
|
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:
|
2020-08-17 12:49:56 +02:00
|
|
|
-c, --clean Do 'git reset HEAD --hard' and 'git clean -fdx'.
|
|
|
|
-f, --fetch Fetch the latest change from the upstream repos.
|
2020-04-01 02:42:36 +02:00
|
|
|
-m, --minimal Only show directories in need for an update.
|
2020-08-17 12:49:56 +02:00
|
|
|
-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."
|
2020-04-01 02:42:36 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for dir in *; do
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
cd $dir
|
2020-08-17 12:49:56 +02:00
|
|
|
if $fetch; then
|
|
|
|
if $verbose; then
|
|
|
|
git fetch --all
|
|
|
|
else
|
|
|
|
git fetch --all --quiet
|
|
|
|
fi
|
2020-04-01 02:42:36 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
BEHIND=$(git rev-list HEAD...origin/master --count)
|
|
|
|
if [[ $BEHIND -eq 0 ]]; then
|
|
|
|
if ! $minimal; then
|
|
|
|
echo "[ ] $(pwd) is up to date"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "[X] $(pwd) is $BEHIND commits behind"
|
|
|
|
|
|
|
|
if $update; then
|
2020-08-17 12:49:56 +02:00
|
|
|
if $pull; then
|
|
|
|
if $verbose; then
|
|
|
|
git pull --all
|
|
|
|
else
|
|
|
|
git pull --all --quiet
|
|
|
|
fi
|
2020-04-01 02:42:36 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if $noconfirm; then
|
|
|
|
if $verbose; then
|
|
|
|
makepkg -si --noconfirm
|
|
|
|
else
|
|
|
|
makepkg -si --noconfirm > /dev/null
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if $verbose; then
|
|
|
|
makepkg -si
|
|
|
|
else
|
|
|
|
makepkg -si > /dev/null
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-17 12:49:56 +02:00
|
|
|
fi
|
|
|
|
fi
|
2020-04-01 02:42:36 +02:00
|
|
|
|
2020-08-17 12:49:56 +02:00
|
|
|
if $clean; then
|
|
|
|
if $verbose; then
|
|
|
|
git reset HEAD --hard
|
|
|
|
git clean -fdx
|
|
|
|
else
|
|
|
|
git reset HEAD --hard --quiet
|
|
|
|
git clean -fdx --quiet
|
2020-04-01 02:42:36 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
done
|