Use a PORTAGE_SIGPIPE_STATUS variable to export 128 + SIGPIPE to the
authorZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 01:26:15 +0000 (18:26 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 01:26:15 +0000 (18:26 -0700)
ebuild environment. SIGPIPE is typically 13, but its better not to
assume that.

bin/isolated-functions.sh
pym/_emerge/BinpkgExtractorAsync.py
pym/portage/package/ebuild/doebuild.py

index 8f0d20c9f693f5be6f119c415d74f8df13467648..3df18b53c31b9c7c98570004f1ffcc979ec3d07b 100644 (file)
@@ -34,7 +34,7 @@ assert_sigpipe_ok() {
        local x pipestatus=${PIPESTATUS[*]}
        for x in $pipestatus ; do
                # Allow SIGPIPE through (128 + 13)
-               [[ $x -ne 0 && $x -ne 141 ]] && die "$@"
+               [[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
        done
 
        # Require normal success for the last process (tar).
@@ -602,7 +602,8 @@ save_ebuild_env() {
                        PORTAGE_INST_UID PORTAGE_IPC_DAEMON \
                        PORTAGE_LOG_FILE PORTAGE_MASTER_PID \
                        PORTAGE_NONFATAL PORTAGE_QUIET PORTAGE_PYTHON \
-                       PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_UPDATE_ENV \
+                       PORTAGE_REPO_NAME PORTAGE_RESTRICT PORTAGE_SIGPIPE_STATUS \
+                       PORTAGE_UPDATE_ENV \
                        PORTAGE_USERNAME PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR \
                        PORTDIR_OVERLAY ${!PORTAGE_SANDBOX_*} PREROOTPATH \
                        PROFILE_PATHS PWORKDIR QA_INTERCEPTORS \
index 3a2654ec11617876744e063b7ad6b9ed49cba7e8..a2bbe7a45a50ab04815d7bcd978cdac5e916618d 100644 (file)
@@ -1,9 +1,10 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.SpawnProcess import SpawnProcess
 import portage
 import os
+import signal
 
 class BinpkgExtractorAsync(SpawnProcess):
 
@@ -12,12 +13,12 @@ class BinpkgExtractorAsync(SpawnProcess):
        _shell_binary = portage.const.BASH_BINARY
 
        def _start(self):
-               # SIGPIPE handling (status 141) should be compatible with
+               # SIGPIPE handling (128 + SIGPIPE) should be compatible with
                # assert_sigpipe_ok() that's used by the ebuild unpack() helper.
                self.args = [self._shell_binary, "-c",
                        ("bzip2 -dqc -- %s | tar -xp -C %s -f - ; " + \
                        "p=(${PIPESTATUS[@]}) ; " + \
-                       "if [[ ${p[0]} != 0 && ${p[0]} != 141 ]] ; then " + \
+                       "if [[ ${p[0]} != 0 && ${p[0]} != %d ]] ; then " % (128 + signal.SIGPIPE) + \
                        "echo bzip2 failed with status ${p[0]} ; exit ${p[0]} ; fi ; " + \
                        "if [ ${p[1]} != 0 ] ; then " + \
                        "echo tar failed with status ${p[1]} ; exit ${p[1]} ; fi ; " + \
index c33cb9a5d208ac8f196d3bc7007e98a28cdfb5c9..1e8da8a0175ddca912e4f99a67d39d6805ef7de5 100644 (file)
@@ -11,6 +11,7 @@ import logging
 import os as _os
 import re
 import shutil
+import signal
 import stat
 import sys
 import tempfile
@@ -177,6 +178,11 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
        # Set requested Python interpreter for Portage helpers.
        mysettings['PORTAGE_PYTHON'] = portage._python_interpreter
 
+       # This is used by assert_sigpipe_ok() that's used by the ebuild
+       # unpack() helper. SIGPIPE is typically 13, but its better not
+       # to assume that.
+       mysettings['PORTAGE_SIGPIPE_STATUS'] = str(128 + signal.SIGPIPE)
+
        # We are disabling user-specific bashrc files.
        mysettings["BASH_ENV"] = INVALID_ENV_FILE