SPECS: adapter.awk - sort BR/R.. sucks very much, but sometimes wo...

glen glen at pld-linux.org
Tue Aug 16 00:06:45 CEST 2005


Author: glen                         Date: Mon Aug 15 22:06:45 2005 GMT
Module: SPECS                         Tag: HEAD
---- Log message:
- sort BR/R.. sucks very much, but sometimes works. enable with ./adapter --sort-br option

---- Files affected:
SPECS:
   adapter.awk (1.170 -> 1.171) 

---- Diffs:

================================================================
Index: SPECS/adapter.awk
diff -u SPECS/adapter.awk:1.170 SPECS/adapter.awk:1.171
--- SPECS/adapter.awk:1.170	Mon Aug 15 22:19:22 2005
+++ SPECS/adapter.awk	Tue Aug 16 00:06:39 2005
@@ -23,6 +23,8 @@
 	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 = 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 @@
 }
 /^%post/, (/^%[a-z]+$/ && !/^%post/) {
 	preamble = 0
-	use_macros()
 }
 /^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
 	preamble = 0
@@ -568,7 +602,6 @@
 	}
 }
 
-
 # main() ;-)
 {
 	preamble = 1
@@ -803,7 +836,7 @@
 			$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 @@
 		}
 
 		if (/\/etc\/sysconfig\// && /%attr\(755/) {
-			gsub("^%attr\(... *,", "%attr(640,");
+			gsub("^%attr\\(... *,", "%attr(640,");
 		}
 
 		if (/\/etc\/sysconfig\// && !/%verify/) {
@@ -834,7 +867,7 @@
 
 
 	# kill leading zeros
-	gsub("%attr\(0", "%attr(")
+	gsub("%attr\\(0", "%attr(")
 
 	# sort %verify attrs
 	if (match($0, /%verify\(not([^)]+)\)/)) {
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SPECS/adapter.awk?r1=1.170&r2=1.171&f=u




More information about the pld-cvs-commit mailing list