From da57c314ce0b610e10939b0b7cf482c1fe38f8dc Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Sat, 4 Jun 2016 18:08:54 +0900 Subject: [PATCH] Add "gentoo-mirrors-shuffle" FEATURE to Portage Currently, the mirrors defined in GENTOO_MIRRORS are used in the order they appear in the configuration file (make.conf). In order to split the load of downloading packages across all listed mirrors more fairly than just using the first mirror, "gentoo-mirrors-shuffle" FEATURE can be enabled. This is added as a FEATURE and not a preset because the mirror ordering might be important for some users of Portage. This will also help relay the download requests to several mirrors when using parallel fetch reducing the chances of speed capping from the mirror. --- pym/portage/const.py | 1 + pym/portage/package/ebuild/fetch.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pym/portage/const.py b/pym/portage/const.py index 179efce..9bf3397 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -148,6 +148,7 @@ SUPPORTED_FEATURES = frozenset([ "force-mirror", "force-prefix", "getbinpkg", + "gentoo-mirrors-shuffle", "icecream", "installsources", "ipc-sandbox", diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 1be2800..7951055 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -364,7 +364,13 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, pass else: if try_mirrors: - mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] + if 'gentoo-mirrors-shuffle' in mysettings["FEATURES"]: + shuffled_mirrors = [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] + random.shuffle(shuffled_mirrors) + mymirrors += shuffled_mirrors + del shuffled_mirrors + else: + mymirrors += [x.rstrip("/") for x in mysettings["GENTOO_MIRRORS"].split() if x] hash_filter = _hash_filter(mysettings.get("PORTAGE_CHECKSUM_FILTER", "")) if hash_filter.transparent: -- 2.7.3