Inside portage.fetch(), check for the case where FETCOMMAND creates a
authorZac Medico <zmedico@gentoo.org>
Thu, 12 Feb 2009 03:53:07 +0000 (03:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 Feb 2009 03:53:07 +0000 (03:53 -0000)
directory where a file is expected. This can happen if FETCHCOMMAND
erroneously contains wget's -P option where it should instead have -O, as
reported in bug #258433, comment #16.

svn path=/main/trunk/; revision=12601

pym/portage/__init__.py

index 3c4ceb8191ebd38bf3ff4dc3e494e273930caa8d..de36e060bbdc2e833e3f03c429f2354c4e0f77a9 100644 (file)
@@ -3816,6 +3816,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                pass
 
                                if mystat is not None:
+                                       if stat.S_ISDIR(mystat.st_mode):
+                                               portage.util.writemsg_level(
+                                                       ("!!! Unable to fetch file since " + \
+                                                       "a directory is in the way: \n" + \
+                                                       "!!!   %s\n") % myfile_path,
+                                                       level=logging.ERROR, noiselevel=-1)
+                                               return 0
+
                                        if mystat.st_size == 0:
                                                if distdir_writable:
                                                        try:
@@ -4065,9 +4073,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                #resume mode:
                                                writemsg(">>> Resuming download...\n")
                                                locfetch=resumecommand
+                                               command_var = resumecommand_var
                                        else:
                                                #normal mode:
                                                locfetch=fetchcommand
+                                               command_var = fetchcommand_var
                                        writemsg_stdout(">>> Downloading '%s'\n" % \
                                                re.sub(r'//(.+):.+@(.+)/',r'//\1:*password*@\2/', loc))
                                        variables = {
@@ -4115,6 +4125,25 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                        del e
                                                        fetched = 0
                                                else:
+
+                                                       if stat.S_ISDIR(mystat.st_mode):
+                                                               # This can happen if FETCHCOMMAND erroneously
+                                                               # contains wget's -P option where it should
+                                                               # instead have -O.
+                                                               portage.util.writemsg_level(
+                                                                       ("!!! The command specified in the " + \
+                                                                       "%s variable appears to have\n!!! " + \
+                                                                       "created a directory instead of a " + \
+                                                                       "normal file.\n") % command_var,
+                                                                       level=logging.ERROR, noiselevel=-1)
+                                                               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)
+                                                               return 0
+
                                                        # no exception?  file exists. let digestcheck() report
                                                        # an appropriately for size or checksum errors