Package: tar
Version: 1.23-4
Severity: normal
Tag: patch

As discussed, the fix for #598345 caused #602907 in pristine-tar.

I suggest the attached patch, which adds an environment variable
pristine-tar can use to enable the old behavior as needed.

I've tested this and confirmed it does not change anything
if TAR_LONGLINK_100 is not set, and produces the output pristine-tar
uses with TAR_LONGLINK_100=1

-- 
see shy jo
diff -ur orig/tar-1.25/src/common.h tar-1.25/src/common.h
--- orig/tar-1.25/src/common.h  2010-11-10 18:41:01.000000000 -0400
+++ tar-1.25/src/common.h       2010-11-11 20:28:06.000000000 -0400
@@ -834,3 +834,5 @@
 
 /* Module exit.c */
 extern void (*fatal_exit_hook) (void);
+
+GLOBAL int debian_longlink_hack;
diff -ur orig/tar-1.25/src/create.c tar-1.25/src/create.c
--- orig/tar-1.25/src/create.c  2010-11-10 18:41:01.000000000 -0400
+++ tar-1.25/src/create.c       2010-11-11 20:30:44.000000000 -0400
@@ -26,6 +26,8 @@
 #include "common.h"
 #include <hash.h>
 
+extern int debian_longlink_hack;
+
 /* Error number to use when an impostor is discovered.
    Pretend the impostor isn't there.  */
 enum { IMPOSTOR_ERRNO = ENOENT };
@@ -735,7 +737,7 @@
       return write_short_name (st);
     }
   else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-          < strlen (st->file_name))
+          < strlen (st->file_name) + debian_longlink_hack)
     return write_long_name (st);
   else
     return write_short_name (st);
@@ -1456,7 +1458,7 @@
          block_ordinal = current_block_ordinal ();
          assign_string (&st->link_name, link_name);
          if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-             < strlen (link_name))
+             < strlen (link_name) + debian_longlink_hack)
            write_long_link (st);
 
          st->stat.st_size = 0;
diff -ur orig/tar-1.25/src/tar.c tar-1.25/src/tar.c
--- orig/tar-1.25/src/tar.c     2010-11-10 18:41:01.000000000 -0400
+++ tar-1.25/src/tar.c  2010-11-11 20:28:59.000000000 -0400
@@ -2566,6 +2566,16 @@
   report_textual_dates (&args);
 }
 
+/* Debian specific environment variable used by pristine-tar to enable use of
+ * longlinks for filenames exactly 100 bytes long. */
+void debian_longlink_hack_init () {
+ char *s=getenv ("TAR_LONGLINK_100");
+ if (s && strcmp(s, "1") == 0)
+        debian_longlink_hack=1;
+ else
+        debian_longlink_hack=0;
+}
+
 
 /* Tar proper.  */
 
@@ -2585,6 +2595,8 @@
   filename_terminator = '\n';
   set_quoting_style (0, DEFAULT_QUOTING_STYLE);
 
+  debian_longlink_hack_init ();
+
   /* Make sure we have first three descriptors available */
   stdopen ();
 

Attachment: signature.asc
Description: Digital signature

Reply via email to