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
...@@ -59,10 +59,6 @@ sanitycheck() { ...@@ -59,10 +59,6 @@ sanitycheck() {
die "Number of md5sums does not correspond to number of sources" die "Number of md5sums does not correspond to number of sources"
fi 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 # common spelling errors
[ -n "$depend" ] && die "APKBUILD contains 'depend'. It should be depends" [ -n "$depend" ] && die "APKBUILD contains 'depend'. It should be depends"
[ -n "$makedepend" ] && die "APKBUILD contains 'makedepend'. It should be makedepends" [ -n "$makedepend" ] && die "APKBUILD contains 'makedepend'. It should be makedepends"
...@@ -145,8 +141,8 @@ clean() { ...@@ -145,8 +141,8 @@ clean() {
rm -rf "$srcdir" rm -rf "$srcdir"
rm -rf "$pkgdir" rm -rf "$pkgdir"
local i local i
for i in $splitfuncs; do for i in $subpackages; do
rm -rf "$pkgdir-$i" rm -rf "$pkgdir-$(get_split_func $i)"
done done
} }
...@@ -180,17 +176,26 @@ build() { ...@@ -180,17 +176,26 @@ build() {
die "No build() function found in $APKBUILD" 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() { subpkg() {
if [ -z "$splitfuncs" ] && [ -z "$subpackages" ]; then if [ -z "$subpackages" ]; then
return 0 return 0
fi fi
local i local i
cd "$startdir" cd "$startdir"
set $splitfuncs
for i in $subpackages; do for i in $subpackages; do
subpkgdir="$startdir/pkg-$1" subpkgname="$i" $0 $1 package \ local func=$(get_split_func $i)
|| return 1 # call abuild recursively, setting subpkg{dir,name}
shift subpkgdir="$startdir/pkg-$func" subpkgname="$i" \
$0 $func package || return 1
done done
} }
...@@ -387,9 +392,8 @@ shift $(( $OPTIND - 1 )) ...@@ -387,9 +392,8 @@ shift $(( $OPTIND - 1 ))
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)" [ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
. "$APKBUILD" . "$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 if [ -n "$subpkgname" ]; then
splitfuncs=
subpackages= subpackages=
fi fi
......
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