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