]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
- sf url unify
authorElan Ruusamäe <glen@pld-linux.org>
Wed, 9 Feb 2011 14:38:13 +0000 (14:38 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    adapter.awk -> 1.488

adapter.awk

index fb2e415fcf80adef3d9b142d56ea7611dcaba47c..f7a4e49f9d622110d25e134a445a1dd7155b9782 100644 (file)
@@ -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)
 
This page took 0.032407 seconds and 4 git commands to generate.