summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-17 06:39:17 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-17 06:39:17 -0700
commit21d2a70b316a7c3b6c9b9a9e81f1d2ab86ba98c7 (patch)
treed8ff4a2c24a2166397da66ff59d3b3f9b4dc04c0
parent71e9c8caf63805b8350c215ee27070d465115eee (diff)
downloadportage-21d2a70b316a7c3b6c9b9a9e81f1d2ab86ba98c7.tar.gz
portage-21d2a70b316a7c3b6c9b9a9e81f1d2ab86ba98c7.tar.bz2
portage-21d2a70b316a7c3b6c9b9a9e81f1d2ab86ba98c7.zip
Unify ebuild spawing some more. All proper ebuild phases which execute
ebuild.sh are spawned via _doebuild_spawn() now. No exceptions.
-rw-r--r--pym/_emerge/EbuildProcess.py29
-rw-r--r--pym/portage/package/ebuild/doebuild.py90
-rw-r--r--pym/portage/package/ebuild/fetch.py12
3 files changed, 56 insertions, 75 deletions
diff --git a/pym/_emerge/EbuildProcess.py b/pym/_emerge/EbuildProcess.py
index 70c724314..6a9c8df62 100644
--- a/pym/_emerge/EbuildProcess.py
+++ b/pym/_emerge/EbuildProcess.py
@@ -5,11 +5,9 @@ from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.package.ebuild.doebuild:_post_phase_userpriv_perms,' + \
- '_spawn_actionmap,_unsandboxed_phases,spawn@doebuild_spawn'
+ '_spawn_actionmap,_doebuild_spawn'
)
-from portage import _shell_quote
from portage import os
-from portage.const import EBUILD_SH_BINARY
class EbuildProcess(AbstractEbuildProcess):
@@ -24,30 +22,13 @@ class EbuildProcess(AbstractEbuildProcess):
AbstractEbuildProcess._start(self)
def _spawn(self, args, **kwargs):
- self.settings["EBUILD_PHASE"] = self.phase
- if self.phase in _unsandboxed_phases:
- kwargs['free'] = True
- if self.phase == 'depend':
- kwargs['droppriv'] = 'userpriv' in self.settings.features
+
actionmap = self.actionmap
if actionmap is None:
actionmap = _spawn_actionmap(self.settings)
- if self.phase in actionmap:
- kwargs.update(actionmap[self.phase]["args"])
- cmd = actionmap[self.phase]["cmd"] % self.phase
- else:
- if self.phase == 'cleanrm':
- ebuild_sh_arg = 'clean'
- else:
- ebuild_sh_arg = self.phase
-
- cmd = "%s %s" % (_shell_quote(os.path.join(
- self.settings["PORTAGE_BIN_PATH"],
- os.path.basename(EBUILD_SH_BINARY))), ebuild_sh_arg)
- try:
- return doebuild_spawn(cmd, self.settings, **kwargs)
- finally:
- self.settings.pop("EBUILD_PHASE", None)
+
+ return _doebuild_spawn(self.phase, self.settings,
+ actionmap, **kwargs)
def _set_returncode(self, wait_retval):
AbstractEbuildProcess._set_returncode(self, wait_retval)
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 355088036..9c9450feb 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -62,6 +62,50 @@ _unsandboxed_phases = frozenset([
"prerm", "setup"
])
+def _doebuild_spawn(phase, settings, actionmap=None, **kwargs):
+ """
+ All proper ebuild phases which execute ebuild.sh are spawned
+ via this function. No exceptions.
+ """
+
+ if phase in _unsandboxed_phases:
+ kwargs['free'] = True
+
+ if phase == 'depend':
+ kwargs['droppriv'] = 'userpriv' in settings.features
+
+ if actionmap is not None and phase in actionmap:
+ kwargs.update(actionmap[phase]["args"])
+ cmd = actionmap[phase]["cmd"] % phase
+ else:
+ if phase == 'cleanrm':
+ ebuild_sh_arg = 'clean'
+ else:
+ ebuild_sh_arg = phase
+
+ cmd = "%s %s" % (_shell_quote(
+ os.path.join(settings["PORTAGE_BIN_PATH"],
+ os.path.basename(EBUILD_SH_BINARY))),
+ ebuild_sh_arg)
+
+ settings['EBUILD_PHASE'] = phase
+ try:
+ return spawn(cmd, settings, **kwargs)
+ finally:
+ settings.pop('EBUILD_PHASE', None)
+
+def _spawn_phase(phase, settings, actionmap=None, **kwargs):
+ if kwargs.get('returnpid'):
+ return _doebuild_spawn(phase, settings, actionmap=actionmap, **kwargs)
+
+ task_scheduler = TaskScheduler()
+ ebuild_phase = EbuildPhase(background=False,
+ phase=phase, scheduler=task_scheduler.sched_iface,
+ settings=settings)
+ task_scheduler.add(ebuild_phase)
+ task_scheduler.run()
+ return ebuild_phase.returncode
+
def doebuild_environment(myebuild, mydo, myroot, mysettings,
debug, use_cache, mydbapi):
@@ -574,7 +618,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
if mydo in ("config", "help", "info", "postinst",
"preinst", "pretend", "postrm", "prerm", "setup"):
return _spawn_phase(mydo, mysettings,
- fd_pipes=fd_pipes, returnpid=returnpid)
+ fd_pipes=fd_pipes, logfile=logfile, returnpid=returnpid)
mycpv = "/".join((mysettings["CATEGORY"], mysettings["PF"]))
@@ -1079,30 +1123,6 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
return proc.returncode
-def _spawn_phase(phase, settings, **kwargs):
- if kwargs.get('returnpid'):
- if phase in _unsandboxed_phases:
- kwargs['free'] = True
- portage_bin_path = settings["PORTAGE_BIN_PATH"]
- ebuild_sh_binary = os.path.join(portage_bin_path,
- os.path.basename(EBUILD_SH_BINARY))
- if phase == 'cleanrm':
- ebuild_sh_arg = 'clean'
- else:
- ebuild_sh_arg = phase
- if phase == 'depend':
- kwargs['droppriv'] = 'userpriv' in settings.features
- return spawn("%s %s" % (_shell_quote(ebuild_sh_binary), ebuild_sh_arg),
- settings, **kwargs)
-
- task_scheduler = TaskScheduler()
- ebuild_phase = EbuildPhase(background=False,
- phase=phase, scheduler=task_scheduler.sched_iface,
- settings=settings)
- task_scheduler.add(ebuild_phase)
- task_scheduler.run()
- return ebuild_phase.returncode
-
# parse actionmap to spawn ebuild with the appropriate args
def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0,
logfile=None, fd_pipes=None, returnpid=False):
@@ -1124,23 +1144,9 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0,
if mydo == "pretend" and not eapi_has_pkg_pretend(eapi):
return os.EX_OK
- if returnpid:
- kwargs = actionmap[mydo]["args"]
- mysettings["EBUILD_PHASE"] = mydo
- try:
- return spawn(actionmap[mydo]["cmd"] % mydo,
- mysettings, debug=debug, logfile=logfile,
- fd_pipes=fd_pipes, returnpid=returnpid, **kwargs)
- finally:
- mysettings["EBUILD_PHASE"] = ""
-
- task_scheduler = TaskScheduler()
- ebuild_phase = EbuildPhase(actionmap=actionmap, background=False,
- phase=mydo, scheduler=task_scheduler.sched_iface,
- settings=mysettings)
- task_scheduler.add(ebuild_phase)
- task_scheduler.run()
- return ebuild_phase.returncode
+ return _spawn_phase(mydo, mysettings,
+ actionmap=actionmap, logfile=logfile,
+ fd_pipes=fd_pipes, returnpid=returnpid)
_post_phase_cmds = {
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
index 0481ed2b0..86d4db96d 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -20,7 +20,7 @@ import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.package.ebuild.config:check_config_instance,config',
'portage.package.ebuild.doebuild:doebuild_environment,' + \
- 'spawn@doebuild_spawn',
+ '_doebuild_spawn',
'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs',
)
@@ -1091,18 +1091,12 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
2 : sys.stderr.fileno(),
}
- ebuild_phase = mysettings.get("EBUILD_PHASE")
try:
- mysettings["EBUILD_PHASE"] = "nofetch"
- doebuild_spawn(_shell_quote(EBUILD_SH_BINARY) + \
- " nofetch", mysettings, fd_pipes=fd_pipes)
+ _doebuild_spawn("nofetch", mysettings, fd_pipes=fd_pipes)
finally:
- if ebuild_phase is None:
- mysettings.pop("EBUILD_PHASE", None)
- else:
- mysettings["EBUILD_PHASE"] = ebuild_phase
if private_tmpdir is not None:
shutil.rmtree(private_tmpdir)
+ private_tmpdir = None
elif restrict_fetch:
pass