commit 9b781bebbfb142d135891f772d6ff760270d3a2e
Author: Elan Ruusamäe <[email protected]>
Date:   Wed Feb 9 14:38:13 2011 +0000

    - sf url unify
    
    Changed files:
        adapter.awk -> 1.488

 adapter.awk | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/adapter.awk b/adapter.awk
index fb2e415..f7a4e49 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -1663,12 +1663,18 @@ function cflags(var)
        return 1
 }
 
+# return whole matched pattern
+function matchstr(str, pat)
+{
+       match(str, "[^/]+$");
+       return substr(str, RSTART, RLENGTH);
+}
+
 function unify_url(url)
 {
 
        # sourceforge urls
        # Docs about sourceforge mirror system: 
http://sourceforge.net/apps/trac/sourceforge/wiki/Mirrors
-       # TODO: SF unify: http://downloads.sourceforge.net/PROJECT/TARBALL
 
        # 1. unify domains
        sub("^http://prdownloads\.sourceforge\.net/";, 
"http://downloads.sourceforge.net/";, url)
@@ -1679,13 +1685,6 @@ function unify_url(url)
        sub("^http://dl\.sf\.net/";, "http://downloads.sourceforge.net/";, url)
        sub("^http://downloads\.sourceforge\.net/sourceforge/";, 
"http://downloads.sourceforge.net/";, url)
 
-       # 2. special hacks
-       # new style urls, strip "files/" between and prepend dl.
-       if (match(url, "^http://sourceforge.net/projects/[^/]+/files/";)) {
-               url = substr(url, 1, RLENGTH - length("files/")) substr(url, 
RSTART + RLENGTH);
-               sub("^http://sourceforge.net/projects/";, 
"http://downloads.sourceforge.net/project/";, url);
-       }
-
        # 3. unify urls
        if (url ~ /sourceforge.net/) {
                sub("[?&]big_mirror=.*$", "", url);
@@ -1695,6 +1694,18 @@ function unify_url(url)
                sub("/download$", "", url);
        }
 
+       # SF: new style urls, strip "files/" between and prepend dl.
+       if (match(url, "^http://sourceforge.net/projects/[^/]+/files/";)) {
+               url = substr(url, 1, RLENGTH - length("files/")) substr(url, 
RSTART + RLENGTH);
+               sub("^http://sourceforge.net/projects/";, 
"http://downloads.sourceforge.net/project/";, url);
+       }
+
+       # SF unify: http://downloads.sourceforge.net/PROJECT/TARBALL
+       # 
http://downloads.sourceforge.net/project/PROJECT/FILE/VERSION/%{name}-%{version}.zip
+       if (match(url, "^http://downloads.sourceforge.net/project/[^/]+";)) {
+               url = sprintf("http://downloads.sourceforge.net/%s/%s";, 
substr(url, 42, RLENGTH - 41), matchstr(url, "[^/]+$"));
+       }
+
        sub("^ftp://ftp\.gnome\.org/";, "http://ftp.gnome.org/";, url)
        sub("^http://ftp\.gnome\.org/pub/gnome/";, 
"http://ftp.gnome.org/pub/GNOME/";, url)
 
================================================================

---- gitweb:

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

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to