primaryuri: prefer thirdpartymirrors in SRC_URI
authorZac Medico <zmedico@gentoo.org>
Fri, 21 Sep 2012 18:00:29 +0000 (11:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 21 Sep 2012 18:01:14 +0000 (11:01 -0700)
This will fix bug #435720.

pym/portage/package/ebuild/fetch.py

index 260bf10bb4701f5fe138c8be8fe37e5c85c5e73b..63b4c0a290e31b5a6c6e15e3f6d76ecc32764151 100644 (file)
@@ -429,10 +429,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
 
                                # now try the official mirrors
                                if mirrorname in thirdpartymirrors:
-                                       random.shuffle(thirdpartymirrors[mirrorname])
-
                                        uris = [locmirr.rstrip("/") + "/" + path \
                                                for locmirr in thirdpartymirrors[mirrorname]]
+                                       random.shuffle(uris)
                                        filedict[myfile].extend(uris)
                                        thirdpartymirror_uris.setdefault(myfile, []).extend(uris)
 
@@ -445,15 +444,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
                        if restrict_fetch or force_mirror:
                                # Only fetch from specific mirrors is allowed.
                                continue
-                       if "primaryuri" in restrict:
-                               # Use the source site first.
-                               if myfile in primaryuri_indexes:
-                                       primaryuri_indexes[myfile] += 1
-                               else:
-                                       primaryuri_indexes[myfile] = 0
-                               filedict[myfile].insert(primaryuri_indexes[myfile], myuri)
-                       else:
-                               filedict[myfile].append(myuri)
                        primaryuris = primaryuri_dict.get(myfile)
                        if primaryuris is None:
                                primaryuris = []
@@ -465,6 +455,15 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
        for myfile, uris in thirdpartymirror_uris.items():
                primaryuri_dict.setdefault(myfile, []).extend(uris)
 
+       # Now merge primaryuri values into filedict (includes mirrors
+       # explicitly referenced in SRC_URI).
+       if "primaryuri" in restrict:
+               for myfile, uris in filedict.items():
+                       filedict[myfile] = primaryuri_dict.get(myfile, []) + uris
+       else:
+               for myfile in filedict:
+                       filedict[myfile] += primaryuri_dict.get(myfile, [])
+
        can_fetch=True
 
        if listonly: