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
This commit is contained in:
Sergey Poznyakoff
2009-03-04 16:50:31 +00:00
parent 7a968d67c8
commit c10830a35b
6 changed files with 70 additions and 10 deletions

View File

@@ -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]))

View File

@@ -40,6 +40,7 @@ struct compression_suffix compression_suffixes[] = {
{ S(lzma, lzma) },
{ S(tlz, lzma) },
{ S(lzo, lzop) },
{ S(xz, xz) },
#undef S
};

View File

@@ -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;