[packages/adapter: 131/631] - sort %verify attrs

glen glen at pld-linux.org
Mon Sep 12 19:45:26 CEST 2016


commit 7c23055b2ad96f5cfedb1e525680d3a3ad73bae5
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Sun Feb 13 20:40:00 2005 +0000

    - sort %verify attrs
    
    Changed files:
        adapter.awk -> 1.126

 adapter.awk | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/adapter.awk b/adapter.awk
index a247e08..ba927b4 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -627,10 +627,41 @@ function use_macros()
 	gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
 }
 
-function use_files_macros()
+
+# insertion sort of A[1..n]
+# copied from mawk manual
+function isort(A,n,		i,j,hold) {
+	for (i = 2; i <= n; i++) {
+		hold = A[j = i]
+		while (A[j-1] > hold) {
+		   	j-- ; A[j+1] = A[j]
+	   	}
+		A[j] = hold
+	}
+	# sentinel A[0] = "" will be created if needed
+}
+
+
+function use_files_macros(	i, n, t, a)
 {
 	gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
 	gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
+
+	# sort %verify attrs
+	if (match($0, /%verify\(not (.*)\)/)) {
+		t = substr($0, RSTART, RLENGTH)
+		gsub(/^%verify\(not |\)$/, "", t)
+		n = split(t, a, / /)
+		isort(a, n)
+
+		s = "%verify(not"
+		for (i = 1 ; i <= n; i++) {
+			s = s " " a[i]
+		}
+		s = s ")"
+
+		gsub(/%verify\(not .*\)/, s)
+	}
 }
 
 function fill(ch, n, i) {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/adapter.git/commitdiff/6ca0126d4d0c8c79feb7db10b0a0fade0f3b8885



More information about the pld-cvs-commit mailing list