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
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.
16 doc/tar.texi | 29 +++++++++++++++++++++--------
17 src/buffer.c | 5 ++++-
19 src/tar.c | 12 +++++++++++-
20 7 files changed, 44 insertions(+), 10 deletions(-)
22 diff --git a/configure.ac b/configure.ac
23 index 0bddbeb..354e787 100644
26 @@ -250,6 +250,7 @@ TAR_COMPR_PROGRAM(lzip)
27 TAR_COMPR_PROGRAM(lzma)
28 TAR_COMPR_PROGRAM(lzop)
30 +TAR_COMPR_PROGRAM(zstd)
32 AC_MSG_CHECKING(for default archive format)
34 diff --git a/doc/tar.1 b/doc/tar.1
35 index ddf4fdc..0663525 100644
38 @@ -831,6 +831,10 @@ Filter the archive through
39 \fB\-Z\fR, \fB\-\-compress\fR, \fB\-\-uncompress\fR
40 Filter the archive through
44 +Filter the archive through
46 .SS Local file selection
48 \fB\-\-add\-file\fR=\fIFILE\fR
49 diff --git a/doc/tar.texi b/doc/tar.texi
50 index a56b9fb..1362216 100644
53 @@ -3713,6 +3713,9 @@ only attributes from the user namespace.
55 Use @command{xz} for compressing or decompressing the archives. @xref{gzip}.
58 +Use @command{zstd} for compressing or decompressing the archives. @xref{gzip}.
62 @node Short Option Summary
63 @@ -9520,6 +9523,7 @@ switch to @samp{posix}.
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.}.
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
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}
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}
109 @anchor{use-compress-program}
110 diff --git a/src/buffer.c b/src/buffer.c
111 index 51f299f..063e1be 100644
114 @@ -281,7 +281,8 @@ enum compress_type {
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" },
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" },
140 diff --git a/src/suffix.c b/src/suffix.c
141 index 47027e7..66b5694 100644
144 @@ -46,6 +46,8 @@ static struct compression_suffix compression_suffixes[] = {
147 { S(txz, XZ) }, /* Slackware */
153 diff --git a/src/tar.c b/src/tar.c
154 index 3f844a8..02fa561 100644
157 @@ -348,7 +348,8 @@ enum
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 },
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);
180 + s = xasprintf (_("filter the archive through %s"), ZSTD_PROGRAM);
183 case ARGP_KEY_HELP_EXTRA:
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);
191 + set_use_compress_program_option (ZSTD_PROGRAM, args->loc);
194 case ATIME_PRESERVE_OPTION:
195 atime_preserve_option =