#!/bin/sh VERSION=0.01 die() { echo "error: $*" exit 1 } pbjtopkg() { pkg=$1 rm -rf "$pkgroot/$pkg" mkdir "$pkgroot/$pkg" cd "$pkgroot/$pkg" jamfile="$jamdir/$1.pbj" if [ ! -f "$jamfile" ] then die "$jamfile is missing" fi # Match the pkgname to the .pbj filename. # Provide values for other things macros won't be able to. printf "+ pkgname $pkg\n+ pkgrel ${PKGREL:-1}\n+ pbjver $VERSION\n" \ | cat - "$jamfile" \ | pbjexpand \ | awk -f "$bindir/pbjparse.awk" \ > PKGMETA if [ $? -ne 0 ] then die "Failed to write $pkgroot/$pkg/PKGMETA" fi # pbjparse.awk also creates a makepb script in our cwd. if ! ./makepb >PKGBUILD then die "makepb failed, error code $?" fi echo "$pkgroot/$pkg/PKGBUILD" } if [ -z "$1" ]; then die "Usage: $0 [package name]"; fi if [ "$PBJROOT" ]; then cd "$PBJROOT"; fi bindir="$(pwd)/bin" if [ ! -d "$bindir" ]; then die "$bindir does not exist"; fi PATH="$PATH:$bindir" if [ -n "$PKGROOT" ]; then pkgroot="$PKGROOT" else pkgroot="$(pwd)/pkg" fi if [ ! -d "$pkgroot" ]; then die "$pkgroot does not exist"; fi jamdir="$(pwd)/pbj" if [ ! -d "$jamdir" ]; then die "$jamdir does not exist"; fi export PATH="$PATH:$bindir/macros:$bindir/templ" for pbj; do pbjtopkg "$pbj"; done