summaryrefslogtreecommitdiffstats
path: root/pym/portage/package/ebuild
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-13 07:05:12 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-13 07:05:12 -0700
commit12cbc8821476dcbac38464a41f7cb336da7ac0c9 (patch)
treec985564961b89af1f3ccb72f4347e41e0dd91a90 /pym/portage/package/ebuild
parent9839ae93b13fd66503b1e4f3dd33193b3a92e838 (diff)
downloadportage-12cbc8821476dcbac38464a41f7cb336da7ac0c9.tar.gz
portage-12cbc8821476dcbac38464a41f7cb336da7ac0c9.tar.bz2
portage-12cbc8821476dcbac38464a41f7cb336da7ac0c9.zip
Use EbuildIpcDaemon to replace the functionality of
EBUILD_EXIT_STATUS_FILE.
Diffstat (limited to 'pym/portage/package/ebuild')
-rw-r--r--pym/portage/package/ebuild/_ipc/ExitCommand.py27
-rw-r--r--pym/portage/package/ebuild/_ipc/IpcCommand.py9
-rw-r--r--pym/portage/package/ebuild/_ipc/__init__.py2
-rw-r--r--pym/portage/package/ebuild/config.py4
-rw-r--r--pym/portage/package/ebuild/doebuild.py67
-rw-r--r--pym/portage/package/ebuild/prepare_build_dirs.py19
6 files changed, 59 insertions, 69 deletions
diff --git a/pym/portage/package/ebuild/_ipc/ExitCommand.py b/pym/portage/package/ebuild/_ipc/ExitCommand.py
new file mode 100644
index 000000000..f14050b91
--- /dev/null
+++ b/pym/portage/package/ebuild/_ipc/ExitCommand.py
@@ -0,0 +1,27 @@
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.package.ebuild._ipc.IpcCommand import IpcCommand
+
+class ExitCommand(IpcCommand):
+
+ __slots__ = ('exitcode', 'reply_hook',)
+
+ def __init__(self):
+ IpcCommand.__init__(self)
+ self.reply_hook = None
+ self.exitcode = None
+
+ def __call__(self, argv):
+
+ if self.exitcode is not None:
+ # Ignore all but the first call, since if die is called
+ # then we certainly want to honor that exitcode, even
+ # the ebuild process manages to send a second exit
+ # command.
+ self.reply_hook = None
+ else:
+ self.exitcode = int(argv[1])
+
+ # (stdout, stderr, returncode)
+ return ('', '', 0)
diff --git a/pym/portage/package/ebuild/_ipc/IpcCommand.py b/pym/portage/package/ebuild/_ipc/IpcCommand.py
new file mode 100644
index 000000000..efb27f0a2
--- /dev/null
+++ b/pym/portage/package/ebuild/_ipc/IpcCommand.py
@@ -0,0 +1,9 @@
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+class IpcCommand(object):
+
+ __slots__ = ()
+
+ def __call__(self, argv):
+ raise NotImplementedError(self)
diff --git a/pym/portage/package/ebuild/_ipc/__init__.py b/pym/portage/package/ebuild/_ipc/__init__.py
new file mode 100644
index 000000000..21a391aee
--- /dev/null
+++ b/pym/portage/package/ebuild/_ipc/__init__.py
@@ -0,0 +1,2 @@
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index a97dd33ac..3b8ee10b5 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -168,7 +168,7 @@ class config(object):
_environ_whitelist += [
"ACCEPT_LICENSE", "BASH_ENV", "BUILD_PREFIX", "D",
"DISTDIR", "DOC_SYMLINKS_DIR", "EAPI", "EBUILD",
- "EBUILD_EXIT_STATUS_FILE", "EBUILD_FORCE_TEST",
+ "EBUILD_FORCE_TEST",
"EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "ED",
"EMERGE_FROM", "EPREFIX", "EROOT",
"FEATURES", "FILESDIR", "HOME", "NOCOLOR", "PATH",
@@ -183,7 +183,7 @@ class config(object):
"PORTAGE_CONFIGROOT", "PORTAGE_DEBUG", "PORTAGE_DEPCACHEDIR",
"PORTAGE_GID", "PORTAGE_GRPNAME",
"PORTAGE_INST_GID", "PORTAGE_INST_UID",
- "PORTAGE_IUSE",
+ "PORTAGE_IPC_DAEMON", "PORTAGE_IUSE",
"PORTAGE_LOG_FILE", "PORTAGE_MASTER_PID",
"PORTAGE_PYM_PATH", "PORTAGE_QUIET",
"PORTAGE_REPO_NAME", "PORTAGE_RESTRICT",
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 61eea40ee..7405b6f12 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -213,8 +213,6 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings,
mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_FILE)
mysettings["PM_EBUILD_HOOK_DIR"] = os.path.join(
mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_DIR)
- mysettings["EBUILD_EXIT_STATUS_FILE"] = os.path.join(
- mysettings["PORTAGE_BUILDDIR"], ".exit_status")
#set up KV variable -- DEP SPEEDUP :: Don't waste time. Keep var persistent.
if not eapi_exports_KV(eapi):
@@ -240,61 +238,6 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings,
(c, style_to_ansi_code(c)))
mysettings["PORTAGE_COLORMAP"] = "\n".join(mycolors)
-def _doebuild_exit_status_check(mydo, settings):
- """
- Returns an error string if the shell appeared
- to exit unsuccessfully, None otherwise.
- """
- exit_status_file = settings.get("EBUILD_EXIT_STATUS_FILE")
- if not exit_status_file or \
- os.path.exists(exit_status_file):
- return None
- msg = _("The ebuild phase '%s' has exited "
- "unexpectedly. This type of behavior "
- "is known to be triggered "
- "by things such as failed variable "
- "assignments (bug #190128) or bad substitution "
- "errors (bug #200313). Normally, before exiting, bash should "
- "have displayed an error message above. If bash did not "
- "produce an error message above, it's possible "
- "that the ebuild has called `exit` when it "
- "should have called `die` instead. This behavior may also "
- "be triggered by a corrupt bash binary or a hardware "
- "problem such as memory or cpu malfunction. If the problem is not "
- "reproducible or it appears to occur randomly, then it is likely "
- "to be triggered by a hardware problem. "
- "If you suspect a hardware problem then you should "
- "try some basic hardware diagnostics such as memtest. "
- "Please do not report this as a bug unless it is consistently "
- "reproducible and you are sure that your bash binary and hardware "
- "are functioning properly.") % mydo
- return msg
-
-def _doebuild_exit_status_check_and_log(settings, mydo, retval):
- msg = _doebuild_exit_status_check(mydo, settings)
- if msg:
- if retval == os.EX_OK:
- retval = 1
- for l in wrap(msg, 72):
- eerror(l, phase=mydo, key=settings.mycpv)
- return retval
-
-def _doebuild_exit_status_unlink(exit_status_file):
- """
- Double check to make sure it really doesn't exist
- and raise an OSError if it still does (it shouldn't).
- OSError if necessary.
- """
- if not exit_status_file:
- return
- try:
- os.unlink(exit_status_file)
- except OSError:
- pass
- if os.path.exists(exit_status_file):
- os.unlink(exit_status_file)
-
-
_doebuild_manifest_cache = None
_doebuild_broken_ebuilds = set()
_doebuild_broken_manifests = set()
@@ -721,8 +664,6 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
elog_process(mysettings.mycpv, mysettings)
return 1
del env_file, env_stat, saved_env
- else:
- mysettings.pop("EBUILD_EXIT_STATUS_FILE", None)
# if any of these are being called, handle them -- running them out of
# the sandbox -- and stop now.
@@ -1172,14 +1113,6 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
spawn_func = selinux.spawn_wrapper(spawn_func,
mysettings["PORTAGE_SANDBOX_T"])
- phase = env.get('EBUILD_PHASE')
- if phase not in EbuildSpawnProcess._phases_without_builddir:
- # Don't try to unlink for phases that don't require
- # PORTAGE_BUILDDIR, since the directory may not
- # even belong to this process in that case.
- _doebuild_exit_status_unlink(
- env.get("EBUILD_EXIT_STATUS_FILE"))
-
if keywords.get("returnpid"):
return spawn_func(mystring, env=env, **keywords)
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py
index dc29eeeb8..15e087121 100644
--- a/pym/portage/package/ebuild/prepare_build_dirs.py
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py
@@ -85,6 +85,25 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
writemsg(_("File Not Found: '%s'\n") % str(e), noiselevel=-1)
return 1
+ for x in ('.ipc_in', '.ipc_out'):
+ p = os.path.join(mysettings['PORTAGE_BUILDDIR'], x)
+ st = None
+ try:
+ st = os.lstat(p)
+ except OSError:
+ os.mkfifo(p)
+ else:
+ if not stat.S_ISFIFO(st.st_mode):
+ st = None
+ try:
+ os.unlink(p)
+ except OSError:
+ pass
+ os.mkfifo(p)
+ apply_secpass_permissions(p,
+ uid=portage_uid, gid=portage_gid,
+ mode=0o770, mask=0o2, stat_cached=st)
+
# Reset state for things like noauto and keepwork in FEATURES.
for x in ('.die_hooks',):
try: