commit ce4fcbd4654206234d008d75729400b6c143e412 Author: Sebastian Hugentobler Date: Thu Jun 22 09:44:34 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..765efc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +.DS_Store +*.pkg.tar.zst +*.pkg.tar.zst.sig diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..e9dda1d --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# Maintainer: Sebastian Hugentobler + +pkgname=aur-update +pkgver=0.1.0 +pkgrel=1 +pkgdesc="Simple updater for local aur repositories." +arch=("any") +url="https://code.vanwa.ch" +license=('MIT') +depends=("git" "base-devel") +source=( + "aur-update" +) +sha256sums=("f4e09dfe9753a26b90df2f8ba463f2856b2cd82268c5f13d8551391bc03f8c79") + +package() { + cd "$srcdir/" + + install -Dm 755 aur-update "$pkgdir/usr/bin/aur-update" +} diff --git a/aur-update b/aur-update new file mode 100755 index 0000000..e119b65 --- /dev/null +++ b/aur-update @@ -0,0 +1,58 @@ +#!/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 --noconfirm + fi + fi + cd .. + done +} + +parse_args "$@" +update "$root_dir"