Add support for zstd compression
* configure.ac (zstd): Register compression program. * doc/tar.1: Mention --zstd. * doc/tar.texi: Document zstd support. * src/buffer.c: Register zstd compression. * src/suffix.c: Add suffixes zst and tzst. * src/tar.c: New compression option --zstd.
This commit is contained in:
committed by
Sergey Poznyakoff
parent
64b43fdf70
commit
3d45373d3b
@@ -250,6 +250,7 @@ TAR_COMPR_PROGRAM(lzip)
|
|||||||
TAR_COMPR_PROGRAM(lzma)
|
TAR_COMPR_PROGRAM(lzma)
|
||||||
TAR_COMPR_PROGRAM(lzop)
|
TAR_COMPR_PROGRAM(lzop)
|
||||||
TAR_COMPR_PROGRAM(xz)
|
TAR_COMPR_PROGRAM(xz)
|
||||||
|
TAR_COMPR_PROGRAM(zstd)
|
||||||
|
|
||||||
AC_MSG_CHECKING(for default archive format)
|
AC_MSG_CHECKING(for default archive format)
|
||||||
|
|
||||||
|
|||||||
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@@ -24,3 +24,4 @@ tar.tp
|
|||||||
tar.vr
|
tar.vr
|
||||||
version.texi
|
version.texi
|
||||||
/parse-datetime.texi
|
/parse-datetime.texi
|
||||||
|
/rmt.8
|
||||||
|
|||||||
@@ -831,6 +831,10 @@ Filter the archive through
|
|||||||
\fB\-Z\fR, \fB\-\-compress\fR, \fB\-\-uncompress\fR
|
\fB\-Z\fR, \fB\-\-compress\fR, \fB\-\-uncompress\fR
|
||||||
Filter the archive through
|
Filter the archive through
|
||||||
.BR compress (1).
|
.BR compress (1).
|
||||||
|
.TP
|
||||||
|
\fB\-\-zstd\fR
|
||||||
|
Filter the archive through
|
||||||
|
.BR zstd (1).
|
||||||
.SS Local file selection
|
.SS Local file selection
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-add\-file\fR=\fIFILE\fR
|
\fB\-\-add\-file\fR=\fIFILE\fR
|
||||||
|
|||||||
29
doc/tar.texi
29
doc/tar.texi
@@ -3713,6 +3713,9 @@ only attributes from the user namespace.
|
|||||||
@itemx -J
|
@itemx -J
|
||||||
Use @command{xz} for compressing or decompressing the archives. @xref{gzip}.
|
Use @command{xz} for compressing or decompressing the archives. @xref{gzip}.
|
||||||
|
|
||||||
|
@item --zstd
|
||||||
|
Use @command{zstd} for compressing or decompressing the archives. @xref{gzip}.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Short Option Summary
|
@node Short Option Summary
|
||||||
@@ -9520,6 +9523,7 @@ switch to @samp{posix}.
|
|||||||
@cindex lzma
|
@cindex lzma
|
||||||
@cindex lzop
|
@cindex lzop
|
||||||
@cindex compress
|
@cindex compress
|
||||||
|
@cindex zstd
|
||||||
@GNUTAR{} is able to create and read compressed archives. It supports
|
@GNUTAR{} is able to create and read compressed archives. It supports
|
||||||
a wide variety of compression programs, namely: @command{gzip},
|
a wide variety of compression programs, namely: @command{gzip},
|
||||||
@command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
|
@command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
|
||||||
@@ -9530,14 +9534,21 @@ compression programs@footnote{It also had patent problems in the past.}.
|
|||||||
|
|
||||||
Creating a compressed archive is simple: you just specify a
|
Creating a compressed archive is simple: you just specify a
|
||||||
@dfn{compression option} along with the usual archive creation
|
@dfn{compression option} along with the usual archive creation
|
||||||
commands. The compression option is @option{-z} (@option{--gzip}) to
|
commands. Available compression options are summarized in the
|
||||||
create a @command{gzip} compressed archive, @option{-j}
|
table below:
|
||||||
(@option{--bzip2}) to create a @command{bzip2} compressed archive,
|
|
||||||
@option{--lzip} to create an @asis{lzip} compressed archive,
|
@multitable @columnfractions 0.4 0.2 0.4
|
||||||
@option{-J} (@option{--xz}) to create an @asis{XZ} archive,
|
@headitem Long @tab Short @tab Archive format
|
||||||
@option{--lzma} to create an @asis{LZMA} compressed
|
@item @option{--gzip} @tab @option{-z} @tab @command{gzip}
|
||||||
archive, @option{--lzop} to create an @asis{LZOP} archive, and
|
@item @option{--bzip2} @tab @option{-j} @tab @command{bzip2}
|
||||||
@option{-Z} (@option{--compress}) to use @command{compress} program.
|
@item @option{--xz} @tab @option{-J} @tab @command{xz}
|
||||||
|
@item @option{--lzip} @tab @tab @command{lzip}
|
||||||
|
@item @option{--lzma} @tab @tab @command{lzma}
|
||||||
|
@item @option{--lzop} @tab @tab @command{lzop}
|
||||||
|
@item @option{--zstd} @tab @tab @command{zstd}
|
||||||
|
@item @option{--compress} @tab @option{-Z} @tab @command{compress}
|
||||||
|
@end multitable
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
@@ -9730,6 +9741,8 @@ suffix. The following suffixes are recognized:
|
|||||||
@item @samp{.tlz} @tab @command{lzma}
|
@item @samp{.tlz} @tab @command{lzma}
|
||||||
@item @samp{.lzo} @tab @command{lzop}
|
@item @samp{.lzo} @tab @command{lzop}
|
||||||
@item @samp{.xz} @tab @command{xz}
|
@item @samp{.xz} @tab @command{xz}
|
||||||
|
@item @samp{.zst} @tab @command{zstd}
|
||||||
|
@item @samp{.tzst} @tab @command{zstd}
|
||||||
@end multitable
|
@end multitable
|
||||||
|
|
||||||
@anchor{use-compress-program}
|
@anchor{use-compress-program}
|
||||||
|
|||||||
@@ -281,7 +281,8 @@ enum compress_type {
|
|||||||
ct_lzip,
|
ct_lzip,
|
||||||
ct_lzma,
|
ct_lzma,
|
||||||
ct_lzop,
|
ct_lzop,
|
||||||
ct_xz
|
ct_xz,
|
||||||
|
ct_zstd
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum compress_type archive_compression_type = ct_none;
|
static enum compress_type archive_compression_type = ct_none;
|
||||||
@@ -310,6 +311,7 @@ static struct zip_magic const magic[] = {
|
|||||||
{ ct_lzma, 6, "\xFFLZMA" },
|
{ ct_lzma, 6, "\xFFLZMA" },
|
||||||
{ ct_lzop, 4, "\211LZO" },
|
{ ct_lzop, 4, "\211LZO" },
|
||||||
{ ct_xz, 6, "\xFD" "7zXZ" },
|
{ ct_xz, 6, "\xFD" "7zXZ" },
|
||||||
|
{ ct_zstd, 4, "\x28\xB5\x2F\xFD" },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NMAGIC (sizeof(magic)/sizeof(magic[0]))
|
#define NMAGIC (sizeof(magic)/sizeof(magic[0]))
|
||||||
@@ -325,6 +327,7 @@ static struct zip_program zip_program[] = {
|
|||||||
{ ct_lzma, XZ_PROGRAM, "-J" },
|
{ ct_lzma, XZ_PROGRAM, "-J" },
|
||||||
{ ct_lzop, LZOP_PROGRAM, "--lzop" },
|
{ ct_lzop, LZOP_PROGRAM, "--lzop" },
|
||||||
{ ct_xz, XZ_PROGRAM, "-J" },
|
{ ct_xz, XZ_PROGRAM, "-J" },
|
||||||
|
{ ct_zstd, ZSTD_PROGRAM, "--zstd" },
|
||||||
{ ct_none }
|
{ ct_none }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ static struct compression_suffix compression_suffixes[] = {
|
|||||||
{ S(lzo, LZOP) },
|
{ S(lzo, LZOP) },
|
||||||
{ S(xz, XZ) },
|
{ S(xz, XZ) },
|
||||||
{ S(txz, XZ) }, /* Slackware */
|
{ S(txz, XZ) }, /* Slackware */
|
||||||
|
{ S(zst, ZSTD) },
|
||||||
|
{ S(tzst, ZSTD) },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
#undef S
|
#undef S
|
||||||
#undef __CAT2__
|
#undef __CAT2__
|
||||||
|
|||||||
12
src/tar.c
12
src/tar.c
@@ -348,7 +348,8 @@ enum
|
|||||||
WARNING_OPTION,
|
WARNING_OPTION,
|
||||||
XATTR_OPTION,
|
XATTR_OPTION,
|
||||||
XATTR_EXCLUDE,
|
XATTR_EXCLUDE,
|
||||||
XATTR_INCLUDE
|
XATTR_INCLUDE,
|
||||||
|
ZSTD_OPTION,
|
||||||
};
|
};
|
||||||
|
|
||||||
static char const doc[] = N_("\
|
static char const doc[] = N_("\
|
||||||
@@ -682,6 +683,7 @@ static struct argp_option options[] = {
|
|||||||
{"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 },
|
{"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 },
|
||||||
{"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 },
|
{"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 },
|
||||||
{"xz", 'J', 0, 0, NULL, GRID+1 },
|
{"xz", 'J', 0, 0, NULL, GRID+1 },
|
||||||
|
{"zstd", ZSTD_OPTION, 0, 0, NULL, GRID+1 },
|
||||||
#undef GRID
|
#undef GRID
|
||||||
|
|
||||||
#define GRID 100
|
#define GRID 100
|
||||||
@@ -1129,6 +1131,10 @@ tar_help_filter (int key, const char *text, void *input)
|
|||||||
s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM);
|
s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZSTD_OPTION:
|
||||||
|
s = xasprintf (_("filter the archive through %s"), ZSTD_PROGRAM);
|
||||||
|
break;
|
||||||
|
|
||||||
case ARGP_KEY_HELP_EXTRA:
|
case ARGP_KEY_HELP_EXTRA:
|
||||||
{
|
{
|
||||||
const char *tstr;
|
const char *tstr;
|
||||||
@@ -1650,6 +1656,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
|||||||
set_use_compress_program_option (COMPRESS_PROGRAM, args->loc);
|
set_use_compress_program_option (COMPRESS_PROGRAM, args->loc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZSTD_OPTION:
|
||||||
|
set_use_compress_program_option (ZSTD_PROGRAM, args->loc);
|
||||||
|
break;
|
||||||
|
|
||||||
case ATIME_PRESERVE_OPTION:
|
case ATIME_PRESERVE_OPTION:
|
||||||
atime_preserve_option =
|
atime_preserve_option =
|
||||||
(arg
|
(arg
|
||||||
|
|||||||
Reference in New Issue
Block a user