diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-03-14 06:53:25 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-03-14 06:53:25 +0000 |
commit | c4e0feffe388409178a3c487053636ac5398f9af (patch) | |
tree | cb0a2b144e6c3e7f7cea217fb8f72a2e63d5a1b7 | |
parent | 57591010d41c37479dbc43acacfaa21d9a906bd8 (diff) | |
download | portage-c4e0feffe388409178a3c487053636ac5398f9af.tar.gz portage-c4e0feffe388409178a3c487053636ac5398f9af.tar.bz2 portage-c4e0feffe388409178a3c487053636ac5398f9af.zip |
Bug #42456 - When a checksum failure occurs during fetch, use a new
PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS config variable to control how
many mirrors should be tried before aborting the download. This type
of behavior used to be enabled only in --fetchonly mode but now
it's enabled for all fetch() calls.
svn path=/main/trunk/; revision=9463
-rw-r--r-- | cnf/make.globals | 3 | ||||
-rw-r--r-- | man/make.conf.5 | 3 | ||||
-rw-r--r-- | pym/portage/__init__.py | 30 |
3 files changed, 31 insertions, 5 deletions
diff --git a/cnf/make.globals b/cnf/make.globals index 9023dab6b..4b73a2f36 100644 --- a/cnf/make.globals +++ b/cnf/make.globals @@ -51,6 +51,9 @@ EMERGE_WARNING_DELAY="10" # This option will be removed and forced to yes. AUTOCLEAN="yes" +# Number mirrors to try when a downloaded file has an incorrect checksum. +PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5" + # Number of times 'emerge --sync' will run before giving up. PORTAGE_RSYNC_RETRIES="3" diff --git a/man/make.conf.5 b/man/make.conf.5 index e02bcd9eb..aa4623a5d 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -402,6 +402,9 @@ This variable contains flags for the \fBPORTAGE_COMPRESS\fR command. .B PORTAGE_ELOG_MAILSUBJECT Please see /etc/make.conf.example for elog documentation. .TP +\fBPORTAGE_FETCH_CHECKSUM_TRY_MIRRORS\fR = \fI5\fR +Number mirrors to try when a downloaded file has an incorrect checksum. +.TP \fBPORTAGE_NICENESS\fR = \fI[number]\fR The value of this variable will be added to the current nice level that emerge is running at. In other words, this will not set the nice level, diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 8e146c45b..adfdc8730 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -936,7 +936,8 @@ class config(object): "PORTAGE_BINHOST_CHUNKSIZE", "PORTAGE_CALLER", "PORTAGE_ECLASS_WARNING_ENABLE", "PORTAGE_ELOG_CLASSES", "PORTAGE_ELOG_MAILFROM", "PORTAGE_ELOG_MAILSUBJECT", - "PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM", "PORTAGE_GPG_DIR", + "PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM", + "PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS", "PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY", "PORTAGE_PACKAGE_EMPTY_ABORT", "PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS", "PORTAGE_RSYNC_RETRIES", "PORTAGE_USE", "PORT_LOGDIR", @@ -3026,6 +3027,28 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", # every single available mirror is a waste of bandwidth # and time, so there needs to be a cap. checksum_failure_max_tries = 5 + v = checksum_failure_max_tries + try: + v = int(mysettings.get("PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS", + checksum_failure_max_tries)) + except (ValueError, OverflowError): + writemsg("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" + \ + " contains non-integer value: '%s'\n" % \ + mysettings["PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"], noiselevel=-1) + writemsg("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " + \ + "default value: %s\n" % checksum_failure_max_tries, + noiselevel=-1) + v = checksum_failure_max_tries + if v < 1: + writemsg("!!! Variable PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" + \ + " contains value less than 1: '%s'\n" % v, noiselevel=-1) + writemsg("!!! Using PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " + \ + "default value: %s\n" % checksum_failure_max_tries, + noiselevel=-1) + v = checksum_failure_max_tries + checksum_failure_max_tries = v + del v + # Behave like the package has RESTRICT="primaryuri" after a # couple of checksum failures, to increase the probablility # of success before checksum_failure_max_tries is reached. @@ -3479,10 +3502,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", pass fetched = 1 continue - if not fetchonly: - fetched=2 - break - else: + if True: # File is the correct size--check the checksums for the fetched # file NOW, for those users who don't have a stable/continuous # net connection. This way we have a chance to try to download |