summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xbin/makepkgbuild41
2 files changed, 35 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 762980f..1f996f1 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ PKGBUILD: $(PKGS)/$(PKG)/PKGBUILD
$(PKGS)/$(PKG)/PKGBUILD: tweakmeta
@cd '$(PKGS)/$(PKG)'; \
- TDIR='$(BIN)/templ' $(BIN)/makepkgbuild >PKGBUILD
+ TDIR='$(BIN)/templ' $(BIN)/makepkgbuild
@echo 'Built pkg/$(PKG)/PKGBUILD.'
tweakmeta: $(PKGS)/$(PKG)/PKGMETA
diff --git a/bin/makepkgbuild b/bin/makepkgbuild
index 9ecfb80..33b2216 100755
--- a/bin/makepkgbuild
+++ b/bin/makepkgbuild
@@ -2,7 +2,26 @@
prog=makepkgbuild
-if ! [ -f PKGMETA ]
+appendpb()
+{
+ txt=$(awk -v f=$1 'BEGIN { FS = "\n"; RS = "" }
+ $1 == f "()" { for (i = 2; i <= NF; i++) print $i }' PKGMETA \
+ | sed 's/^/ /')
+
+ case "$txt" in
+ '') return 0 ;;
+ *) echo '/^ *'"${func}"'()[ \\n]*{
+/^}
+i
+'"$txt"'
+.
+wq
+' | tee dbg | ed PKGBUILD >/dev/null 2>&1
+ return $? ;;
+ esac
+}
+
+if ! [ -r PKGMETA ]
then
echo "$prog: PKGMETA could not be read." 1>&2
exit 1
@@ -15,21 +34,29 @@ esac
tcmd=$(awk '
BEGIN { FS = "\n"; RS = "" }
- $1 == "template" { for (i = 2; i <= NF; i++) print $i }' PKGMETA | \
- while read line
+ $1 == "template" { for (i = 2; i <= NF; i++) print $i }' PKGMETA \
+ | while read line
do
set -- $line
cmd="$TDIR/$1"
if ! [ -x $cmd ]
then
- echo "$prog: Unknown template command: $cmd" \
- 1>&2
+ echo "$prog: Unknown template command: $cmd" 1>&2
exit 2
fi
echo "$TDIR/$*"
- done | tr '\n' '|' | sed 's/\|$//')
+ done \
+ | tr '\n' '|' | sed 's/\|$//')
-echo "\$tcmd = $tcmd" 1>&2
"$TDIR/pbfields" <PKGMETA >PKGBUILD
$tcmd <PKGMETA >>PKGBUILD
+for func in package check build
+do
+ if ! appendpb $func
+ then
+ echo "$prog: failed to append to the ${func}() function in PKGBUILD" 1>&2
+ exit 2
+ fi
+done
+