From: Zac Medico Date: Thu, 12 Feb 2009 03:20:05 +0000 (-0000) Subject: Bug #258433 - In portage.fetch(), check for missing ${FILE} parameter in X-Git-Tag: v2.2_rc24~202 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=676495936bdde5a8992e867d963381fcfecbeec6;p=portage.git Bug #258433 - In portage.fetch(), check for missing ${FILE} parameter in FETCHCOMMAND or RESUMECOMMAND and bail out early if necessary. svn path=/main/trunk/; revision=12600 --- diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 7fcebe949..3c4ceb819 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3651,10 +3651,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", if listonly: can_fetch = False - for var_name in ("FETCHCOMMAND", "RESUMECOMMAND"): - if not mysettings.get(var_name, None): - can_fetch = False - if can_fetch and not fetch_to_ro: global _userpriv_test_write_file_cache dirmode = 02070 @@ -3969,14 +3965,56 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", continue # allow different fetchcommands per protocol protocol = loc[0:loc.find("://")] - if "FETCHCOMMAND_" + protocol.upper() in mysettings: - fetchcommand=mysettings["FETCHCOMMAND_"+protocol.upper()] - else: - fetchcommand=mysettings["FETCHCOMMAND"] - if "RESUMECOMMAND_" + protocol.upper() in mysettings: - resumecommand=mysettings["RESUMECOMMAND_"+protocol.upper()] - else: - resumecommand=mysettings["RESUMECOMMAND"] + + missing_file_param = False + fetchcommand_var = "FETCHCOMMAND_" + protocol.upper() + fetchcommand = mysettings.get(fetchcommand_var) + if fetchcommand is None: + fetchcommand_var = "FETCHCOMMAND" + fetchcommand = mysettings.get(fetchcommand_var) + if fetchcommand is None: + portage.util.writemsg_level( + ("!!! %s is unset. It should " + \ + "have been defined in\n!!! %s/make.globals.\n") \ + % (fetchcommand_var, + portage.const.GLOBAL_CONFIG_PATH), + level=logging.ERROR, noiselevel=-1) + return 0 + if "${FILE}" not in fetchcommand: + portage.util.writemsg_level( + ("!!! %s does not contain the required ${FILE}" + \ + " parameter.\n") % fetchcommand_var, + level=logging.ERROR, noiselevel=-1) + missing_file_param = True + + resumecommand_var = "RESUMECOMMAND_" + protocol.upper() + resumecommand = mysettings.get(resumecommand_var) + if resumecommand is None: + resumecommand_var = "RESUMECOMMAND" + resumecommand = mysettings.get(resumecommand_var) + if resumecommand is None: + portage.util.writemsg_level( + ("!!! %s is unset. It should " + \ + "have been defined in\n!!! %s/make.globals.\n") \ + % (resumecommand_var, + portage.const.GLOBAL_CONFIG_PATH), + noiselevel=-1) + return 0 + if "${FILE}" not in resumecommand: + portage.util.writemsg_level( + ("!!! %s does not contain the required ${FILE}" + \ + " parameter.\n") % resumecommand_var, + level=logging.ERROR, noiselevel=-1) + missing_file_param = True + + if missing_file_param: + portage.util.writemsg_level( + "!!! Refer to the make.conf(5) man page for " + \ + "information about how to\n!!! correctly specify " + \ + "FETCHCOMMAND and RESUMECOMMAND.\n", + level=logging.ERROR, noiselevel=-1) + if myfile != os.path.basename(loc): + return 0 if not can_fetch: if fetched != 2: @@ -3997,11 +4035,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: writemsg(("!!! File %s is incorrect size, " + \ "but unable to retry.\n") % myfile, noiselevel=-1) - for var_name in ("FETCHCOMMAND", "RESUMECOMMAND"): - if not mysettings.get(var_name, None): - writemsg(("!!! %s is unset. It should " + \ - "have been defined in /etc/make.globals.\n") \ - % var_name, noiselevel=-1) return 0 else: continue