summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-05-15 17:08:05 +0200
committerJustin Davis <jrcd83@gmail.com>2012-05-15 17:08:05 +0200
commitb561c1bf11e6ecfac26f95fe1dd9fb16fbb5d67b (patch)
treee7873f38b30ea6229ef4df9b7ad1e6a82cbfe323
parentaeeb51372863bd95b5126691c16851d52082ac92 (diff)
downloadgenpkg-b561c1bf11e6ecfac26f95fe1dd9fb16fbb5d67b.tar.gz
genpkg-b561c1bf11e6ecfac26f95fe1dd9fb16fbb5d67b.tar.xz
Forgot to add vervar script.
-rwxr-xr-xbin/vervar52
1 files changed, 52 insertions, 0 deletions
diff --git a/bin/vervar b/bin/vervar
new file mode 100755
index 0000000..8333486
--- /dev/null
+++ b/bin/vervar
@@ -0,0 +1,52 @@
+#!/usr/bin/awk -f
+##
+# Replaces version strings with the $pkgver variable or $_ver variable.
+# If the ver field is the same as pkgver then ver is discarded (not printed)
+# and version strings are replaced with $pkgver.
+#
+# The path and source fields are searched and replaced.
+
+BEGIN {
+ OFS = FS = "\n"
+ RS = ""
+ ORS = "\n\n"
+ prog = "vervar"
+ replflds["path"] = replflds["source"] = 1
+}
+
+$1 == "ver" { ver = $2; next }
+$1 == "pkgver" { pkgver = $2; next }
+$1 in replflds {
+ repl[$1] = $0
+ next
+}
+1
+
+END {
+ if(error) {
+ exit(error)
+ }
+ if(!ver){
+ print prog ": error: ver field is missing (or zero)" | "cat 1>&2"
+ exit(1)
+ }
+
+ if("" pkgver == ver){
+ # Don't use the $_ver variable if $pkgver and $_ver are identical.
+ skipver = 1
+ vervar = "pkgver"
+ ver = pkgver
+ }else{
+ # Print the $_ver variable if it is different
+ print "ver", ver
+ vervar = "ver"
+ }
+ print "pkgver", pkgver
+
+ # Replace the version string with the version parameter.
+ gsub(/([.])/, "\\\\&", ver)
+ for(f in repl){
+ sub(ver, "$" vervar, repl[f])
+ print repl[f]
+ }
+}