forked from archlinuxhardened/selinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit_update.sh
executable file
·35 lines (28 loc) · 1.08 KB
/
commit_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# Commit local modifications to prepare the update of AUR packages
cd "$(dirname -- "$0")" || exit $?
# Run the given command after displaying it
log_and_run() {
echo "Running: $*"
"$@" || exit $?
}
# reset the git repository
log_and_run git reset HEAD
for DIR in $(find . -maxdepth 2 -name PKGBUILD -printf '%h\n' | sort)
do
PKGNAME="${DIR##*/}"
# Ignore directories without any change
[ -n "$(git status --porcelain "$DIR")" ] || continue
# Update .SRCINFO
echo "Committing update to ${DIR#./} package"
(cd "$DIR" && makepkg --printsrcinfo > .SRCINFO) || exit $?
# Commit everything with a custom commit message
log_and_run git add "$DIR"
PKGVER="$(sed -n 's/^\s*pkgver = \(.*\)$/\1/p' "$DIR/.SRCINFO" | head -n1)"
PKGREL="$(sed -n 's/^\s*pkgrel = \(.*\)$/\1/p' "$DIR/.SRCINFO" | head -n1)"
log_and_run git commit -m "$PKGNAME $PKGVER-$PKGREL update"
tput bold
echo "$PKGNAME changes has been commited. You can now push them to the AUR with:"
echo "git subtree push --prefix=${DIR#./} aur-$PKGNAME master"
tput sgr0
done