* configure.ac (brotli): Register compression program. * THANKS: Add Jamie Magee. * doc/tar.1: Mention --brotli. * doc/tar.texi: Document brotli support. * src/buffer.c: Register brotli compression. * src/suffix.c: Add suffixes br and tbr. * src/tar.c: New compression option --brotli. * tests/testsuite.at (Compression): Add brotli test.
Signed-off-by: Jamie Magee <jamie.ma...@gmail.com> --- THANKS | 1 + configure.ac | 1 + doc/tar.1 | 5 +++++ doc/tar.texi | 13 ++++++++++++- src/buffer.c | 4 ++++ src/suffix.c | 2 ++ src/tar.c | 10 ++++++++++ tests/testsuite.at | 1 + 8 files changed, 36 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index aee0a924..abde2dd0 100644 --- a/THANKS +++ b/THANKS @@ -228,6 +228,7 @@ James H Caldwell Jr caldw...@cs.fsu.edu James Stevens james.stev...@jrcs.co.uk James V. DI Toro III kar...@gats.hampton.va.us James W. McKelvey mckel...@fafnir.com +Jamie Magee jamie.ma...@gmail.com Jamie Zawinski j...@lucid.com Jan Carlson j...@sni.ca Jan Djarv jan.dj...@mbox200.swipnet.se diff --git a/configure.ac b/configure.ac index a376709a..fb0d8c64 100644 --- a/configure.ac +++ b/configure.ac @@ -275,6 +275,7 @@ fi TAR_COMPR_PROGRAM(compress) TAR_COMPR_PROGRAM(gzip) +TAR_COMPR_PROGRAM(brotli) TAR_COMPR_PROGRAM(bzip2) TAR_COMPR_PROGRAM(lzip) TAR_COMPR_PROGRAM(lzma) diff --git a/doc/tar.1 b/doc/tar.1 index 23ae7ac2..be6a362d 100644 --- a/doc/tar.1 +++ b/doc/tar.1 @@ -800,6 +800,10 @@ Filter data through \fICOMMAND\fR. It must accept the \fB\-d\fR option, for decompression. The argument can contain command line options. .TP +\fB\-\-brotli\fR +Filter the archive through +.BR brotli (1). +.TP \fB\-j\fR, \fB\-\-bzip2\fR Filter the archive through .BR bzip2 (1). @@ -1296,6 +1300,7 @@ compressor program failed. Another example is .B rmt failure during backup to a remote device. .SH "SEE ALSO" +.BR brotli (1) .BR bzip2 (1), .BR compress (1), .BR gzip (1), diff --git a/doc/tar.texi b/doc/tar.texi index dac49f32..5449e65c 100644 --- a/doc/tar.texi +++ b/doc/tar.texi @@ -2545,6 +2545,9 @@ with the block number in the archive file. @xref{block-number}. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per record. @xref{Blocking Factor}. +@item --brotli +Use @command{brotli} for compressing or decompressing the archives. @xref{gzip}. + @opsummary{bzip2} @item --bzip2 @itemx -j @@ -9694,6 +9697,7 @@ switch to @samp{posix}. @cindex Storing archives in compressed format @cindex gzip +@cindex brotli @cindex bzip2 @cindex lzip @cindex lzma @@ -9702,7 +9706,7 @@ switch to @samp{posix}. @cindex zstd @GNUTAR{} is able to create and read compressed archives. It supports a wide variety of compression programs, namely: @command{gzip}, -@command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop}, +@command{brotli}, @command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop}, @command{zstd}, @command{xz} and traditional @command{compress}. The latter is supported mostly for backward compatibility, and we recommend against using it, because it is by far less effective than the other @@ -9716,6 +9720,7 @@ table below: @multitable @columnfractions 0.4 0.2 0.4 @headitem Long @tab Short @tab Archive format @item @option{--gzip} @tab @option{-z} @tab @command{gzip} +@item @option{--brotli} @tab @tab @command{brotli} @item @option{--bzip2} @tab @option{-j} @tab @command{bzip2} @item @option{--xz} @tab @option{-J} @tab @command{xz} @item @option{--lzip} @tab @tab @command{lzip} @@ -9829,6 +9834,10 @@ Filter the archive through @command{gzip}. @itemx --xz Filter the archive through @code{xz}. +@opindex brotli +@item --brotli +Filter the archive through @command{brotli}. + @item -j @itemx --bzip2 Filter the archive through @code{bzip2}. @@ -9912,6 +9921,8 @@ suffix. The following suffixes are recognized: @item @samp{.taz} @tab @command{gzip} @item @samp{.Z} @tab @command{compress} @item @samp{.taZ} @tab @command{compress} +@item @samp{.br} @tab @command{brotli} +@item @samp{.tbr} @tab @command{brotli} @item @samp{.bz2} @tab @command{bzip2} @item @samp{.tz2} @tab @command{bzip2} @item @samp{.tbz2} @tab @command{bzip2} diff --git a/src/buffer.c b/src/buffer.c index a929138f..f1af7850 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -276,6 +276,7 @@ enum compress_type { ct_tar, /* Plain tar file */ ct_compress, ct_gzip, + ct_brotli, ct_bzip2, ct_lzip, ct_lzma, @@ -305,6 +306,8 @@ static struct zip_magic const magic[] = { { ct_tar, 0, 0 }, { ct_compress, 2, "\037\235" }, { ct_gzip, 2, "\037\213" }, + { ct_brotli, 4, "\x91\x19\x62\x66" }, + { ct_brotli, 4, "\xCE\xB2\xCF\x81" }, { ct_bzip2, 3, "BZh" }, { ct_lzip, 4, "LZIP" }, { ct_lzma, 6, "\xFFLZMA" }, @@ -320,6 +323,7 @@ static struct zip_program zip_program[] = { { ct_compress, COMPRESS_PROGRAM, "-Z" }, { ct_compress, GZIP_PROGRAM, "-z" }, { ct_gzip, GZIP_PROGRAM, "-z" }, + { ct_brotli, BROTLI_PROGRAM, "--brotli" }, { ct_bzip2, BZIP2_PROGRAM, "-j" }, { ct_bzip2, "lbzip2", "-j" }, { ct_lzip, LZIP_PROGRAM, "--lzip" }, diff --git a/src/suffix.c b/src/suffix.c index f03a3960..b0d0531e 100644 --- a/src/suffix.c +++ b/src/suffix.c @@ -35,6 +35,8 @@ static struct compression_suffix compression_suffixes[] = { { S(taz, GZIP) }, { S(Z, COMPRESS) }, { S(taZ, COMPRESS) }, + { S(br, BROTLI) }, + { S(tbr, BROTLI) }, { S(bz2, BZIP2) }, { S(tbz, BZIP2) }, { S(tbz2, BZIP2) }, diff --git a/src/tar.c b/src/tar.c index d65fc806..f48b5625 100644 --- a/src/tar.c +++ b/src/tar.c @@ -273,6 +273,7 @@ enum ACLS_OPTION = CHAR_MAX + 1, ATIME_PRESERVE_OPTION, BACKUP_OPTION, + BROTLI_OPTION, CHECK_DEVICE_OPTION, CHECKPOINT_OPTION, CHECKPOINT_ACTION_OPTION, @@ -720,6 +721,7 @@ static struct argp_option options[] = { {"use-compress-program", 'I', N_("PROG"), 0, N_("filter through PROG (must accept -d)"), GRID_COMPRESS }, /* Note: docstrings for the options below are generated by tar_help_filter */ + {"brotli", BROTLI_OPTION, 0, 0, NULL, GRID_COMPRESS }, {"bzip2", 'j', 0, 0, NULL, GRID_COMPRESS }, {"gzip", 'z', 0, 0, NULL, GRID_COMPRESS }, {"gunzip", 0, 0, OPTION_ALIAS, NULL, GRID_COMPRESS }, @@ -1146,6 +1148,10 @@ tar_help_filter (int key, const char *text, void *input) s = (char*) text; break; + case BROTLI_OPTION: + s = easprintf (_("filter the archive through %s"), BROTLI_PROGRAM); + break; + case 'j': s = easprintf (_("filter the archive through %s"), BZIP2_PROGRAM); break; @@ -1417,6 +1423,10 @@ parse_opt (int key, char *arg, struct argp_state *state) read_full_records_option = true; break; + case BROTLI_OPTION: + set_use_compress_program_option (BROTLI_PROGRAM, args->loc); + break; + case 'c': set_subcommand_option (CREATE_SUBCOMMAND); break; diff --git a/tests/testsuite.at b/tests/testsuite.at index 9ee9dd9a..6c3643a7 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -240,6 +240,7 @@ m4_popdef([CPT_CHECK]) AT_BANNER([Compression]) m4_include([compress.m4]) TAR_CHECK_COMPRESS(gzip, gz, tgz) +TAR_CHECK_COMPRESS(brotli, br, tbr) TAR_CHECK_COMPRESS(bzip2, bz2, tbz2) TAR_CHECK_COMPRESS(xz, xz, txz) dnl: omit lzma, because it would fail due to magic number mismatch -- 2.40.1