From 07de48f66fc63bb747111af4ae6ad8fe53e9fe26 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 25 Aug 2010 18:26:15 -0700 Subject: [PATCH] Use a PORTAGE_SIGPIPE_STATUS variable to export 128 + SIGPIPE to the ebuild environment. SIGPIPE is typically 13, but its better not to assume that. --- bin/isolated-functions.sh | 5 +++-- pym/_emerge/BinpkgExtractorAsync.py | 7 ++++--- pym/portage/package/ebuild/doebuild.py | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 8f0d20c9f..3df18b53c 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -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 \ diff --git a/pym/_emerge/BinpkgExtractorAsync.py b/pym/_emerge/BinpkgExtractorAsync.py index 3a2654ec1..a2bbe7a45 100644 --- a/pym/_emerge/BinpkgExtractorAsync.py +++ b/pym/_emerge/BinpkgExtractorAsync.py @@ -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 ; " + \ diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index c33cb9a5d..1e8da8a01 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -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 -- 2.26.2