1 From e36454201ec81374bf4d2d09877e6c345a6fddab Mon Sep 17 00:00:00 2001
2 From: Joey Hess <joeyh@debian.org>
3 Date: Sun, 27 Oct 2013 13:16:52 -0400
4 Subject: [PATCH] add PRISTINE_TAR_COMPAT
7 debian/patches/longlink-hack.diff | 72 -------------------------
8 debian/patches/pristine-tar.diff | 108 ++++++++++++++++++++++++++++++++++++++
9 debian/patches/series | 2 +-
10 3 files changed, 109 insertions(+), 73 deletions(-)
11 delete mode 100644 debian/patches/longlink-hack.diff
12 create mode 100644 debian/patches/pristine-tar.diff
14 diff --git a/debian/patches/longlink-hack.diff b/debian/patches/longlink-hack.diff
15 deleted file mode 100644
16 index b6bc385..0000000
17 --- a/debian/patches/longlink-hack.diff
20 -diff --git a/src/common.h b/src/common.h
21 -index eb801bb..4aaace5 100644
24 -@@ -907,4 +907,6 @@ void finish_deferred_unlinks (void);
26 - extern void (*fatal_exit_hook) (void);
28 -+GLOBAL int debian_longlink_hack;
30 - _GL_INLINE_HEADER_END
31 -diff --git a/src/create.c b/src/create.c
32 -index e14e13d..3a84c79 100644
39 -+extern int debian_longlink_hack;
41 - /* Error number to use when an impostor is discovered.
42 - Pretend the impostor isn't there. */
43 - enum { IMPOSTOR_ERRNO = ENOENT };
44 -@@ -724,7 +726,7 @@ write_header_name (struct tar_stat_info *st)
45 - return write_short_name (st);
47 - else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
48 -- < strlen (st->file_name))
49 -+ < strlen (st->file_name) + debian_longlink_hack)
50 - return write_long_name (st);
52 - return write_short_name (st);
53 -@@ -1476,7 +1478,7 @@ dump_hard_link (struct tar_stat_info *st)
54 - block_ordinal = current_block_ordinal ();
55 - assign_string (&st->link_name, link_name);
56 - if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
57 -- < strlen (link_name))
58 -+ < strlen (link_name) + debian_longlink_hack)
59 - write_long_link (st);
61 - st->stat.st_size = 0;
62 -diff --git a/src/tar.c b/src/tar.c
63 -index 4f5017d..e9a5126 100644
66 -@@ -1246,6 +1246,16 @@ expand_pax_option (struct tar_args *targs, const char *arg)
70 -+/* Debian specific environment variable used by pristine-tar to enable use of
71 -+ * longlinks for filenames exactly 100 bytes long. */
72 -+void debian_longlink_hack_init () {
73 -+ char *s=getenv ("TAR_LONGLINK_100");
74 -+ if (s && strcmp(s, "1") == 0)
75 -+ debian_longlink_hack=1;
77 -+ debian_longlink_hack=0;
82 - parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
83 -@@ -2626,6 +2636,8 @@ main (int argc, char **argv)
84 - filename_terminator = '\n';
85 - set_quoting_style (0, DEFAULT_QUOTING_STYLE);
87 -+ debian_longlink_hack_init ();
89 - /* Make sure we have first three descriptors available */
92 diff --git a/debian/patches/pristine-tar.diff b/debian/patches/pristine-tar.diff
94 index 0000000..f350acc
96 +++ b/debian/patches/pristine-tar.diff
98 +diff --git a/src/common.h b/src/common.h
99 +index eb801bb..30f8cf5 100644
102 +@@ -907,4 +907,7 @@ void finish_deferred_unlinks (void);
103 + /* Module exit.c */
104 + extern void (*fatal_exit_hook) (void);
106 ++GLOBAL int debian_longlink_hack;
107 ++GLOBAL int pristine_tar_compat;
109 + _GL_INLINE_HEADER_END
110 +diff --git a/src/create.c b/src/create.c
111 +index e14e13d..d6e8ea7 100644
115 + #include "common.h"
118 ++extern int debian_longlink_hack;
119 ++extern int pristine_tar_compat;
121 + /* Error number to use when an impostor is discovered.
122 + Pretend the impostor isn't there. */
123 + enum { IMPOSTOR_ERRNO = ENOENT };
124 +@@ -534,6 +537,11 @@ write_short_name (struct tar_stat_info *st)
128 ++#define FILL(field,byte) do { \
129 ++ memset(field, byte, sizeof(field)-1); \
130 ++ (field)[sizeof(field)-1] = 0; \
133 + /* Write a GNUTYPE_LONGLINK or GNUTYPE_LONGNAME block. */
135 + write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
136 +@@ -544,6 +552,10 @@ write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
139 + header = start_private_header ("././@LongLink", size, start_time.tv_sec);
140 ++ if (pristine_tar_compat) {
141 ++ FILL (header->header.mtime, '0');
142 ++ FILL (header->header.mode, '0');
144 + uid_to_uname (0, &tmpname);
145 + UNAME_TO_CHARS (tmpname, header->header.uname);
147 +@@ -724,7 +736,7 @@ write_header_name (struct tar_stat_info *st)
148 + return write_short_name (st);
150 + else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
151 +- < strlen (st->file_name))
152 ++ < strlen (st->file_name) + debian_longlink_hack)
153 + return write_long_name (st);
155 + return write_short_name (st);
156 +@@ -1476,7 +1488,7 @@ dump_hard_link (struct tar_stat_info *st)
157 + block_ordinal = current_block_ordinal ();
158 + assign_string (&st->link_name, link_name);
159 + if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
160 +- < strlen (link_name))
161 ++ < strlen (link_name) + debian_longlink_hack)
162 + write_long_link (st);
164 + st->stat.st_size = 0;
165 +diff --git a/src/tar.c b/src/tar.c
166 +index 4f5017d..b72e25b 100644
169 +@@ -1246,6 +1246,26 @@ expand_pax_option (struct tar_args *targs, const char *arg)
173 ++/* Debian specific environment variable used by pristine-tar to enable use of
174 ++ * longlinks for filenames exactly 100 bytes long. */
175 ++void debian_longlink_hack_init (void) {
176 ++ char *s=getenv ("TAR_LONGLINK_100");
177 ++ if (s && strcmp(s, "1") == 0)
178 ++ debian_longlink_hack=1;
180 ++ debian_longlink_hack=0;
183 ++/* pristine-tar sets this environment variable to force fields in longlinks
184 ++ * to be zeroed as was the case in tar 1.26. */
185 ++void pristine_tar_compat_init (void) {
186 ++ char *s=getenv ("PRISTINE_TAR_COMPAT");
187 ++ if (s && strcmp(s, "1") == 0)
188 ++ pristine_tar_compat=1;
190 ++ pristine_tar_compat=0;
195 + parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
196 +@@ -2626,6 +2646,9 @@ main (int argc, char **argv)
197 + filename_terminator = '\n';
198 + set_quoting_style (0, DEFAULT_QUOTING_STYLE);
200 ++ debian_longlink_hack_init ();
201 ++ pristine_tar_compat_init ();
203 + /* Make sure we have first three descriptors available */
206 diff --git a/debian/patches/series b/debian/patches/series
207 index 1dfef41..5974cbb 100644
208 --- a/debian/patches/series
209 +++ b/debian/patches/series