From c080922e0bd40ced9df7169bf13e06133e7fb790 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 16 Aug 2010 21:30:41 -0700 Subject: [PATCH] Use EbuildPhase to execute preinst/postinst and eliminate duplicate code. --- pym/portage/package/ebuild/doebuild.py | 74 ++++---------------------- 1 file 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 -- 2.26.2