bsdtar doesn't actually know what compression is supported by libarchive
and it should not pretend that it does. It should just pass along the user's request and handle an error if it's not supported.
This commit is contained in:
parent
4392f2bf72
commit
6b176158d3
@ -299,30 +299,18 @@ main(int argc, char **argv)
|
|||||||
bsdtar->optarg);
|
bsdtar->optarg);
|
||||||
break;
|
break;
|
||||||
case 'j': /* GNU tar */
|
case 'j': /* GNU tar */
|
||||||
#if HAVE_LIBBZ2
|
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Can't specify both -%c and -%c", opt,
|
"Can't specify both -%c and -%c", opt,
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
#else
|
|
||||||
bsdtar_warnc(0,
|
|
||||||
"bzip2 compression not supported by this version of bsdtar");
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'J': /* GNU tar 1.21 and later */
|
case 'J': /* GNU tar 1.21 and later */
|
||||||
#if HAVE_LIBLZMA
|
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Can't specify both -%c and -%c", opt,
|
"Can't specify both -%c and -%c", opt,
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
#else
|
|
||||||
bsdtar_warnc(0,
|
|
||||||
"xz compression not supported by this version of bsdtar");
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'k': /* GNU tar */
|
case 'k': /* GNU tar */
|
||||||
bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
|
bsdtar->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
|
||||||
@ -338,17 +326,11 @@ main(int argc, char **argv)
|
|||||||
bsdtar->option_warn_links = 1;
|
bsdtar->option_warn_links = 1;
|
||||||
break;
|
break;
|
||||||
case OPTION_LZMA:
|
case OPTION_LZMA:
|
||||||
#if HAVE_LIBLZMA
|
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Can't specify both -%c and -%c", opt,
|
"Can't specify both -%c and -%c", opt,
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
#else
|
|
||||||
bsdtar_warnc(0,
|
|
||||||
"lzma compression not supported by this version of bsdtar");
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'm': /* SUSv2 */
|
case 'm': /* SUSv2 */
|
||||||
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_TIME;
|
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_TIME;
|
||||||
@ -510,17 +492,11 @@ main(int argc, char **argv)
|
|||||||
set_mode(bsdtar, opt);
|
set_mode(bsdtar, opt);
|
||||||
break;
|
break;
|
||||||
case 'y': /* FreeBSD version of GNU tar */
|
case 'y': /* FreeBSD version of GNU tar */
|
||||||
#if HAVE_LIBBZ2
|
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Can't specify both -%c and -%c", opt,
|
"Can't specify both -%c and -%c", opt,
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
#else
|
|
||||||
bsdtar_warnc(0,
|
|
||||||
"bzip2 compression not supported by this version of bsdtar");
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'Z': /* GNU tar */
|
case 'Z': /* GNU tar */
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
@ -530,17 +506,11 @@ main(int argc, char **argv)
|
|||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
break;
|
break;
|
||||||
case 'z': /* GNU tar, star, many others */
|
case 'z': /* GNU tar, star, many others */
|
||||||
#if HAVE_LIBZ
|
|
||||||
if (bsdtar->create_compression != '\0')
|
if (bsdtar->create_compression != '\0')
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Can't specify both -%c and -%c", opt,
|
"Can't specify both -%c and -%c", opt,
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
bsdtar->create_compression = opt;
|
bsdtar->create_compression = opt;
|
||||||
#else
|
|
||||||
bsdtar_warnc(0,
|
|
||||||
"gzip compression not supported by this version of bsdtar");
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case OPTION_USE_COMPRESS_PROGRAM:
|
case OPTION_USE_COMPRESS_PROGRAM:
|
||||||
bsdtar->compress_program = bsdtar->optarg;
|
bsdtar->compress_program = bsdtar->optarg;
|
||||||
|
@ -185,34 +185,33 @@ tar_mode_c(struct bsdtar *bsdtar)
|
|||||||
} else {
|
} else {
|
||||||
switch (bsdtar->create_compression) {
|
switch (bsdtar->create_compression) {
|
||||||
case 0:
|
case 0:
|
||||||
archive_write_set_compression_none(a);
|
r = archive_write_set_compression_none(a);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_LIBBZ2
|
|
||||||
case 'j': case 'y':
|
case 'j': case 'y':
|
||||||
archive_write_set_compression_bzip2(a);
|
r = archive_write_set_compression_bzip2(a);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIBLZMA
|
|
||||||
case 'J':
|
case 'J':
|
||||||
archive_write_set_compression_xz(a);
|
r = archive_write_set_compression_xz(a);
|
||||||
break;
|
break;
|
||||||
case OPTION_LZMA:
|
case OPTION_LZMA:
|
||||||
archive_write_set_compression_lzma(a);
|
r = archive_write_set_compression_lzma(a);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIBZ
|
|
||||||
case 'z':
|
case 'z':
|
||||||
archive_write_set_compression_gzip(a);
|
r = archive_write_set_compression_gzip(a);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case 'Z':
|
case 'Z':
|
||||||
archive_write_set_compression_compress(a);
|
r = archive_write_set_compression_compress(a);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bsdtar_errc(1, 0,
|
bsdtar_errc(1, 0,
|
||||||
"Unrecognized compression option -%c",
|
"Unrecognized compression option -%c",
|
||||||
bsdtar->create_compression);
|
bsdtar->create_compression);
|
||||||
}
|
}
|
||||||
|
if (r != ARCHIVE_OK) {
|
||||||
|
bsdtar_errc(1, 0,
|
||||||
|
"Unsupported compression option -%c",
|
||||||
|
bsdtar->create_compression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
|
if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
|
||||||
|
Loading…
Reference in New Issue
Block a user