Skip to content
Snippets Groups Projects
Commit 56741bed authored by Natanael Copa's avatar Natanael Copa
Browse files

do not use splitfuncs variable

the split function name is extraced from the subpackage name in subpackages
variable in one of the following formats:

 1. subpackage:func

    The ':' serves as a separator. subpackage is first part, function second

 2. subpackage-func

    Without ':' separator, the subpackage is the entire string. In the
    example above, the package name is 'subpackage-func'.

    Function is extracted from the text after last '-'.

 3. subpackage

    Without either ':' and '-' the function name will be the subpackage name
    itself.
parent fc3d67b1
No related merge requests found
......@@ -59,10 +59,6 @@ sanitycheck() {
die "Number of md5sums does not correspond to number of sources"
fi
if [ "$(echo $subpackages | wc -w)" -ne "$(echo $splitfuncs | wc -w)" ]; then
die "Number of subpackages does not correspond to number of splitfuncs"
fi
# common spelling errors
[ -n "$depend" ] && die "APKBUILD contains 'depend'. It should be depends"
[ -n "$makedepend" ] && die "APKBUILD contains 'makedepend'. It should be makedepends"
......@@ -145,8 +141,8 @@ clean() {
rm -rf "$srcdir"
rm -rf "$pkgdir"
local i
for i in $splitfuncs; do
rm -rf "$pkgdir-$i"
for i in $subpackages; do
rm -rf "$pkgdir-$(get_split_func $i)"
done
}
......@@ -180,17 +176,26 @@ build() {
die "No build() function found in $APKBUILD"
}
get_split_func() {
# get the 'func' from "sub-pkg:func"
local func=${1##*:}
# get 'func' from "sub-pkg-func" if there was no :func
[ "$func" = "$1" ] && func=${func##*-}
echo $func
}
subpkg() {
if [ -z "$splitfuncs" ] && [ -z "$subpackages" ]; then
if [ -z "$subpackages" ]; then
return 0
fi
local i
cd "$startdir"
set $splitfuncs
for i in $subpackages; do
subpkgdir="$startdir/pkg-$1" subpkgname="$i" $0 $1 package \
|| return 1
shift
local func=$(get_split_func $i)
# call abuild recursively, setting subpkg{dir,name}
subpkgdir="$startdir/pkg-$func" subpkgname="$i" \
$0 $func package || return 1
done
}
......@@ -387,9 +392,8 @@ shift $(( $OPTIND - 1 ))
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
. "$APKBUILD"
# If we are handling a sub package then reset splitfuncs and subpackages
# If we are handling a sub package then reset subpackages
if [ -n "$subpkgname" ]; then
splitfuncs=
subpackages=
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment