Bug #336499 - If RESTRICT=fetch is not set but pkg_nofetch is defined,
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Sep 2010 23:47:45 +0000 (16:47 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Sep 2010 23:47:45 +0000 (16:47 -0700)
go ahead and run pkg_nofetch upon fetch failure. This allows specialized
messages to be displayed for problematic packages.

pym/_emerge/EbuildBuild.py

index b319596aca314d7120a0fe37a3c263beb2edc19b..ecf9f6c432032c9ef795ca37342d8da5a37162e3 100644 (file)
@@ -153,8 +153,7 @@ class EbuildBuild(CompositeTask):
                portage.elog.elog_process(self.pkg.cpv, self.settings)
 
                if self._default_exit(fetcher) != os.EX_OK:
-                       self._unlock_builddir()
-                       self.wait()
+                       self._fetch_failed()
                        return
 
                # discard successful fetch log
@@ -195,6 +194,31 @@ class EbuildBuild(CompositeTask):
                        scheduler=scheduler, settings=settings)
                self._start_task(build, self._build_exit)
 
+       def _fetch_failed(self):
+               # If RESTRICT=fetch is set, then the nofetch phase
+               # should have been executed already, so don't do
+               # it again.
+               if 'fetch' in self.pkg.metadata.restrict or \
+               'nofetch' not in self.pkg.metadata.defined_phases:
+                       self._unlock_builddir()
+                       self.wait()
+                       return
+
+               # The package has defined a pkg_nofetch phase, even
+               # though RESTRICT=fetch is not set, so go ahead and
+               # run it. This allows specialized messages to be
+               # displayed for problematic packages (bug #336499).
+               self.returncode = None
+               nofetch_phase = EbuildPhase(background=self.background,
+                       phase='nofetch', scheduler=self.scheduler, settings=self.settings)
+               self._start_task(nofetch_phase, self._nofetch_exit)
+
+       def _nofetch_exit(self, nofetch_phase):
+               self._final_exit(nofetch_phase)
+               self._unlock_builddir()
+               self.returncode = 1
+               self.wait()
+
        def _unlock_builddir(self):
                portage.elog.elog_process(self.pkg.cpv, self.settings)
                self._build_dir.unlock()