-# 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)
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))
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)