]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
- sort BR/R.. sucks very much, but sometimes works. enable with ./adapter --sort...
authorElan Ruusamäe <glen@pld-linux.org>
Mon, 15 Aug 2005 22:06:39 +0000 (22:06 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    adapter.awk -> 1.171

adapter.awk

index 49a3ff4b81cfced55191a73b3839be3cac5ccb3d..470d1a0e5e2b2fb3923790e4ea07772558114b1f 100644 (file)
@@ -23,6 +23,8 @@ BEGIN {
        bod = 0                 # Beggining of %description
        tw = 70                 # Descriptions width
 
+       b_idx = 0               # index of BR/R arrays
+
        # If variable removed, then 1 (for removing it from export)
        removed["LDFLAGS"] = 0
        removed["CFLAGS"] = 0
@@ -80,6 +82,39 @@ defattr == 1 {
        defattr = 0
 }
 
+function b_makekey(a, b,       s) {
+       s = a "" b;
+       # kill bcond
+       gsub("%{\\?[_a-zA-Z0-9]+:", "", s);
+       return s;
+}
+
+# sort BR/R!
+#
+# NOTES:
+# - mixing BR/R and anything else confuses this (all will be sorted together)
+#   so don't do that.
+# - comments leading the BR/R can not be associated,
+#   so don't adapterize when the BR/R are mixed with comments
+ENVIRON["SORTBR"] == 1 && preamble == 1 && /(Build)?Requires/, /(Build)?Requires/ { # && !/^%/) {
+       b_idx++;
+       b_ktmp = b_makekey($1, $2);
+       b_key[b_idx] = b_ktmp;
+       b_val[b_ktmp] = $0;
+
+       next;
+}
+
+preamble == 1 {
+       if (b_idx > 0) {
+               isort(b_key, b_idx);
+               for (i = 1; i <= b_idx; i++) {
+                       print "" b_val[b_key[i]];
+               }
+               b_idx = 0
+       }
+}
+
 # Comments
 /^#/ && (description == 0) {
        if (/This file does not like to be adapterized!/) {
@@ -349,7 +384,6 @@ defattr == 1 {
 }
 /^%post/, (/^%[a-z]+$/ && !/^%post/) {
        preamble = 0
-       use_macros()
 }
 /^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
        preamble = 0
@@ -568,7 +602,6 @@ preamble == 1 {
        }
 }
 
-
 # main() ;-)
 {
        preamble = 1
@@ -803,7 +836,7 @@ function use_files_macros(  i, n, t, a)
                        $0 = "%attr(754,root,root) " $0
                }
                if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
-                       gsub("^%attr\(... *,", "%attr(754,");
+                       gsub("^%attr\\(... *,", "%attr(754,");
                }
        }
 
@@ -824,7 +857,7 @@ function use_files_macros(  i, n, t, a)
                }
 
                if (/\/etc\/sysconfig\// && /%attr\(755/) {
-                       gsub("^%attr\(... *,", "%attr(640,");
+                       gsub("^%attr\\(... *,", "%attr(640,");
                }
 
                if (/\/etc\/sysconfig\// && !/%verify/) {
@@ -834,7 +867,7 @@ function use_files_macros(  i, n, t, a)
 
 
        # kill leading zeros
-       gsub("%attr\(0", "%attr(")
+       gsub("%attr\\(0", "%attr(")
 
        # sort %verify attrs
        if (match($0, /%verify\(not([^)]+)\)/)) {
This page took 0.038688 seconds and 4 git commands to generate.