From: Zac Medico Date: Mon, 16 Aug 2010 11:57:08 +0000 (-0700) Subject: Convert EbuildBinpkg to inherit from MiscFunctionsProcess instead X-Git-Tag: v2.2_rc68~162 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=447bd43b4af0002365d6387e2f634543c8787b91;p=portage.git Convert EbuildBinpkg to inherit from MiscFunctionsProcess instead of EbuildProcess. This bypasses the complex doebuild() function, and uses the _spawn_actionmap() function that's been split out. --- diff --git a/pym/_emerge/EbuildBinpkg.py b/pym/_emerge/EbuildBinpkg.py index 103f2b5f1..0ec2871af 100644 --- a/pym/_emerge/EbuildBinpkg.py +++ b/pym/_emerge/EbuildBinpkg.py @@ -1,46 +1,53 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -from _emerge.EbuildProcess import EbuildProcess +from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from portage import os +from portage.exception import PermissionDenied +from portage.package.ebuild.doebuild import _spawn_actionmap +from portage.package.ebuild.doebuild import spawn as doebuild_spawn +from portage.util import ensure_dirs -class EbuildBinpkg(EbuildProcess): +class EbuildBinpkg(MiscFunctionsProcess): """ This assumes that src_install() has successfully completed. """ __slots__ = ("_binpkg_tmpfile",) + def __init__(self, **kwargs): + MiscFunctionsProcess.__init__(self, phase="package", **kwargs) + def _start(self): - self.phase = "package" - self.tree = "porttree" pkg = self.pkg root_config = pkg.root_config - portdb = root_config.trees["porttree"].dbapi bintree = root_config.trees["bintree"] - ebuild_path = portdb.findname(pkg.cpv) - if ebuild_path is None: - raise AssertionError("ebuild not found for '%s'" % pkg.cpv) - settings = self.settings - debug = settings.get("PORTAGE_DEBUG") == "1" - bintree.prevent_collision(pkg.cpv) binpkg_tmpfile = os.path.join(bintree.pkgdir, pkg.cpv + ".tbz2." + str(os.getpid())) - self._binpkg_tmpfile = binpkg_tmpfile - settings["PORTAGE_BINPKG_TMPFILE"] = binpkg_tmpfile - settings.backup_changes("PORTAGE_BINPKG_TMPFILE") + parent_dir = os.path.dirname(binpkg_tmpfile) + ensure_dirs(parent_dir) + if not os.access(parent_dir, os.W_OK): + raise PermissionDenied( + "access('%s', os.W_OK)" % parent_dir) + self._binpkg_tmpfile = binpkg_tmpfile + self.logfile = self.settings.get("PORTAGE_LOG_FILE") + self.commands = ["dyn_" + self.phase] + MiscFunctionsProcess._start(self) + + def _spawn(self, args, **kwargs): + self.settings["EBUILD_PHASE"] = self.phase + self.settings["PORTAGE_BINPKG_TMPFILE"] = self._binpkg_tmpfile + kwargs.update(_spawn_actionmap(self.settings)[self.phase]["args"]) try: - EbuildProcess._start(self) + return doebuild_spawn(" ".join(args), self.settings, **kwargs) finally: - settings.pop("PORTAGE_BINPKG_TMPFILE", None) + self.settings.pop("EBUILD_PHASE", None) + self.settings.pop("PORTAGE_BINPKG_TMPFILE", None) def _set_returncode(self, wait_retval): - EbuildProcess._set_returncode(self, wait_retval) - - pkg = self.pkg - bintree = pkg.root_config.trees["bintree"] - binpkg_tmpfile = self._binpkg_tmpfile + MiscFunctionsProcess._set_returncode(self, wait_retval) if self.returncode == os.EX_OK: - bintree.inject(pkg.cpv, filename=binpkg_tmpfile) - + pkg = self.pkg + bintree = pkg.root_config.trees["bintree"] + bintree.inject(pkg.cpv, filename=self._binpkg_tmpfile) diff --git a/pym/_emerge/MiscFunctionsProcess.py b/pym/_emerge/MiscFunctionsProcess.py index eaf8c2235..04445a89d 100644 --- a/pym/_emerge/MiscFunctionsProcess.py +++ b/pym/_emerge/MiscFunctionsProcess.py @@ -15,7 +15,6 @@ class MiscFunctionsProcess(AbstractEbuildProcess): def _start(self): settings = self.settings - settings.pop("EBUILD_PHASE", None) portage_bin_path = settings["PORTAGE_BIN_PATH"] misc_sh_binary = os.path.join(portage_bin_path, os.path.basename(portage.const.MISC_SH_BINARY)) @@ -26,7 +25,5 @@ class MiscFunctionsProcess(AbstractEbuildProcess): AbstractEbuildProcess._start(self) def _spawn(self, args, **kwargs): - settings = self.settings - debug = settings.get("PORTAGE_DEBUG") == "1" - return spawn(" ".join(args), settings, - debug=debug, **kwargs) + self.settings.pop("EBUILD_PHASE", None) + return spawn(" ".join(args), self.settings, **kwargs)