]> git.pld-linux.org Git - packages/tar.git/blob - zstd.patch
- rel 2; backport zstd support from upstream
[packages/tar.git] / zstd.patch
1 From 3d45373d3b192d7342d49524193497598818d36d Mon Sep 17 00:00:00 2001
2 From: Adam Borowski <kilobyte@angband.pl>
3 Date: Sun, 18 Mar 2018 10:24:13 +0200
4 Subject: Add support for zstd compression
5
6 * configure.ac (zstd): Register compression program.
7 * doc/tar.1: Mention --zstd.
8 * doc/tar.texi: Document zstd support.
9 * src/buffer.c: Register zstd compression.
10 * src/suffix.c: Add suffixes zst and tzst.
11 * src/tar.c: New compression option --zstd.
12 ---
13  configure.ac   |  1 +
14  doc/.gitignore |  1 +
15  doc/tar.1      |  4 ++++
16  doc/tar.texi   | 29 +++++++++++++++++++++--------
17  src/buffer.c   |  5 ++++-
18  src/suffix.c   |  2 ++
19  src/tar.c      | 12 +++++++++++-
20  7 files changed, 44 insertions(+), 10 deletions(-)
21
22 diff --git a/configure.ac b/configure.ac
23 index 0bddbeb..354e787 100644
24 --- a/configure.ac
25 +++ b/configure.ac
26 @@ -250,6 +250,7 @@ TAR_COMPR_PROGRAM(lzip)
27  TAR_COMPR_PROGRAM(lzma)
28  TAR_COMPR_PROGRAM(lzop)
29  TAR_COMPR_PROGRAM(xz)
30 +TAR_COMPR_PROGRAM(zstd)
31  
32  AC_MSG_CHECKING(for default archive format)
33  
34 diff --git a/doc/tar.1 b/doc/tar.1
35 index ddf4fdc..0663525 100644
36 --- a/doc/tar.1
37 +++ b/doc/tar.1
38 @@ -831,6 +831,10 @@ Filter the archive through
39  \fB\-Z\fR, \fB\-\-compress\fR, \fB\-\-uncompress\fR
40  Filter the archive through
41  .BR compress (1).
42 +.TP
43 +\fB\-\-zstd\fR
44 +Filter the archive through
45 +.BR zstd (1).
46  .SS Local file selection
47  .TP
48  \fB\-\-add\-file\fR=\fIFILE\fR
49 diff --git a/doc/tar.texi b/doc/tar.texi
50 index a56b9fb..1362216 100644
51 --- a/doc/tar.texi
52 +++ b/doc/tar.texi
53 @@ -3713,6 +3713,9 @@ only attributes from the user namespace.
54  @itemx -J
55  Use @command{xz} for compressing or decompressing the archives.  @xref{gzip}.
56  
57 +@item --zstd
58 +Use @command{zstd} for compressing or decompressing the archives.  @xref{gzip}.
59 +
60  @end table
61  
62  @node Short Option Summary
63 @@ -9520,6 +9523,7 @@ switch to @samp{posix}.
64  @cindex lzma
65  @cindex lzop
66  @cindex compress
67 +@cindex zstd
68  @GNUTAR{} is able to create and read compressed archives.  It supports
69  a wide variety of compression programs, namely: @command{gzip},
70  @command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
71 @@ -9530,14 +9534,21 @@ compression programs@footnote{It also had patent problems in the past.}.
72  
73  Creating a compressed archive is simple: you just specify a
74  @dfn{compression option} along with the usual archive creation
75 -commands.  The compression option is @option{-z} (@option{--gzip}) to
76 -create a @command{gzip} compressed archive, @option{-j}
77 -(@option{--bzip2}) to create a @command{bzip2} compressed archive,
78 -@option{--lzip} to create an @asis{lzip} compressed archive,
79 -@option{-J} (@option{--xz}) to create an @asis{XZ} archive,
80 -@option{--lzma} to create an @asis{LZMA} compressed
81 -archive, @option{--lzop} to create an @asis{LZOP} archive, and
82 -@option{-Z} (@option{--compress}) to use @command{compress} program.
83 +commands.  Available compression options are summarized in the
84 +table below:
85 +
86 +@multitable @columnfractions 0.4 0.2 0.4
87 +@headitem Long            @tab Short       @tab Archive format
88 +@item @option{--gzip}     @tab @option{-z} @tab @command{gzip}
89 +@item @option{--bzip2}    @tab @option{-j} @tab @command{bzip2}
90 +@item @option{--xz}       @tab @option{-J} @tab @command{xz}
91 +@item @option{--lzip}     @tab             @tab @command{lzip}
92 +@item @option{--lzma}     @tab             @tab @command{lzma}
93 +@item @option{--lzop}     @tab             @tab @command{lzop}
94 +@item @option{--zstd}     @tab             @tab @command{zstd}
95 +@item @option{--compress} @tab @option{-Z} @tab @command{compress}
96 +@end multitable
97 +
98  For example:
99  
100  @smallexample
101 @@ -9730,6 +9741,8 @@ suffix.  The following suffixes are recognized:
102  @item @samp{.tlz} @tab @command{lzma}
103  @item @samp{.lzo} @tab @command{lzop}
104  @item @samp{.xz} @tab @command{xz}
105 +@item @samp{.zst} @tab @command{zstd}
106 +@item @samp{.tzst} @tab @command{zstd}
107  @end multitable
108  
109  @anchor{use-compress-program}
110 diff --git a/src/buffer.c b/src/buffer.c
111 index 51f299f..063e1be 100644
112 --- a/src/buffer.c
113 +++ b/src/buffer.c
114 @@ -281,7 +281,8 @@ enum compress_type {
115    ct_lzip,
116    ct_lzma,
117    ct_lzop,
118 -  ct_xz
119 +  ct_xz,
120 +  ct_zstd
121  };
122  
123  static enum compress_type archive_compression_type = ct_none;
124 @@ -310,6 +311,7 @@ static struct zip_magic const magic[] = {
125    { ct_lzma,     6, "\xFFLZMA" },
126    { ct_lzop,     4, "\211LZO" },
127    { ct_xz,       6, "\xFD" "7zXZ" },
128 +  { ct_zstd,     4, "\x28\xB5\x2F\xFD" },
129  };
130  
131  #define NMAGIC (sizeof(magic)/sizeof(magic[0]))
132 @@ -325,6 +327,7 @@ static struct zip_program zip_program[] = {
133    { ct_lzma,     XZ_PROGRAM,       "-J" },
134    { ct_lzop,     LZOP_PROGRAM,     "--lzop" },
135    { ct_xz,       XZ_PROGRAM,       "-J" },
136 +  { ct_zstd,     ZSTD_PROGRAM,     "--zstd" },
137    { ct_none }
138  };
139  
140 diff --git a/src/suffix.c b/src/suffix.c
141 index 47027e7..66b5694 100644
142 --- a/src/suffix.c
143 +++ b/src/suffix.c
144 @@ -46,6 +46,8 @@ static struct compression_suffix compression_suffixes[] = {
145    { S(lzo,  LZOP) },
146    { S(xz,   XZ) },
147    { S(txz,  XZ) }, /* Slackware */
148 +  { S(zst,  ZSTD) },
149 +  { S(tzst, ZSTD) },
150    { NULL }
151  #undef S
152  #undef __CAT2__
153 diff --git a/src/tar.c b/src/tar.c
154 index 3f844a8..02fa561 100644
155 --- a/src/tar.c
156 +++ b/src/tar.c
157 @@ -348,7 +348,8 @@ enum
158    WARNING_OPTION,
159    XATTR_OPTION,
160    XATTR_EXCLUDE,
161 -  XATTR_INCLUDE
162 +  XATTR_INCLUDE,
163 +  ZSTD_OPTION,
164  };
165  
166  static char const doc[] = N_("\
167 @@ -682,6 +683,7 @@ static struct argp_option options[] = {
168    {"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 },
169    {"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 },
170    {"xz", 'J', 0, 0, NULL, GRID+1 },
171 +  {"zstd", ZSTD_OPTION, 0, 0, NULL, GRID+1 },
172  #undef GRID
173  
174  #define GRID 100
175 @@ -1129,6 +1131,10 @@ tar_help_filter (int key, const char *text, void *input)
176        s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM);
177        break;
178  
179 +    case ZSTD_OPTION:
180 +      s = xasprintf (_("filter the archive through %s"), ZSTD_PROGRAM);
181 +      break;
182 +
183      case ARGP_KEY_HELP_EXTRA:
184        {
185         const char *tstr;
186 @@ -1650,6 +1656,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
187        set_use_compress_program_option (COMPRESS_PROGRAM, args->loc);
188        break;
189  
190 +    case ZSTD_OPTION:
191 +      set_use_compress_program_option (ZSTD_PROGRAM, args->loc);
192 +      break;
193 +
194      case ATIME_PRESERVE_OPTION:
195        atime_preserve_option =
196         (arg
197 -- 
198 cgit v1.0-41-gc330
199
This page took 0.047797 seconds and 3 git commands to generate.