Commit 78b22a0f authored by Dubiousjim's avatar Dubiousjim Committed by Natanael Copa

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

parent ecde2039
...@@ -20,14 +20,22 @@ fi ...@@ -20,14 +20,22 @@ fi
do_bump() { do_bump() {
local p rc=0 pkgname pkgver section message local p rc=0 pkgname pkgver section message
local upgrade="${cvelist:+security }upgrade" local upgrade="${cvelist:+security }upgrade"
local a
for p; do for p; do
pkgname=${p%-[0-9]*} pkgname=${p%-[0-9]*}
pkgver=${p#${pkgname}-} 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 set -e
cd $HOME/aports/*/$pkgname cd "${a%/*}"
section=${PWD%/*} section=${PWD%/*}
section=${section##*/} section=${section##*/}
...@@ -75,6 +83,8 @@ recursive="-r" ...@@ -75,6 +83,8 @@ recursive="-r"
cvelist= cvelist=
fixes= fixes=
[ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR"
args=`getopt -o s:Rkqh --long security:,recursive,keep,quiet,help -n "$prog" -- "$@"` args=`getopt -o s:Rkqh --long security:,recursive,keep,quiet,help -n "$prog" -- "$@"`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
usage usage
......
...@@ -19,6 +19,18 @@ if [ -f "$abuild_userconf" ]; then ...@@ -19,6 +19,18 @@ if [ -f "$abuild_userconf" ]; then
fi 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 # output functions
case $prog in case $prog in
abuild) abuild)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment