[packages/adapter: 69/631] - fixed problem with substitutions: .zip -> .%{name} (zip.spec) .tar.gz -> .%{name}.gz (tar.spec)

glen glen at pld-linux.org
Mon Sep 12 19:40:15 CEST 2016


commit fd8718a51a80fb1781e8bd9d49664a1496b8d09e
Author: Sebastian Zagrodzki <sebek at zagrodzki.net>
Date:   Mon Aug 7 13:27:53 2000 +0000

    - fixed problem with substitutions:
            .zip -> .%{name} (zip.spec)
            .tar.gz -> .%{name}.gz (tar.spec)
            .patch -> .%{name} (patch.spec)
    - fixed problem with regexps in filenames - (try to use fixedsub() where
      possible)
    
    Changed files:
        adapter.awk -> 1.69

 adapter.awk | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/adapter.awk b/adapter.awk
index cbc094b..5b71a17 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -329,10 +329,31 @@ preamble == 1 {
 	# Use %{name} and %{version} in the filenames in "Source:"
 	if (field ~ /source/ || field ~ /patch/) {
 		n = split($2, url, /\//)
+		if (url[n] ~ /\.gz$/) {
+			url[n+1] = ".gz" url[n+1]
+			sub(/\.gz$/,"",url[n])
+		}
+		if (url[n] ~ /\.zip$/) {
+			url[n+1] = ".zip" url[n+1]
+			sub(/\.zip$/,"",url[n])
+		}
+		if (url[n] ~ /\.tar$/) {
+			url[n+1] = ".tar" url[n+1]
+			sub(/\.tar$/,"",url[n])
+		}
+		if (url[n] ~ /\.patch$/) {
+			url[n+1] = ".patch" url[n+1]
+			sub(/\.patch$/,"",url[n])
+		}
+		if (url[n] ~ /\.bz2$/) {
+			url[n+1] = ".bz2" url[n+1]
+			sub(/\.bz2$/,"",url[n])
+		}
 		filename = url[n]
-		sub(name, "%{name}", url[n])
-		if (field ~ /source/) sub(version, "%{version}", url[n])
-		sub(filename, url[n], $2)
+		url[n] = fixedsub(name, "%{name}", url[n])
+		if (field ~ /source/) 
+			url[n] = fixedsub(version, "%{version}", url[n])
+		$2 = fixedsub(filename, url[n], $2)
 	}
 
 	if (field ~ /source:/)
@@ -410,6 +431,13 @@ END {
 	}
 }
 
+function fixedsub(s1,s2,t,      ind) {
+# substitutes fixed strings (not regexps)
+        if (ind = index(t,s1))
+                t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
+        return t
+}
+
 # There should be one or two tabs after the colon.
 function format_preamble()
 {
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list