Debian Codegraph @

debian/patches/pristine-tar.diff

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