diff options
author | Justin Davis <jrcd83@gmail.com> | 2012-05-14 02:40:10 +0200 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2012-05-14 02:40:10 +0200 |
commit | aeeb51372863bd95b5126691c16851d52082ac92 (patch) | |
tree | 7be6aef8b78fcb12e266450d1307e5a9c27c28c2 /bin | |
parent | ce30a8af59f163bc09be80955d38b56039785735 (diff) | |
download | genpkg-aeeb51372863bd95b5126691c16851d52082ac92.tar.gz genpkg-aeeb51372863bd95b5126691c16851d52082ac92.tar.xz |
Add feature to replace ver-strings with $pkgver.
Alot of logic was added to allow changing versions
in mods while still preserving the version in the
$_ver custom variable.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/genpkg | 22 | ||||
-rwxr-xr-x | bin/pbfields | 51 |
2 files changed, 50 insertions, 23 deletions
@@ -58,6 +58,18 @@ END { exit !found } return $? } +# Create an extra "ver" field in case the packager needs to modify +# the version. +dupver() +{ + awk ' +BEGIN { OFS = FS = "\n"; RS = ""; ORS = "\n\n" } +$1 == "pkgver" { pkgver = $2 } +1 +END { print "ver", pkgver } +' +} + if [ $# -lt 1 ] then echo "usage: $prog [package name]" 1>&2 @@ -98,20 +110,26 @@ do rm PKGDATA exit "$?" fi + trap '' 1 2 15 mod="$modsd/$pkg" if [ -f "$mod" -a -r "$mod" ] then - if modpkg "$mod" + trap 'rm PKGDATA.new' 1 2 15 + if cat PKGDATA | dupver | modpkg "$mod" > PKGDATA.new then echo "Modified with $mod." 1>&2 + mv PKGDATA.new PKGDATA else echo "$prog: modpkg failed." 1>&2 + [ "$GENPKGDBG" ] || rm PKGDATA.new fi + trap '' 1 2 15 fi # Insert PKGBUILD fields into prefix of PKGBUILD body. - cat PKGDATA | injectdigs | pbfields | putpkgtree PKGBUILD prefix body || exit "$?" + cat PKGDATA | vervar | injectdigs | pbfields |\ + putpkgtree PKGBUILD prefix body || exit "$?" # Merge split PKGTREE files into their own separate text files. mergefile PKGBUILD prefix build check package suffix diff --git a/bin/pbfields b/bin/pbfields index 5bbf9c6..ca65c2a 100755 --- a/bin/pbfields +++ b/bin/pbfields @@ -1,16 +1,22 @@ #!/usr/bin/awk -f BEGIN { - fieldstr = "pkgname pkgver pkgrel pkgdesc epoch" \ + fieldstr = "pkgname _ver pkgver pkgrel pkgdesc epoch" \ " *arch *license *options" \ " install changelog" \ " *depends *makedepends *checkdepends *optdepends" \ " *conflicts *provides" \ - " url *source *noextract *md5sums *sha512sums" + " url *source *noextract *md5sums *sha512sums" \ + " _dir" max = split(fieldstr, fields) for(i=1; i<=max; i++) { - if(sub(/^[*]/, "", fields[i])) arrfield[fields[i]] = 1; - else strfield[fields[i]] = 1; + if(sub(/^[*]/, "", fields[i])){ + arrfield[fields[i]] = 1 + }else if(sub(/^_/, "", fields[i])){ + cfield[fields[i]] = 1 + }else{ + strfield[fields[i]] = 1 + } } COLS = 78; FS = "\n"; RS = "" @@ -22,15 +28,6 @@ $1 == "packager" { packager = $2 } $1 == "maintainer" { maintainer = $2 } -$1 ~ /depends$|conflicts|provides|source/ { quotevals() } - -$1 == "pkgdesc" { - gsub(/[$"`]/, "\\\\&", $2) - $2 = sprintf("\"%s\"", $2) -} - -$1 == "pkgverfmt" { pkgverfmt = $2 } - $1 == "customvars" { for(i = 2; i <= NF; i++){ customvars[i - 1] = $i @@ -39,7 +36,8 @@ $1 == "customvars" { } { - if(strfield[$1]){ + quotevals() + if(($1 in strfield) || ($1 in cfield)){ output[$1] = $2 }else { arrtxt = wraparray(length($1) + 2) @@ -62,16 +60,22 @@ END { print "" OFS = "="; ORS = "\n"; + for(i = 1; i <= customlen; i++){ + v = customvars[i] + print "_" v, unk[v] + } for(i=1; i<=max; i++){ name = fields[i] - if(name in output){ + if(!(name in output)){ + continue + } + + if(name in cfield){ + print "_" name, output[name] + }else{ print name, output[name] } } - for(i = 1; i <= customlen; i++){ - v = customvars[i] - print "_" v, unk[v] - } } function wraparray (indent) @@ -112,6 +116,11 @@ function quotevals () function bashquote (val) { - if(val ~ /[$]/) return sprintf("\"%s\"", val) - return sprintf("'%s'", val) + + if(val ~ /[$'"`]/){ + gsub(/[$"`]/, "\\\\&", $2) + return sprintf("\"%s\"", val) + } + if(val ~ / /) return sprintf("'%s'", val) + return val } |