summaryrefslogtreecommitdiff
path: root/tar
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2009-01-31 01:31:15 -0500
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2009-01-31 01:31:15 -0500
commitc25e0da2e8d6091bea7ff1c86940808a0bd79eef (patch)
treed6343a586ef9157026ab8cccfe3ac2b9b8a26b60 /tar
parent0c4a6ac2747acd743044720e5e23f024e1127894 (diff)
downloadlibarchive-c25e0da2e8d6091bea7ff1c86940808a0bd79eef.tar.gz
Add support xz format and compressing lzma format.
SVN-Revision: 521
Diffstat (limited to 'tar')
-rw-r--r--tar/bsdtar.c26
-rw-r--r--tar/bsdtar.h3
-rw-r--r--tar/cmdline.c4
-rw-r--r--tar/write.c8
4 files changed, 39 insertions, 2 deletions
diff --git a/tar/bsdtar.c b/tar/bsdtar.c
index 65975dff..0fc83750 100644
--- a/tar/bsdtar.c
+++ b/tar/bsdtar.c
@@ -251,6 +251,19 @@ main(int argc, char **argv)
usage(bsdtar);
#endif
break;
+ case 'J': /* GNU tar 1.21 and later */
+#if HAVE_LIBLZMA
+ if (bsdtar->create_compression != '\0')
+ bsdtar_errc(bsdtar, 1, 0,
+ "Can't specify both -%c and -%c", opt,
+ bsdtar->create_compression);
+ bsdtar->create_compression = opt;
+#else
+ bsdtar_warnc(bsdtar, 0,
+ "lzma compression not supported by this version of bsdtar");
+ usage(bsdtar);
+#endif
+ break;
case 'k': /* GNU tar */
bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
break;
@@ -420,6 +433,19 @@ main(int argc, char **argv)
case 'x': /* SUSv2 */
set_mode(bsdtar, opt);
break;
+ case OPTION_XZ:
+#if HAVE_LIBLZMA
+ if (bsdtar->create_compression != '\0')
+ bsdtar_errc(bsdtar, 1, 0,
+ "Can't specify both -%c and -%c", opt,
+ bsdtar->create_compression);
+ bsdtar->create_compression = opt;
+#else
+ bsdtar_warnc(bsdtar, 0,
+ "xz compression not supported by this version of bsdtar");
+ usage(bsdtar);
+#endif
+ break;
case 'y': /* FreeBSD version of GNU tar */
#if HAVE_LIBBZ2
if (bsdtar->create_compression != '\0')
diff --git a/tar/bsdtar.h b/tar/bsdtar.h
index a427b9a3..8315453e 100644
--- a/tar/bsdtar.h
+++ b/tar/bsdtar.h
@@ -129,7 +129,8 @@ enum {
OPTION_STRIP_COMPONENTS,
OPTION_TOTALS,
OPTION_USE_COMPRESS_PROGRAM,
- OPTION_VERSION
+ OPTION_VERSION,
+ OPTION_XZ
};
diff --git a/tar/cmdline.c b/tar/cmdline.c
index ad8b487a..c24b3d54 100644
--- a/tar/cmdline.c
+++ b/tar/cmdline.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
* Short options for tar. Please keep this sorted.
*/
static const char *short_options
- = "Bb:C:cf:HhI:jkLlmnOoPpqrSs:T:tUuvW:wX:xyZz";
+ = "Bb:C:cf:HhI:JjkLlmnOoPpqrSs:T:tUuvW:wX:xyZz";
/*
* Long options for tar. Please keep this list sorted.
@@ -93,6 +93,7 @@ static struct option {
{ "keep-newer-files", 0, OPTION_KEEP_NEWER_FILES },
{ "keep-old-files", 0, 'k' },
{ "list", 0, 't' },
+ { "lzma", 0, 'J' },
{ "modification-time", 0, 'm' },
{ "newer", 1, OPTION_NEWER_CTIME },
{ "newer-ctime", 1, OPTION_NEWER_CTIME },
@@ -122,6 +123,7 @@ static struct option {
{ "use-compress-program", 1, OPTION_USE_COMPRESS_PROGRAM },
{ "verbose", 0, 'v' },
{ "version", 0, OPTION_VERSION },
+ { "xz", 0, OPTION_XZ },
{ NULL, 0, 0 }
};
diff --git a/tar/write.c b/tar/write.c
index 6bb317cd..fa143d6b 100644
--- a/tar/write.c
+++ b/tar/write.c
@@ -182,6 +182,14 @@ tar_mode_c(struct bsdtar *bsdtar)
archive_write_set_compression_bzip2(a);
break;
#endif
+#ifdef HAVE_LIBLZMA
+ case 'J':
+ archive_write_set_compression_lzma(a);
+ break;
+ case OPTION_XZ:
+ archive_write_set_compression_xz(a);
+ break;
+#endif
#ifdef HAVE_LIBZ
case 'z':
archive_write_set_compression_gzip(a);