commit:     26c0a0e31b5150f7ef23b2156b87863e47dd5996
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct  4 06:07:05 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct  4 07:07:32 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=26c0a0e3

BinpkgExtractorAsync: fix PIPESTATUS error handling

Fixes: b4b0e6b0aaa1 ("remove trailer when decompressing binary packages")

 pym/_emerge/BinpkgExtractorAsync.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/pym/_emerge/BinpkgExtractorAsync.py 
b/pym/_emerge/BinpkgExtractorAsync.py
index 173845974..07ba2a1b7 100644
--- a/pym/_emerge/BinpkgExtractorAsync.py
+++ b/pym/_emerge/BinpkgExtractorAsync.py
@@ -80,17 +80,21 @@ class BinpkgExtractorAsync(SpawnProcess):
                # 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",
-                       ("head -c-%d -- %s | %s | tar -xp %s -C %s -f - ; " + \
-                       "p=(${PIPESTATUS[@]}) ; " + \
-                       "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 ; " + \
+                       ("cmd0=(head -c-%d -- %s) cmd1=(%s) cmd2=(tar -xp %s -C 
%s -f -); " + \
+                       '"${cmd0[@]}" | "${cmd1[@]}" | "${cmd2[@]}"; ' + \
+                       "p=(${PIPESTATUS[@]}) ; for i in {0..2}; do " + \
+                       "if [[ ${p[$i]} != 0 && ${p[$i]} != %d ]] ; then " + \
+                       "echo command $(eval \"echo \\\"'\\${cmd$i[*]}'\\\"\") 
" + \
+                       "failed with status ${p[$i]} ; exit ${p[$i]} ; fi ; 
done; " + \
+                       "if [ ${p[$i]} != 0 ] ; then " + \
+                       "echo command $(eval \"echo \\\"'\\${cmd$i[*]}'\\\"\") 
" + \
+                       "failed with status ${p[$i]} ; exit ${p[$i]} ; fi ; " + 
\
                        "exit 0 ;") % \
                        (pkg_xpak.xpaksize,
                        portage._shell_quote(self.pkg_path),
                        decomp_cmd,
                        tar_options,
-                       portage._shell_quote(self.image_dir))]
+                       portage._shell_quote(self.image_dir),
+                       128 + signal.SIGPIPE)]
 
                SpawnProcess._start(self)

Reply via email to