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/mkpkgmeta | |
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/mkpkgmeta')
-rwxr-xr-x | bin/mkpkgmeta | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/mkpkgmeta b/bin/mkpkgmeta new file mode 100755 index 0000000..2296a28 --- /dev/null +++ b/bin/mkpkgmeta @@ -0,0 +1,67 @@ +#!/bin/sh + +prog=mkpkgmeta + +err() +{ + echo "$prog: $*" 1>&2 + exit 1 +} + +basicmeta() +{ + printf "pkgname\n%s\n\n" "$pkgname" + printf "pkgrel\n%d\n\n" "${PKGREL:-1}" + printf "packager\n%s\n\n" "${PACKAGER:-Anonymous}" + + if [ "$MAINTAINER" ] + then + printf "maintainer\n%s\n\n" "$MAINTAINER" + fi + + return 0 +} + +prependmeta() +{ + if basicmeta | cat - "$1" > "$1.new" + then + mv "$1.new" "$1" + return 0 + else + rm "$1.new" + return 1 + fi +} + +case $# in +0) echo "usage: $prog [package name]" 1>&2 + exit 1 +esac + +case "$METABIN" in +'') err "set METABIN before calling $prog" +esac + +tmp="/tmp/$prog.$$" +for flav in "$METABIN"/* +do + pkgname="$1" + [ -f "$flav" -a -x "$flav" ] || continue + PATH="$PATH:$flav.d" "$flav" "$pkgname" + metaret=$? + + case "$metaret" in + 0) if prependmeta PKGDATA + then + exit 0 + else + err "failed to prepend to PKGDATA" + fi ;; + 1) err "$flav encountered an error" ;; + 2) ;; # loop + *) err "$flav returned error code $metaret" ;; + esac +done + +err "no matching meta generator found for '$1'" |