From b561c1bf11e6ecfac26f95fe1dd9fb16fbb5d67b Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Tue, 15 May 2012 11:08:05 -0400 Subject: Forgot to add vervar script. --- bin/vervar | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 bin/vervar (limited to 'bin') 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] + } +} -- cgit v1.2.3-24-g4f1b