From: Sergey Poznyakoff Date: Wed, 4 Mar 2009 16:50:31 +0000 (+0000) Subject: Add xz support. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=c10830a35ba2e0e86dc10c5ab9bbaf163d4c0b3a;p=chaz%2Ftar Add xz support. * src/buffer.c, src/suffix.c: Add support for xz compression. * src/tar.c: New option --xz, for compression/decompression using xz. Re-assign -J as a short equivalent of --xz. * doc/tar.texi, NEWS: Document --xz --- diff --git a/ChangeLog b/ChangeLog index f205339..1584078 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-03-04 Sergey Poznyakoff + + Add xz support. + + * src/buffer.c, src/suffix.c: Add support for xz compression. + * src/tar.c: New option --xz, for compression/decompression using xz. + Re-assign -J as a short equivalent of --xz. + 2009-01-19 Sergey Poznyakoff * doc/tar.texi: Fix typo. diff --git a/NEWS b/NEWS index 41b30ea..5324a4d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,37 @@ -GNU tar NEWS - User visible changes. 2008-12-27 +GNU tar NEWS - User visible changes. 2009-03-04 Please send GNU tar bug reports to + +version 1.21.90 (CVS) + +* Support for xz compression + +Tar uses xz for compression if at least one of the following +conditions is met: + + 1. The option --xz or -J (see below) is used. + 2. The xz binary is set as compressor using --use-compress-program option. + 3. The file name of the archive being created ends in `.xz' and + auto-compress option (-a) is used. + +Xz is used for decompression if at least one of the following +conditions is met: + + 1. The option --xz or -J is used. + 2. The xz binary is set as compressor using --use-compress-program option. + 3. The file is recognized as xz compressed stream data. + +* Short option -J + +The decision to assign -J option was taken just before the XZ format +has been officially declared stable. Now, that stable xz tools are +available, the -J option is re-assigned as a short equivalent of --xz. + +* New option -I + +The -I option is assigned as a short equivalent for +--use-compress-program. + version 1.21 - Sergey Poznyakoff, 2008-12-27 diff --git a/doc/tar.texi b/doc/tar.texi index ac86765..20f1807 100644 --- a/doc/tar.texi +++ b/doc/tar.texi @@ -2786,7 +2786,6 @@ incremental format. @xref{Incremental Dumps}. @opsummary{lzma} @item --lzma -@itemx -J This option tells @command{tar} to read or write archives through @command{lzma}. @xref{gzip}. @@ -3359,6 +3358,12 @@ Use wildcards when matching member names with patterns. @item --wildcards-match-slash Wildcards match @samp{/}. @xref{controlling pattern-matching}. + +@opsummary{xz} +@item --xz +@itemx -J +Use @command{xz} for compressing or decompressing the archives. @xref{gzip}. + @end table @node Short Option Summary @@ -3380,7 +3385,7 @@ them with the equivalent long option. @item -G @tab @ref{--incremental}. -@item -J @tab @ref{--lzma}. +@item -J @tab @ref{--xz}. @item -K @tab @ref{--starting-file}. @@ -8406,7 +8411,8 @@ Creating a compressed archive is simple: you just specify a commands. The compression option is @option{-z} (@option{--gzip}) to create a @command{gzip} compressed archive, @option{-j} (@option{--bzip2}) to create a @command{bzip2} compressed archive, -@option{-J} (@option{--lzma}) to create an @asis{LZMA} compressed +@option{-J} (@option{--xz}) to create an @asis{XZ} archive, +@option{--lzma} to create an @asis{LZMA} compressed archive, @option{--lzop} to create an @asis{LSOP} archive, and @option{-Z} (@option{--compress}) to use @command{compress} program. For example: @@ -8504,6 +8510,7 @@ suffix. The following suffixes are recognized: @item @samp{.lzma} @tab @command{lzma} @item @samp{.tlz} @tab @command{lzma} @item @samp{.lzo} @tab @command{lzop} +@item @samp{.xz} @tab @command{xz} @end multitable @opindex gzip @@ -8548,13 +8555,17 @@ lose some compressibility. But this would have make recovering easier. So, there are pros and cons. We'll see! @opindex bzip2 +@item -J +@itemx --xz +Filter the archive through @code{xz}. Otherwise like +@option{--gzip}. + @item -j @itemx --bzip2 Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}. @opindex lzma @item --lzma -@itemx -J Filter the archive through @command{lzma}. Otherwise like @option{--gzip}. @opindex lzop diff --git a/src/buffer.c b/src/buffer.c index 5f5457a..a646202 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -204,7 +204,8 @@ enum compress_type { ct_gzip, ct_bzip2, ct_lzma, - ct_lzop + ct_lzop, + ct_xz }; struct zip_magic @@ -222,8 +223,9 @@ static struct zip_magic const magic[] = { { ct_compress, 2, "\037\235", "compress", "-Z" }, { ct_gzip, 2, "\037\213", "gzip", "-z" }, { ct_bzip2, 3, "BZh", "bzip2", "-j" }, - { ct_lzma, 6, "\xFFLZMA", "lzma", "-J" }, /* FIXME: ???? */ + { ct_lzma, 6, "\xFFLZMA", "lzma", "--lzma" }, /* FIXME: ???? */ { ct_lzop, 4, "\211LZO", "lzop", "--lzop" }, + { ct_xz, 6, "\0xFD7zXZ", "-J" }, }; #define NMAGIC (sizeof(magic)/sizeof(magic[0])) diff --git a/src/suffix.c b/src/suffix.c index 986f347..9080fd6 100644 --- a/src/suffix.c +++ b/src/suffix.c @@ -40,6 +40,7 @@ struct compression_suffix compression_suffixes[] = { { S(lzma, lzma) }, { S(tlz, lzma) }, { S(lzo, lzop) }, + { S(xz, xz) }, #undef S }; diff --git a/src/tar.c b/src/tar.c index 8396ad5..8c83959 100644 --- a/src/tar.c +++ b/src/tar.c @@ -271,6 +271,7 @@ enum IGNORE_FAILED_READ_OPTION, INDEX_FILE_OPTION, KEEP_NEWER_FILES_OPTION, + LZMA_OPTION, LZOP_OPTION, MODE_OPTION, MTIME_OPTION, @@ -593,7 +594,7 @@ static struct argp_option options[] = { {"auto-compress", 'a', 0, 0, N_("use archive suffix to determine the compression program"), GRID+1 }, {"no-auto-compress", NO_AUTO_COMPRESS_OPTION, 0, 0, - N_("do not use use archive suffix to determine the compression program"), + N_("do not use archive suffix to determine the compression program"), GRID+1 }, {"bzip2", 'j', 0, 0, N_("filter the archive through bzip2"), GRID+1 }, @@ -604,10 +605,12 @@ static struct argp_option options[] = { {"compress", 'Z', 0, 0, N_("filter the archive through compress"), GRID+1 }, {"uncompress", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, - {"lzma", 'J', 0, 0, + {"lzma", LZMA_OPTION, 0, 0, N_("filter the archive through lzma"), GRID+1 }, {"lzop", LZOP_OPTION, 0, 0, N_("filter the archive through lzop"), GRID+8 }, + {"xz", 'J', 0, 0, + N_("filter the archive through xz"), GRID+8 }, {"use-compress-program", 'I', N_("PROG"), 0, N_("filter through PROG (must accept -d)"), GRID+1 }, #undef GRID @@ -1367,7 +1370,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'J': - set_use_compress_program_option ("lzma"); + set_use_compress_program_option ("xz"); break; case 'k': @@ -1401,6 +1404,10 @@ parse_opt (int key, char *arg, struct argp_state *state) } break; + case LZMA_OPTION: + set_use_compress_program_option ("lzma"); + break; + case LZOP_OPTION: set_use_compress_program_option ("lzop"); break;