From ea8184012874f11d4ef9eed6e7fcc8cd5a1bf848 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Thu, 11 Apr 2013 11:33:35 +0000 Subject: Perl mod pkgbuilds use $_ddir now. With pacman 4.1 $srcdir is no longer set outside of PKGBUILD functions. Yipee! This breaks all of my PKGBUILDs. Now we switch to storing the distribution's tarballed directory in the _ddir custom variable. We cd into $srcdir/$_ddir at the beginning of every func. Custom variable mechanics have changed in bin/pbfields as well. Instead of hard-coding _dir as an accepted field, any PKGDATA entry with a name starting with underscore (_) is considered a custom variable and printed in the PKGBUILD. --- bin/pbfields | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'bin') diff --git a/bin/pbfields b/bin/pbfields index 281fc88..052c643 100755 --- a/bin/pbfields +++ b/bin/pbfields @@ -6,19 +6,16 @@ BEGIN { " install changelog" \ " *depends *makedepends *checkdepends *optdepends" \ " *conflicts *provides" \ - " url *source *noextract *md5sums *sha512sums" \ - " _dir" - fieldcnt = split(fieldstr, fields) - for(i = 1; i <= fieldcnt; i++){ + " url *source *noextract *md5sums *sha512sums" + fcount = split(fieldstr, fields) + for(i = 1; i <= fcount; i++){ f = fields[i] if(sub(/^[*]/, "", f)){ + fields[i] = f arrfield[f] = 1 - }else if(sub(/^_/, "", f)){ - cfield[f] = 1 }else{ strfield[f] = 1 } - fields[i] = f } COLS = 78; FS = "\n"; RS = "" @@ -31,16 +28,20 @@ $1 == "packager" { packager = $2; next } $1 == "maintainer" { maintainer = $2; next } # pkgdesc has the only value where parameters do not expand. -$1 == "pkgdesc" { output[$1] = qnoexpand($2); next } +$1 == "pkgdesc" { values[$1] = qnoexpand($2); next } { for(i = 2; i <= NF; i++) $i = qexpand($i) - if(($1 in strfield) || ($1 in cfield)){ - output[$1] = $2 - }else { - arrtxt = wraparray(length($1) + 2) - if(arrfield[$1]){ - output[$1] = arrtxt + if($1 in strfield){ + values[$1] = $2 + }else if($1 in arrfield){ + values[$1] = wraparray(length($1) + 2) + }else if($1 ~ /^_/){ + vars[++vcount] = $1 + if(NF > 2){ + values[$1] = wraparray(length($1) + 2) + }else{ + values[$1] = $2 } } } @@ -54,14 +55,23 @@ END { print "# Packager: Anonymous\n" } - OFS = "="; ORS = "\n"; + ORS = "\n"; - for(i = 1; i <= fieldcnt; i++){ + # Loop through our list of PKGBUILD field names so they are always + # printed in the same order, matching the PKGBUILD manpage. + for(i = 1; i <= fcount; i++){ f = fields[i] - if(!(f in output)) continue - v = output[f] - if(f in cfield) f = "_" f - print f, v + if(!(f in values)){ + continue + } + v = values[f] + print f "=" v + } + + # Print our custom variables in the order they appeared. + for(i = 1; i <= vcount; i++){ + v = vars[i] + print v "=" values[v] } } -- cgit v1.2.3-24-g4f1b