dotfiles/.local/bin/scripts/git-aur

46 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh -e
2022-05-10 08:11:30 +00:00
aurdir="$DATA/1-projects/aur"
2022-09-03 11:36:52 +00:00
commands="<origin|clone|create|commit|push|clean>"
if test $# -eq 0
then echo "Usage: $0 $commands"
case "$PWD" in ($aurdir*) exit 0;; (*) cd "$aurdir"; exec $SHELL;; esac
fi
command=$1
shift
2021-09-20 19:34:00 +00:00
url="ssh://aur@aur.archlinux.org/${1:-$(basename $PWD)}.git"
2022-04-12 17:30:12 +00:00
case "$command" in
(origin)
test "$(git rev-parse --git-dir)" = ".git" && git remote set-url origin "$url"
git remote -v;;
(clone)
cd "$aurdir"
git -c init.defaultBranch=master clone "$url"
cd "$1"
test -f PKGBUILD || sed "s/PKG/${1%%-git}/" ../PKGBUILD > PKGBUILD
test -f .gitignore || echo '*' > .gitignore
exec $SHELL;;
(create)
2023-03-13 14:34:16 +00:00
if ! test -d .git; then "$0" clone "$@"; exit; fi
2022-04-12 17:30:12 +00:00
git add -f .gitignore PKGBUILD
git commit -m "Create Package" "$@"
2023-03-13 14:34:16 +00:00
"$0" push --amend;;
2022-04-12 17:30:12 +00:00
(commit)
makepkg --printsrcinfo > .SRCINFO
git add -f .SRCINFO
2022-05-03 09:22:10 +00:00
git commit -v "$@";;
2023-03-13 14:34:16 +00:00
(update)
git pull
updpkgsums
makepkg -si
"$0" push;;
2022-04-12 17:30:12 +00:00
(push)
grep -q SKIP PKGBUILD || updpkgsums
2022-04-12 17:30:12 +00:00
git add -f *.install 2>/dev/null || true
2023-03-13 14:34:16 +00:00
"$0" commit -a "$@"
2022-04-12 17:30:12 +00:00
git push;;
(clean)
2022-11-22 12:24:52 +00:00
find "$aurdir" -mindepth 2 -maxdepth 2 \( -iname "*.pkg.tar.*" -o -iname "*.zip" -o -name "*.tar.gz" -o -type d -not -name ".*" \) \
2022-04-12 17:30:12 +00:00
-print -exec sudo rm -rI {} +;;
2022-09-03 11:36:52 +00:00
(*) echo "Unknown command! Available: $commands"; exit 3;;
esac