diff options
author | Justin Davis <jrcd83@gmail.com> | 2012-02-05 18:16:43 +0100 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2012-02-05 18:16:43 +0100 |
commit | ba97a989c2228e4840a0c58173b0d8f541911c69 (patch) | |
tree | 5e0fd4bae7c1270f3237f5415fef645baaf60c3d /bin/mkpkgbuild | |
parent | 30669532cbd4439ed731778c08c8636491f8fc6e (diff) | |
download | genpkg-ba97a989c2228e4840a0c58173b0d8f541911c69.tar.gz genpkg-ba97a989c2228e4840a0c58173b0d8f541911c69.tar.xz |
Start of big rewrite of pkg tweaking.
The current setup is only really good for modifying PKGBUILD fields. The
modification of PKGBUILD funcs is hackish. Instead, the tweaks will be
written in a scripting language (like Io) where both PKGBUILD fields
and function code can be easily modified.
Fields should be able to be modified just like arrays, but with easier
package matching going on. PKGBUILD bash functions are simply arrays
of lines, but they are not as sophisticated. Instead they can only be
appended to.
Package files are represented as trees. Each file (PKGBUILD pkg.install)
is a child of the top-level node of the tree. Each child of the file
node is a section of the file (intro, body, end). Each section can
also have its own intro, body, and end node. In this way each bash
function is a node with its own intro, body, and end node. Prepending
to a function appends to its intro node. Appending to a function appends
to its end child node. The body cannot be modified.
Diffstat (limited to 'bin/mkpkgbuild')
-rwxr-xr-x | bin/mkpkgbuild | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/bin/mkpkgbuild b/bin/mkpkgbuild deleted file mode 100755 index 490a27a..0000000 --- a/bin/mkpkgbuild +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -prog=mkpkgbuild - -die() -{ - rc=$1; shift - echo "$prog: $*" 1>&2 - exit $rc -} - -editpb() -{ - op=$1 func=$2 - - case "$op" in - append) - regexp="^${func}[(][)]<?$" - edin="/^ *$func() *{ -/^} -i" ;; - prepend) - regexp=">${func}()" - edin="/^ *$func() *{ -/^[ \t]*cd/ -a" ;; - *) die 1 "unknown editpb operation: $op" - esac - - txt=$(awk -v r="$regexp" 'BEGIN { FS = "\n"; RS = "" } - $1 ~ r { for (i = 2; i <= NF; i++) print $i }' PKGDATA |\ - sed 's/^/ /') - [ "$txt" ] || return 0 - - cat << END | ed -s PKGBUILD >/dev/null -$edin -$txt -. -wq -END - return $? -} - -[ -r PKGDATA ] || die 1 "PKGDATA could not be read." - -[ "$TDIR" ] || die 1 "TDIR env. var is unset." -[ -d "$TDIR" ] || die 1 "template dir ($TDIR) not found." - -tcmd=$(awk 'BEGIN { FS="\n"; RS="" } $1 == "template" { print $2 }' PKGDATA) -[ "$tcmd" ] || die 1 "PKGDATA is missing 'template' entry." - -set -- $tcmd -cmd="$TDIR/$1" -[ -f "$cmd" -a -x "$cmd" ] \ - || die 2 "template command ($1) not in template dir ($TDIR)" - -# Generate the PKGBUILD using basic pbfields script plus custom template. -"$TDIR/pbfields" < PKGDATA > PKGBUILD || die 1 "pbfields returned error ${?}." -"$TDIR"/$tcmd < PKGDATA >> PKGBUILD || die 1 "template pipeline ($tcmd) failed" - -# Prepand/append text to the package, check, or build functions. -for func in package check build -do - for op in append prepend - do - editpb $op $func \ - || die 2 "error $? when trying to $op to ${func}()" - done -done - -exit 0 |