apkgrel: optionally bump pkgrel when git is unclean

This commit is contained in:
Natanael Copa 2012-02-13 07:36:05 +00:00
parent 761472d96b
commit 0a11c5e3c1

View File

@ -14,6 +14,10 @@ do_set() {
do_add () {
local f= old=
for f in "$@"; do
[ -n "$only_clean_git" ] \
&& [ -n "$(git diff --name-only $f)" ] \
&& continue
[ -d "$f" ] && f="$f/APKBUILD"
old=$(do_show "$f")
setto=$(($old + 1))
do_set "$f" || return 1
@ -22,12 +26,15 @@ do_add () {
do_verify() {
[ -n "$force" ] && return 0
if ! grep -q '^pkgrel=[0-9]' "$@"; then
echo "The following files does not have proper pkgrel:" >&2
grep -L '^pkgrel=[0-9]' "$@" >&2
return 1
fi
return 0
local f= rc=0
for f in "$@"; do
[ -d "$f" ] && f="$f/APKBUILD"
if ! grep -q '^pkgrel=[0-9]' "$f"; then
echo "$f: Has no proper pkgrel" >&2
rc=1
fi
done
return $rc
}
do_nothing() {
@ -39,6 +46,7 @@ do_usage() {
Usage: $program -a|-h|-s NUM|-t|-z [-f] FILE...
Commands:
-a Add 1 to current pkgrel
-g Only do the change on files that have clean git status
-h Show this help
-s Set pkgrel to NUM
-t Only verify that files are in proper format
@ -52,9 +60,10 @@ __EOF__
cmd=do_show
force=
while getopts "afhs:tz" opt; do
while getopts "afghs:tz" opt; do
case $opt in
a) cmd=do_add;;
g) only_clean_git=1;;
f) force=1;;
h) cmd=do_usage;;
s) setto=$OPTARG; cmd=do_set;;