LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   [PATCH] tar issuing a SIGPIPE in installpkg (https://www.linuxquestions.org/questions/slackware-14/%5Bpatch%5D-tar-issuing-a-sigpipe-in-installpkg-4175637923/)

NonNonBa 09-06-2018 03:56 PM

[PATCH] tar issuing a SIGPIPE in installpkg
 
Hi,

Quote:

Thu Sep 6 06:15:46 UTC 2018
[]
a/pkgtools-15.0-noarch-22.txz: Rebuilt.
installpkg: prevent noise from the "stray cat" if tar hands it a broken
pipe. Thanks to ivandi.
Also (in the comments) provide a possibly better but untested solution.
Thanks to SeB.
I've investigated a bit further, and I think I've found the problem. :)

First I've built the tar from the -current source with and without the "nolonezero" patch, then I used the debug.sh script below to compare their respective behavior:

Code:

result=./RESULT
for i in patched unpatched; do
    # WARNING: the tar-patched and tar-unpatched binaries must be in
    #          the current working directory.
    find "$@" -name '*.txz' | while read pkg; do
        hi=32
        ( xz -dc "$pkg"; echo $? >$result ) | ./tar-$i tf - >/dev/null
        read r <$result
        [ $r -eq 0 ] || hi=31
        printf '\033[0;'$hi'm%s \033[0;0m [code=%s tar=%s]\n' ${pkg##*/} $r $i
    done
done
rm $result

Here is the result when applied to the a/ and ap/ -current series:

Code:

$ bash debug.sh /path/to/the/package/tree
lvm2-2.02.177-x86_64-1.txz  [code=0 tar=patched]
[]
mkinitrd-1.4.11-x86_64-8.txz  [code=141 tar=patched]
unarj-265-x86_64-2.txz  [code=0 tar=patched]
[]
kmod-25-x86_64-2.txz  [code=141 tar=patched]
elilo-3.16-x86_64-7.txz  [code=0 tar=patched]
[]
minicom-2.7.1-x86_64-2.txz  [code=141 tar=patched]
dbus-1.12.10-x86_64-1.txz  [code=0 tar=patched]
[]
quota-4.03-x86_64-2.txz  [code=141 tar=patched]
kernel-firmware-20180904_85c5d90-noarch-1.txz  [code=0 tar=patched]
[]
texinfo-6.5-x86_64-6.txz  [code=141 tar=patched]
linuxdoc-tools-0.9.72-x86_64-5.txz  [code=0 tar=patched]
[]
cups-filters-1.21.2-x86_64-1.txz  [code=141 tar=patched]
xorriso-1.4.8-x86_64-2.txz  [code=141 tar=patched]
acct-6.6.4-x86_64-2.txz  [code=0 tar=patched]
[]
cdparanoia-III_10.2-x86_64-2.txz  [code=141 tar=patched]
[]
diffutils-3.6-x86_64-2.txz  [code=0 tar=patched]
lvm2-2.02.177-x86_64-1.txz  [code=0 tar=unpatched]
devs-2.3.1-noarch-25.txz  [code=0 tar=unpatched]
sharutils-4.15.2-x86_64-2.txz  [code=0 tar=unpatched]
kernel-generic-4.14.68-x86_64-1.txz  [code=0 tar=unpatched]
[]
diffutils-3.6-x86_64-2.txz  [code=0 tar=unpatched]

Only the patched tar has issues (causes cat to get a SIGPIPE, "code=141") with some packages (but always the same).

I use -stable, that's why I bother you with all the testing process, in case someone wants to reproduce it on the complete package tree. Applied to my -stable local tree, I've no SIGPIPE issue but the unpatched tar complains about "lone zero blocks" in some packages.

This amended version of the mentioned patch seems to make everyone happy everywhere in every regard:

Code:

--- tar-1.30.orig/src/list.c        2017-12-16 22:23:12.000000000 +0100
+++ tar-1.30/src/list.c        2018-09-06 22:31:21.302045405 +0200
@@ -242,15 +242,22 @@
 
          if (!ignore_zeros_option)
            {
-              char buf[UINTMAX_STRSIZE_BOUND];
+
+              /*
+              * According to POSIX tar specs, this is wrong, but on the web
+              * there are some tar specs that can trigger this, and some tar
+              * implementations create tars according to that spec.  For now,
+              * let's not be pedantic about issuing the warning.
+              *
+              * char buf[UINTMAX_STRSIZE_BOUND]; */
 
              status = read_header (&current_header, &current_stat_info,
                                    read_header_auto);
-              if (status == HEADER_ZERO_BLOCK)
-                break;
-              WARNOPT (WARN_ALONE_ZERO_BLOCK,
-                      (0, 0, _("A lone zero block at %s"),
-                        STRINGIFY_BIGINT (current_block_ordinal (), buf)));
+          /* if (status == HEADER_ZERO_BLOCK)
+                *    break;
+            * WARNOPT (WARN_ALONE_ZERO_BLOCK,
+                *      (0, 0, _("A lone zero block at %s"),
+                *        STRINGIFY_BIGINT (current_block_ordinal (), buf)));  */
              break;
            }
          status = prev_status;


bassmadrigal 09-07-2018 10:25 AM

This is now fixed in -current. Great job!

Code:

Thu Sep 6 23:22:45 UTC 2018
a/pkgtools-15.0-noarch-23.txz: Rebuilt.
      Removed stray cat and loop kludges for lack of reported size, since this
      is fixed now in tar.
a/tar-1.30-x86_64-3.txz: Rebuilt.
      Fixed a bug in the nolonezero patch that was evidently causing all of the
      issues in installpkg that we'd been kludging around (e.g. the "stray cat").
      Thanks *very* much to NonNonBa for the patch, and to SeB for the initial
      analysis of the problem.



All times are GMT -5. The time now is 05:02 AM.