summaryrefslogtreecommitdiffstats
path: root/bin/pbfields
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pbfields')
-rwxr-xr-xbin/pbfields50
1 files changed, 30 insertions, 20 deletions
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]
}
}