59 lines
1.0 KiB
Bash
Executable File
59 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
shopt -s dotglob
|
|
|
|
root_dir="/aur"
|
|
|
|
display_help() {
|
|
echo "Usage: $0 [option...] " >&2
|
|
echo
|
|
echo " -r, root directory, every subdir with a \".git\" directory inside is treated as an aur repo [default: $root_dir]"
|
|
echo " -h, display this help and exit"
|
|
echo
|
|
}
|
|
|
|
parse_args() {
|
|
while getopts ":hr:" opt; do
|
|
case $opt in
|
|
h)
|
|
display_help
|
|
exit 0
|
|
;;
|
|
r)
|
|
root_dir=$OPTARG
|
|
;;
|
|
\?)
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
display_help
|
|
exit 1
|
|
;;
|
|
:)
|
|
echo "Option -$OPTARG requires an argument." >&2
|
|
display_help
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
update() {
|
|
for d in "$@"/*; do
|
|
echo "checking $d..."
|
|
test -d "$d" -a \! -L "$d" || continue
|
|
cd "$d"
|
|
if [ -d ".git" ]; then
|
|
git_status="$(git pull)"
|
|
if [ "$git_status" != "Already up to date." ]; then
|
|
makepkg -sirc --sign --noconfirm
|
|
fi
|
|
fi
|
|
cd ..
|
|
done
|
|
}
|
|
|
|
parse_args "$@"
|
|
update "$root_dir"
|