abump, functions: refactor (and verify) calculation of APKBUILD path

This commit is contained in:
Dubiousjim 2013-07-05 00:21:29 -04:00 committed by Natanael Copa
parent ecde203930
commit 78b22a0f78
2 changed files with 23 additions and 1 deletions

View File

@ -20,14 +20,22 @@ fi
do_bump() {
local p rc=0 pkgname pkgver section message
local upgrade="${cvelist:+security }upgrade"
local a
for p; do
pkgname=${p%-[0-9]*}
pkgver=${p#${pkgname}-}
# calculate APKBUILD's path
if [ "${pkgname#*/}" != "$pkgname" ] && ! [ -d "$APORTSDIR/${pkgname%/*} ]; then
error "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'"
rc=1; continue
fi
a=$(aports_buildscript "$pkgname" || die "can't find APKBUILD for $pkgname") || { rc=1; continue; }
(
set -e
cd $HOME/aports/*/$pkgname
cd "${a%/*}"
section=${PWD%/*}
section=${section##*/}
@ -75,6 +83,8 @@ recursive="-r"
cvelist=
fixes=
[ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR"
args=`getopt -o s:Rkqh --long security:,recursive,keep,quiet,help -n "$prog" -- "$@"`
if [ $? -ne 0 ]; then
usage

View File

@ -19,6 +19,18 @@ if [ -f "$abuild_userconf" ]; then
fi
# expects $1 to be a package directory in the aports tree ('foo' or 'main/foo')
# outputs APKBUILD's path if successful
aports_buildscript() {
[ -n "$APORTSDIR" ] || return 1
if [ "${1#*/}" != "$1" ]; then
( cd "$APORTSDIR/$1" && [ -f APKBUILD ] && echo "$PWD/APKBUILD" )
else
( cd "$APORTSDIR"/*/"$1" && [ -f APKBUILD ] && echo "$PWD/APKBUILD" )
fi
}
# output functions
case $prog in
abuild)