summaryrefslogtreecommitdiffstats
path: root/bin/tweakmeta
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-02-05 18:16:43 +0100
committerJustin Davis <jrcd83@gmail.com>2012-02-05 18:16:43 +0100
commitba97a989c2228e4840a0c58173b0d8f541911c69 (patch)
tree5e0fd4bae7c1270f3237f5415fef645baaf60c3d /bin/tweakmeta
parent30669532cbd4439ed731778c08c8636491f8fc6e (diff)
downloadgenpkg-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/tweakmeta')
-rwxr-xr-xbin/tweakmeta118
1 files changed, 0 insertions, 118 deletions
diff --git a/bin/tweakmeta b/bin/tweakmeta
deleted file mode 100755
index 75198a2..0000000
--- a/bin/tweakmeta
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/awk -f
-##
-# tweakmeta
-#
-# First read a PKGDATA file in the current directory, loading its values.
-# Next read a PKGTWEAK file from standard input.
-# The PKGTWEAK file tells us how to modify the PKGDATA data.
-# The modified PKGDATA is printed to standard output.
-#
-# Justin Davis <jrcd83@gmail.com>
-
-BEGIN {
- PROG = "tweakmeta"
- if (system("test -r PKGDATA") != 0) {
- print PROG ": PKGDATA file could not be read." | "cat 1>&2"
- exit(errcode = 2)
- }
-
- FS = "\n"; RS = ""
- while (getline<"PKGDATA" > 0)
- for (i = 2; i <= NF; i++) pushval($1, $i)
- close("PKGDATA")
- FS = " "; RS = "\n"
-}
-
-{ sub(/#.*/, "") }
-
-$1 == "+" { pushval($2, joinfields(3)); next }
-
-$1 == "-" { remval($2, $3); next }
-
-$1 == "<" {
- i = findval($2, $3)
- stack[++stacklen] = pbvars[$2, i]
- remelem($2, i)
- next
-}
-
-$1 == ">" {
- if (stacklen < 1)
- die("No values on the stack. Make sure you use '<' first.")
- pushval($2, stack[stacklen--])
- next
-}
-
-$1 == "=" {
- if ($2 == "optdepends") die("cannot use '=' with optdepends.")
- remall($2)
- for (i=3; i<=NF; i++) pushval($2, $i)
- next
-}
-
-# ignore lines of whitespace
-$1 !~ /^[ \t]*$/ { die("invalid input: " $0) }
-
-END {
- if (errcode) exit(errcode)
-
- OFS = "\n"
-
- for (name in pbcount) {
- len = pbcount[name]
- if (len == 0) continue
-
- print name
- for (i=1; i<=len; i++) print pbvars[name, i]
- print ""
- }
-}
-
-function die (msg)
-{
- printf "%s: error line %d: %s\n", PROG, FNR, msg | "cat 1>&2"
- exit(errcode = 1)
-}
-
-function joinfields (start, msg)
-{
- msg = $(start++)
- while (start <= NF) msg = msg " " $(start++)
- return msg
-}
-
-function remall (field)
-{
- pbcount[field] = 0
-}
-
-function pushval (field, val)
-{
- pbvars[field, ++pbcount[field]] = val
-}
-
-function remval (field, prefix)
-{
- remelem(field, findval(field, prefix))
-}
-
-function remelem (field, i, len)
-{
- # TODO: error check if "i" is in bounds?
- len = pbcount[field]
- for (len = pbcount[field]; i < len; i++)
- pbvars[field, i] = pbvars[field, i+1]
- delete pbvars[field, i]
- pbcount[field]--
-}
-
-function findval (field, prefix, i, len)
-{
- len = pbcount[field]
- if (len == 0) die(field " is empty!")
-
- for (i = 1; i <= len; i++)
- if (index(pbvars[field,i], prefix) == 1) break
- if (i > len) die("could not find " prefix " in " field "'s values")
- return i
-}