Commit bd245c07 authored by Natanael Copa's avatar Natanael Copa

implement new way of doing subpackages

subpackages contains a list of (full) names of the sub packages
splitfuncs contains a list of corresponding function names to be called
parent 59bcc571
......@@ -29,8 +29,8 @@ all_cmds="checksum fetch unpack rootpkg build package cleancache clean srcpkg"
# functions
msg() {
local sub=
[ -n "$INSUB" ] && sub="(sub)"
[ -z "$quiet" ] && echo ">>> $pkgname $sub:" "$@" >&2
[ -n "$subpkgname" ] && sub="(sub)"
[ -z "$quiet" ] && echo ">>> ${subpkgname:-$pkgname} $sub:" "$@" >&2
}
warning() {
......@@ -55,6 +55,14 @@ sanitycheck() {
[ -z "$url" ] && die "Missing url in APKBUILD"
[ -z "$license" ] && die "Missing license in APKBULID"
if [ "$(echo $source | wc -l)" -ne "$(echo $md5sums | wc -l)" ]; then
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"
......@@ -154,11 +162,10 @@ cleancache() {
}
cleanpkg() {
local p="$pkgname-$pkgver-$pkgrel"
rm -f "$PKGDEST/$p.apk" "$PKGDEST/$p.src.tar.gz"
local i
for i in $splitfuncs; do
INSUB=1 subpkgdir="$pkgdir-$i" $0 $i cleanpkg
for i in $pkgname $subpackages; do
local p="$i-$pkgver-$pkgrel"
rm -f "$PKGDEST/$p.apk" "$PKGDEST/$p.src.tar.gz"
done
}
......@@ -174,18 +181,24 @@ build() {
}
subpkg() {
[ -z "$splitfuncs" ] && return 0
if [ -z "$splitfuncs" ] && [ -z "$subpackages" ]; then
return 0
fi
local i
cd "$startdir"
for i in $splitfuncs; do
INSUB=1 subpkgdir="$pkgdir-$i" $0 $i package || return 1
set $splitfuncs
for i in $subpackages; do
subpkgdir="$startdir/pkg-$1" subpkgname="$i" $0 $1 package \
|| return 1
shift
done
}
package_apk() {
[ -z "${pkgname##* *}" ] && die "pkgname contains spaces"
local name=${subpkgname:-$pkgname}
[ -z "${name##* *}" ] && die "package name contains spaces"
local dir=${subpkgdir:-$pkgdir}
local pkg="$pkgname-$pkgver-$pkgrel.apk"
local pkg="$name-$pkgver-$pkgrel.apk"
[ ! -d "$dir" ] && die "Missing $dir"
cd "$dir"
......@@ -199,7 +212,7 @@ package_apk() {
fi
echo "# $(date -u)" >> .PKGINFO
cat >> .PKGINFO <<EOF
pkgname = $pkgname
pkgname = $name
pkgver = $pkgver-$pkgrel
pkgdesc = $pkgdesc
url = $url
......@@ -250,7 +263,6 @@ package() {
# predefined splitfunc doc
doc() {
pkgname="$pkgname-doc"
depends=""
local i
for i in doc man info html sgml; do
......@@ -269,7 +281,6 @@ doc() {
# predefined splitfunc mod
mod() {
pkgname="$pkgname-mod"
depends="$kernel"
for i in firmware modules; do
if [ -d "$pkgdir/lib/$i" ]; then
......@@ -283,7 +294,6 @@ mod() {
# predefined splitfunc dev
dev() {
depends="$pkgname"
pkgname="$pkgname-dev"
for i in $(cd "$pkgdir" && find usr/lib -name '*.a' -o \
-name '*.la' -o -name '*.o' 2>/dev/null) \
usr/include usr/lib/pkgconfig usr/share/aclocal; do
......@@ -377,8 +387,11 @@ shift $(( $OPTIND - 1 ))
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
. "$APKBUILD"
# If we are handling a sub package then reset splitfuncs
[ -n "$INSUB" ] && splitfuncs=
# If we are handling a sub package then reset splitfuncs and subpackages
if [ -n "$subpkgname" ]; then
splitfuncs=
subpackages=
fi
trap 'die "Aborted by user"' INT
......
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