From 722000c545d7c23764382685d70819e42c11ead8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 10 Sep 2010 18:39:42 -0700 Subject: Remove pkg_nofetch code from the fetch() function since it's currently broken (doebuild_environment raises TypeError due to missing mydbapi parameter) and this is a poor place to spawn pkg_nofetch anyway, especially given that the caller does not even pass in a portdbapi instance. For now, relocate the pkg_nofetch execution to EbuildBuild so that it works for emerge. TODO: Add pkg_nofetch support to fetch() callers where appropriate. --- pym/_emerge/EbuildBuild.py | 17 ++++++------- pym/portage/package/ebuild/fetch.py | 49 ------------------------------------- 2 files changed, 8 insertions(+), 58 deletions(-) diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index 28ef7d074..6d42b1fbb 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -193,19 +193,18 @@ class EbuildBuild(CompositeTask): 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: + # We only call the pkg_nofetch phase if either RESTRICT=fetch + # is set or the package has explicitly overridden the default + # pkg_nofetch implementation. This allows specialized messages + # to be displayed for problematic packages even though they do + # not set RESTRICT=fetch (bug #336499). + + if 'fetch' not in self.pkg.metadata.restrict and \ + '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) diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index d5ad7f827..2c7f00703 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -1054,55 +1054,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", (mysettings["CATEGORY"], mysettings["PF"]) writemsg_level(msg, level=logging.ERROR, noiselevel=-1) - have_builddir = "PORTAGE_BUILDDIR" in mysettings and \ - os.path.isdir(mysettings["PORTAGE_BUILDDIR"]) - - global_tmpdir = mysettings["PORTAGE_TMPDIR"] - private_tmpdir = None - if not parallel_fetchonly and not have_builddir: - # When called by digestgen(), it's normal that - # PORTAGE_BUILDDIR doesn't exist. It's helpful - # to show the pkg_nofetch output though, so go - # ahead and create a temporary PORTAGE_BUILDDIR. - # Use a temporary config instance to avoid altering - # the state of the one that's been passed in. - mysettings = config(clone=mysettings) - try: - private_tmpdir = tempfile.mkdtemp("", "._portage_fetch_.", - global_tmpdir) - except OSError as e: - if e.errno != PermissionDenied.errno: - raise - raise PermissionDenied(global_tmpdir) - mysettings["PORTAGE_TMPDIR"] = private_tmpdir - mysettings.backup_changes("PORTAGE_TMPDIR") - debug = mysettings.get("PORTAGE_DEBUG") == "1" - doebuild_environment(mysettings["EBUILD"], "fetch", - mysettings["ROOT"], mysettings, debug, 1, None) - prepare_build_dirs(mysettings["ROOT"], mysettings, 0) - have_builddir = True - - if not parallel_fetchonly and have_builddir: - # To spawn pkg_nofetch requires PORTAGE_BUILDDIR for - # ensuring sane $PWD (bug #239560) and storing elog - # messages. Therefore, calling code needs to ensure that - # PORTAGE_BUILDDIR is already clean and locked here. - - # All the pkg_nofetch goes to stderr since it's considered - # to be an error message. - fd_pipes = { - 0 : sys.stdin.fileno(), - 1 : sys.stderr.fileno(), - 2 : sys.stderr.fileno(), - } - - try: - _doebuild_spawn("nofetch", mysettings, fd_pipes=fd_pipes) - finally: - if private_tmpdir is not None: - shutil.rmtree(private_tmpdir) - private_tmpdir = None - elif restrict_fetch: pass elif listonly: -- cgit v1.2.3-1-g7c22