SPECS: adapter.awk - set order for other preamble tags

glen glen at pld-linux.org
Mon Dec 26 23:57:05 CET 2005


Author: glen                         Date: Mon Dec 26 22:57:05 2005 GMT
Module: SPECS                         Tag: HEAD
---- Log message:
- set order for other preamble tags

---- Files affected:
SPECS:
   adapter.awk (1.250 -> 1.251) 

---- Diffs:

================================================================
Index: SPECS/adapter.awk
diff -u SPECS/adapter.awk:1.250 SPECS/adapter.awk:1.251
--- SPECS/adapter.awk:1.250	Mon Dec 26 21:06:04 2005
+++ SPECS/adapter.awk	Mon Dec 26 23:57:00 2005
@@ -27,6 +27,8 @@
 	RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun"
 	SECTIONS = "^%(" RPM_SECTIONS ")"
 
+	PREAMBLE_TAGS = "(Summary|Name|Version|Release|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Provides|PreReq|(Build)?Requires)"
+
 	preamble = 1		# Is it part of preamble? Default - yes
 	boc = 4			# Beginning of %changelog
 	bod = 0			# Beginning of %description
@@ -108,51 +110,22 @@
 	# kill commented out items
     gsub(/[# \t]*/, "", s);
 
-	# hack: change Obsoletes -> ZObsoletes to sort as last
-    gsub(/^Provides/, "YProvides", s);
-    gsub(/^Obsoletes/, "ZObsoletes", s);
+	# force order
+    gsub(/^Summary/, "1Summary", s);
+    gsub(/^Name/, "2Name", s);
+    gsub(/^Version/, "3Version", s);
+    gsub(/^Release/, "4Release", s);
+    gsub(/^License/, "5License", s);
+    gsub(/^Group/, "6Group", s);
+    gsub(/^URL/, "7URL", s);
+
+    gsub(/^Provides/, "XProvides", s);
+    gsub(/^Obsoletes/, "YObsoletes", s);
+    gsub(/^BuildArch/, "ZBuildArch", s);
+    gsub(/^BuildRoot/, "ZBuildRoot", 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["SKIP_SORTBR"] != 1 && preamble == 1 && /(Obsoletes|Provides|PreReq|(Build)?Requires)/, /(Obsoletes|Provides|PreReq|(Build)?Requires)/ {
-	if ($1 ~ /PreReq:/) {
-		sub(/PreReq:/, "Requires:", $1);
-	}
-	format_preamble()
-	kill_preamble_macros();
-
-	b_idx++;
-	l = substr($0, index($0, $2));
-	b_ktmp = b_makekey($1, l);
-	b_key[b_idx] = b_ktmp;
-	b_val[b_ktmp] = $0;
-
-	next;
-}
-
-/^%bcond_/ {
-	# do nothing
-	print
-	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!/) {
@@ -770,6 +743,46 @@
 	if (field ~ /requires/) {
 		# atrpms
 		$0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
+	}
+}
+
+
+# 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["SKIP_SORTBR"] != 1 && preamble == 1 && $0 ~ PREAMBLE_TAGS, $0 ~ PREAMBLE_TAGS {
+	if ($1 ~ /PreReq:/) {
+		sub(/PreReq:/, "Requires:", $1);
+	}
+	format_preamble()
+	kill_preamble_macros();
+
+	b_idx++;
+	l = substr($0, index($0, $2));
+	b_ktmp = b_makekey($1, l);
+	b_key[b_idx] = b_ktmp;
+	b_val[b_ktmp] = $0;
+
+	next;
+}
+
+/^%bcond_/ {
+	# do nothing
+	print
+	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
 	}
 }
 
================================================================

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



More information about the pld-cvs-commit mailing list