summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-16 21:30:41 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-16 21:30:41 -0700
commitc080922e0bd40ced9df7169bf13e06133e7fb790 (patch)
tree0e431858d9a941e22204213d7845b4c251232178
parent15c8a621ad1211912b00a604c862e15c320f560c (diff)
downloadportage-c080922e0bd40ced9df7169bf13e06133e7fb790.tar.gz
portage-c080922e0bd40ced9df7169bf13e06133e7fb790.tar.bz2
portage-c080922e0bd40ced9df7169bf13e06133e7fb790.zip
Use EbuildPhase to execute preinst/postinst and eliminate duplicate code.
-rw-r--r--pym/portage/package/ebuild/doebuild.py74
1 files changed, 9 insertions, 65 deletions
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 003cb4356..520ab6700 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -594,41 +594,20 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
uid=portage_uid, gid=portage_gid, dirmode=0o70, dirmask=0,
filemode=0o60, filemask=0)
return retval
- elif mydo == "preinst":
- phase_retval = spawn(
- _shell_quote(ebuild_sh_binary) + " " + mydo,
- mysettings, debug=debug, free=1, logfile=logfile,
- fd_pipes=fd_pipes, returnpid=returnpid)
-
+ elif mydo in ("preinst", "postinst"):
if returnpid:
- return phase_retval
-
- if phase_retval == os.EX_OK:
- mysettings.pop("EBUILD_PHASE", None)
- phase_retval = spawn(
- " ".join(_post_pkg_preinst_cmd(mysettings)),
- mysettings, debug=debug, free=1, logfile=logfile)
- if phase_retval != os.EX_OK:
- writemsg(_("!!! post preinst failed; exiting.\n"),
- noiselevel=-1)
- return phase_retval
- elif mydo == "postinst":
- phase_retval = spawn(
+ return spawn(
_shell_quote(ebuild_sh_binary) + " " + mydo,
mysettings, debug=debug, free=1, logfile=logfile,
fd_pipes=fd_pipes, returnpid=returnpid)
- if returnpid:
- return phase_retval
-
- if phase_retval == os.EX_OK:
- mysettings.pop("EBUILD_PHASE", None)
- phase_retval = spawn(" ".join(_post_pkg_postinst_cmd(mysettings)),
- mysettings, debug=debug, free=1, logfile=logfile)
- if phase_retval != os.EX_OK:
- writemsg(_("!!! post postinst failed; exiting.\n"),
- noiselevel=-1)
- return phase_retval
+ task_scheduler = TaskScheduler()
+ ebuild_phase = EbuildPhase(background=False,
+ phase=mydo, scheduler=task_scheduler.sched_iface,
+ settings=mysettings)
+ task_scheduler.add(ebuild_phase)
+ task_scheduler.run()
+ return ebuild_phase.returncode
elif mydo in ("prerm", "postrm", "config", "info", "pretend"):
retval = spawn(
_shell_quote(ebuild_sh_binary) + " " + mydo,
@@ -1538,38 +1517,3 @@ def _merge_unicode_error(errors):
lines.append("")
return lines
-
-def _post_pkg_preinst_cmd(mysettings):
- """
- Post phase logic and tasks that have been factored out of
- ebuild.sh. Call preinst_mask last so that INSTALL_MASK can
- can be used to wipe out any gmon.out files created during
- previous functions (in case any tools were built with -pg
- in CFLAGS).
- """
-
- portage_bin_path = mysettings["PORTAGE_BIN_PATH"]
- misc_sh_binary = os.path.join(portage_bin_path,
- os.path.basename(MISC_SH_BINARY))
-
- mysettings["EBUILD_PHASE"] = ""
- global _post_phase_cmds
- myargs = [_shell_quote(misc_sh_binary)] + _post_phase_cmds["preinst"]
-
- return myargs
-
-def _post_pkg_postinst_cmd(mysettings):
- """
- Post phase logic and tasks that have been factored out of
- build.sh.
- """
-
- portage_bin_path = mysettings["PORTAGE_BIN_PATH"]
- misc_sh_binary = os.path.join(portage_bin_path,
- os.path.basename(MISC_SH_BINARY))
-
- mysettings["EBUILD_PHASE"] = ""
- global _post_phase_cmds
- myargs = [_shell_quote(misc_sh_binary)] + _post_phase_cmds["postinst"]
-
- return myargs