File: pristine-tar.diff

package info (click to toggle)
tar 1.35%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,460 kB
  • sloc: ansic: 90,098; sh: 56,758; yacc: 1,853; makefile: 437; sed: 16
file content (128 lines) | stat: -rw-r--r-- 3,916 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Index: tar/src/common.h
===================================================================
--- tar.orig/src/common.h
+++ tar/src/common.h
@@ -1036,4 +1036,8 @@
 int group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name);
 
 
+GLOBAL int debian_longlink_hack;
+GLOBAL int debian_broken_numeric_owner;
+GLOBAL int pristine_tar_compat;
+
 _GL_INLINE_HEADER_END
Index: tar/src/create.c
===================================================================
--- tar.orig/src/create.c
+++ tar/src/create.c
@@ -28,6 +28,10 @@
 #include "common.h"
 #include <hash.h>
 
+extern int debian_longlink_hack;
+extern int debian_broken_numeric_owner;
+extern int pristine_tar_compat;
+
 /* Error number to use when an impostor is discovered.
    Pretend the impostor isn't there.  */
 enum { IMPOSTOR_ERRNO = ENOENT };
@@ -535,6 +539,11 @@
   return header;
 }
 
+#define FILL(field,byte) do {            \
+  memset(field, byte, sizeof(field)-1);  \
+  (field)[sizeof(field)-1] = 0;          \
+} while (0)
+
 /* Write a GNUTYPE_LONGLINK or GNUTYPE_LONGNAME block.  */
 static void
 write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
@@ -544,7 +553,11 @@
   union block *header;
 
   header = start_private_header ("././@LongLink", size, 0);
-  if (! numeric_owner_option)
+  if (pristine_tar_compat) {
+         FILL (header->header.mtime, '0');
+         FILL (header->header.mode, '0');
+  }
+  if ((pristine_tar_compat && debian_broken_numeric_owner) || ! numeric_owner_option)
     {
       static char *uname, *gname;
       if (!uname)
@@ -729,7 +742,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);
@@ -1483,7 +1496,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;
Index: tar/src/tar.c
===================================================================
--- tar.orig/src/tar.c
+++ tar/src/tar.c
@@ -1253,6 +1253,41 @@
   return res;
 }
 
+/* Debian specific function prototypes (-Werror=missing-prototypes) */
+void debian_longlink_hack_init (void);
+void debian_broken_numeric_owner_init (void);
+void pristine_tar_compat_init (void);
+
+/* Debian specific environment variable used by pristine-tar to enable use of
+ * longlinks for filenames exactly 100 bytes long. */
+void debian_longlink_hack_init (void) {
+ char *s=getenv ("TAR_LONGLINK_100");
+ if (s && strcmp(s, "1") == 0)
+	 debian_longlink_hack=1;
+ else
+	 debian_longlink_hack=0;
+}
+
+/* Debian specific environment variable used by pristine-tar to enable use of
+ * user and group names even when --numeric-owner is passed. */
+void debian_broken_numeric_owner_init (void) {
+ char *s=getenv ("TAR_BROKEN_NUMERIC_OWNER");
+ if (s && strcmp(s, "1") == 0)
+	 debian_broken_numeric_owner=1;
+ else
+	 debian_broken_numeric_owner=0;
+}
+
+/* pristine-tar sets this environment variable to force fields in longlinks
+ * to be zeroed as was the case in tar 1.26. */
+void pristine_tar_compat_init (void) {
+ char *s=getenv ("PRISTINE_TAR_COMPAT");
+ if (s && strcmp(s, "1") == 0)
+	 pristine_tar_compat=1;
+ else
+	 pristine_tar_compat=0;
+}
+
 
 static uintmax_t
 parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
@@ -2768,6 +2803,10 @@
 
   set_quoting_style (0, DEFAULT_QUOTING_STYLE);
 
+  debian_longlink_hack_init ();
+  debian_broken_numeric_owner_init ();
+  pristine_tar_compat_init ();
+
   close_stdout_set_file_name (_("stdout"));
   /* Make sure we have first three descriptors available */
   if (stdopen ())