aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2007-05-29 05:39:10 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2007-05-29 05:39:10 +0000
commita38d1d4c8b6eb95203da19880cd5413a1ec96bde (patch)
tree65824c6a122704c18c5f4261710047c9567d981a
parentcebf6b9f640708f7a8ac808ba8047ffb579b2db7 (diff)
downloadsrc-a38d1d4c8b6eb95203da19880cd5413a1ec96bde.tar.gz
src-a38d1d4c8b6eb95203da19880cd5413a1ec96bde.zip
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
Notes
Notes: svn path=/head/; revision=170084
-rw-r--r--usr.bin/tar/Makefile2
-rw-r--r--usr.bin/tar/bsdtar.14
-rw-r--r--usr.bin/tar/bsdtar.c6
-rw-r--r--usr.bin/tar/bsdtar.h1
-rw-r--r--usr.bin/tar/read.c15
-rw-r--r--usr.bin/tar/write.c31
6 files changed, 39 insertions, 20 deletions
diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile
index 2ac23b2c1f37..15b386ab901f 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 651df62bdaea..e6350dccc1c8 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 7626a43d048a..5ada5518ca68 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 6b5108033cbb..8a56ddfea984 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 4763b13ae0f4..dead37a22c8d 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 76d6fcfd1c24..0efddd097746 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);