summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-16 04:57:08 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-16 04:57:08 -0700
commit447bd43b4af0002365d6387e2f634543c8787b91 (patch)
tree94b2a4cea630edd60428c6defb4125c2f138b4f5 /pym
parent063f0b5b4b73dabab395f8b7eab8345b0bc54f97 (diff)
downloadportage-447bd43b4af0002365d6387e2f634543c8787b91.tar.gz
portage-447bd43b4af0002365d6387e2f634543c8787b91.tar.bz2
portage-447bd43b4af0002365d6387e2f634543c8787b91.zip
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.
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/EbuildBinpkg.py55
-rw-r--r--pym/_emerge/MiscFunctionsProcess.py7
2 files changed, 33 insertions, 29 deletions
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)