Bug #258433 - In portage.fetch(), check for missing ${FILE} parameter in
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 03:54:02 +0000 (03:54 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 03:54:02 +0000 (03:54 -0000)
FETCHCOMMAND or RESUMECOMMAND and bail out early if necessary. (trunk r12600)

svn path=/main/branches/2.1.6/; revision=12881

pym/portage/__init__.py

index ae4e7a1200a17a8b77f6243c1c4ff0f457ecf05b..3c2807a53b0b29293bc252afc7a2575ed33a7dae 100644 (file)
@@ -3641,10 +3641,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
@@ -3959,14 +3955,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:
@@ -3987,11 +4025,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