diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-05-29 05:39:10 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-05-29 05:39:10 +0000 |
commit | 57eb78da4c46c88fa232f249fb32318f1c9f78f6 (patch) | |
tree | 65824c6a122704c18c5f4261710047c9567d981a /usr.bin | |
parent | 052215bb5907c5ca24320dcce2a2aadf3a17cb6c (diff) | |
download | FreeBSD-src-57eb78da4c46c88fa232f249fb32318f1c9f78f6.zip FreeBSD-src-57eb78da4c46c88fa232f249fb32318f1c9f78f6.tar.gz |
bsdtar 2.2.3:
* Implement --use-compress-program using new libarchive feature.
* Minor portability improvement by adjusting casts used to
print out uids, gids, and device numbers.
Thanks to: Joerg Sonnenberger for the --use-compress-program implementation.
MFC after: 15 days
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tar/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/tar/bsdtar.1 | 4 | ||||
-rw-r--r-- | usr.bin/tar/bsdtar.c | 6 | ||||
-rw-r--r-- | usr.bin/tar/bsdtar.h | 1 | ||||
-rw-r--r-- | usr.bin/tar/read.c | 15 | ||||
-rw-r--r-- | usr.bin/tar/write.c | 31 |
6 files changed, 39 insertions, 20 deletions
diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile index 2ac23b2..15b386a 100644 --- a/usr.bin/tar/Makefile +++ b/usr.bin/tar/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= bsdtar -VERSION= 2.0.28 +VERSION= 2.2.3 SRCS= bsdtar.c getdate.y matching.c read.c tree.c util.c write.c WARNS?= 5 DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} diff --git a/usr.bin/tar/bsdtar.1 b/usr.bin/tar/bsdtar.1 index 651df62..e6350dc 100644 --- a/usr.bin/tar/bsdtar.1 +++ b/usr.bin/tar/bsdtar.1 @@ -360,6 +360,10 @@ Without this option, overwrites existing files, which preserves existing hardlinks. With this option, existing hardlinks will be broken, as will any symlink that would affect the location of an extracted file. +.It Fl -use-compress-program Ar program +Pipe the input (in x or t mode) or the output (in c mode) through +.Pa program +instead of using the builtin compression support. .It Fl v Produce verbose output. In create and extract modes, diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index 7626a43..5ada551 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -145,6 +145,7 @@ enum { OPTION_ONE_FILE_SYSTEM, OPTION_STRIP_COMPONENTS, OPTION_TOTALS, + OPTION_USE_COMPRESS_PROGRAM, OPTION_VERSION }; @@ -202,6 +203,8 @@ static const struct option tar_longopts[] = { { "unlink", no_argument, NULL, 'U' }, { "unlink-first", no_argument, NULL, 'U' }, { "update", no_argument, NULL, 'u' }, + { "use-compress-program", + required_argument, NULL, OPTION_USE_COMPRESS_PROGRAM }, { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, OPTION_VERSION }, { NULL, 0, NULL, 0 } @@ -558,6 +561,9 @@ main(int argc, char **argv) usage(bsdtar); #endif break; + case OPTION_USE_COMPRESS_PROGRAM: + bsdtar->compress_program = optarg; + break; default: usage(bsdtar); } diff --git a/usr.bin/tar/bsdtar.h b/usr.bin/tar/bsdtar.h index 6b51080..8a56ddf 100644 --- a/usr.bin/tar/bsdtar.h +++ b/usr.bin/tar/bsdtar.h @@ -55,6 +55,7 @@ struct bsdtar { char mode; /* Program mode: 'c', 't', 'r', 'u', 'x' */ char symlink_mode; /* H or L, per BSD conventions */ char create_compression; /* j, y, or z */ + const char *compress_program; char option_absolute_paths; /* -P */ char option_dont_traverse_mounts; /* --one-file-system */ char option_fast_read; /* --fast-read */ diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c index 4763b13..dead37a 100644 --- a/usr.bin/tar/read.c +++ b/usr.bin/tar/read.c @@ -106,7 +106,10 @@ read_archive(struct bsdtar *bsdtar, char mode) include_from_file(bsdtar, bsdtar->names_from_file); a = archive_read_new(); - archive_read_support_compression_all(a); + if (bsdtar->compress_program != NULL) + archive_read_support_compression_program(a, bsdtar->compress_program); + else + archive_read_support_compression_all(a); archive_read_support_format_all(a); if (archive_read_open_file(a, bsdtar->filename, bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block : @@ -294,7 +297,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) /* Use uname if it's present, else uid. */ p = archive_entry_uname(entry); if ((p == NULL) || (*p == '\0')) { - sprintf(tmp, "%d ", st->st_uid); + sprintf(tmp, "%lu ", (unsigned long)st->st_uid); p = tmp; } w = strlen(p); @@ -308,7 +311,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) fprintf(out, "%s", p); w = strlen(p); } else { - sprintf(tmp, "%d", st->st_gid); + sprintf(tmp, "%lu", (unsigned long)st->st_gid); w = strlen(tmp); fprintf(out, "%s", tmp); } @@ -319,9 +322,9 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) * If gs_width is too small, grow it. */ if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) { - sprintf(tmp, "%d,%u", - major(st->st_rdev), - (unsigned)minor(st->st_rdev)); /* ls(1) also casts here. */ + sprintf(tmp, "%lu,%lu", + (unsigned long)major(st->st_rdev), + (unsigned long)minor(st->st_rdev)); /* ls(1) also casts here. */ } else { /* * Note the use of platform-dependent macros to format diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 76d6fcf..0efddd0 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -203,23 +203,28 @@ tar_mode_c(struct bsdtar *bsdtar) } else archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK); - switch (bsdtar->create_compression) { - case 0: - break; + if (bsdtar->compress_program) { + archive_write_set_compression_program(a, bsdtar->compress_program); + } else { + switch (bsdtar->create_compression) { + case 0: + archive_write_set_compression_none(a); + break; #ifdef HAVE_LIBBZ2 - case 'j': case 'y': - archive_write_set_compression_bzip2(a); - break; + case 'j': case 'y': + archive_write_set_compression_bzip2(a); + break; #endif #ifdef HAVE_LIBZ - case 'z': - archive_write_set_compression_gzip(a); - break; + case 'z': + archive_write_set_compression_gzip(a); + break; #endif - default: - bsdtar_errc(bsdtar, 1, 0, - "Unrecognized compression option -%c", - bsdtar->create_compression); + default: + bsdtar_errc(bsdtar, 1, 0, + "Unrecognized compression option -%c", + bsdtar->create_compression); + } } r = archive_write_open_file(a, bsdtar->filename); |