From 78b22a0f78f72cc9890add81f49a15e8390c2e05 Mon Sep 17 00:00:00 2001 From: Dubiousjim <dubiousjim@gmail.com> Date: Fri, 5 Jul 2013 00:21:29 -0400 Subject: [PATCH] abump, functions: refactor (and verify) calculation of APKBUILD path --- abump.in | 12 +++++++++++- functions.sh.in | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/abump.in b/abump.in index 581ed8dba0e4..76284623d176 100755 --- a/abump.in +++ b/abump.in @@ -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 diff --git a/functions.sh.in b/functions.sh.in index d71ef38bda51..96b058656ab5 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -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) -- GitLab