Make bzcat, lzcat, xzcat, zcat, lzopcat, unlzop individually selectable

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-11-16 15:45:05 +01:00
parent a8c696bf09
commit eb3fdc843e
3 changed files with 82 additions and 36 deletions

View File

@ -30,7 +30,7 @@ config FEATURE_SEAMLESS_GZ
Make tar, rpm, modprobe etc understand .gz data. Make tar, rpm, modprobe etc understand .gz data.
config FEATURE_SEAMLESS_Z config FEATURE_SEAMLESS_Z
bool "tar, rpm, modprobe etc understand .Z data" bool "Make tar, rpm, modprobe etc understand .Z data"
default n # it is ancient default n # it is ancient
help help
Make tar, rpm, modprobe etc understand .Z data. Make tar, rpm, modprobe etc understand .Z data.

View File

@ -291,18 +291,24 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
//config: You can use the `-t' option to test the integrity of //config: You can use the `-t' option to test the integrity of
//config: an archive, without decompressing it. //config: an archive, without decompressing it.
//config: //config:
//config:config ZCAT
//config: bool "zcat"
//config: default y
//config: help
//config: Alias to "gunzip -c".
//config:
//config:config FEATURE_GUNZIP_LONG_OPTIONS //config:config FEATURE_GUNZIP_LONG_OPTIONS
//config: bool "Enable long options" //config: bool "Enable long options"
//config: default y //config: default y
//config: depends on GUNZIP && LONG_OPTS //config: depends on (GUNZIP || ZCAT) && LONG_OPTS
//config: help //config: help
//config: Enable use of long options. //config: Enable use of long options.
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) //applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o //kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
#if ENABLE_GUNZIP //kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
#if ENABLE_GUNZIP || ENABLE_ZCAT
static static
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM) char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
{ {
@ -365,7 +371,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
* Normally, "zcat" is just "gunzip -c". * Normally, "zcat" is just "gunzip -c".
* But if seamless magic is enabled, then we are much more clever. * But if seamless magic is enabled, then we are much more clever.
*/ */
if (applet_name[1] == 'c') if (ENABLE_ZCAT && applet_name[1] == 'c')
option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC; option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC;
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL); return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL);
@ -402,18 +408,24 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
//config: //config:
//config: Unless you have a specific application which requires bunzip2, you //config: Unless you have a specific application which requires bunzip2, you
//config: should probably say N here. //config: should probably say N here.
//config:
//config:config BZCAT
//config: bool "bzcat"
//config: default y
//config: help
//config: Alias to "bunzip2 -c".
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) //applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o //kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
#if ENABLE_BUNZIP2 //kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
#if ENABLE_BUNZIP2 || ENABLE_BZCAT
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc UNUSED_PARAM, char **argv) int bunzip2_main(int argc UNUSED_PARAM, char **argv)
{ {
getopt32(argv, "cfvqdt"); getopt32(argv, "cfvqdt");
argv += optind; argv += optind;
if (applet_name[2] == 'c') /* bzcat */ if (ENABLE_BZCAT && applet_name[2] == 'c') /* bzcat */
option_mask32 |= OPT_STDOUT; option_mask32 |= OPT_STDOUT;
return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2"); return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2");
@ -481,27 +493,40 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
//config: The BusyBox unlzma applet is limited to decompression only. //config: The BusyBox unlzma applet is limited to decompression only.
//config: On an x86 system, this applet adds about 4K. //config: On an x86 system, this applet adds about 4K.
//config: //config:
//config:config FEATURE_LZMA_FAST //config:config LZCAT
//config: bool "Optimize unlzma for speed" //config: bool "lzcat"
//config: default n //config: default y
//config: depends on UNLZMA
//config: help //config: help
//config: This option reduces decompression time by about 25% at the cost of //config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
//config: a 1K bigger binary. //config: compression algorithm, and range coding. Compression
//config: is generally considerably better than that achieved by the bzip2
//config: compressors.
//config:
//config: The BusyBox unlzma applet is limited to decompression only.
//config: On an x86 system, this applet adds about 4K.
//config: //config:
//config:config LZMA //config:config LZMA
//config: bool "Provide lzma alias which supports only unpacking" //config: bool "lzma -d"
//config: default y //config: default y
//config: depends on UNLZMA
//config: help //config: help
//config: Enable this option if you want commands like "lzma -d" to work. //config: Enable this option if you want commands like "lzma -d" to work.
//config: IOW: you'll get lzma applet, but it will always require -d option. //config: IOW: you'll get lzma applet, but it will always require -d option.
//config:
//config:config FEATURE_LZMA_FAST
//config: bool "Optimize unlzma for speed"
//config: default n
//config: depends on UNLZMA || LZCAT || LZMA
//config: help
//config: This option reduces decompression time by about 25% at the cost of
//config: a 1K bigger binary.
//applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) //applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) //applet:IF_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
//applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) //applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))
//kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o //kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o
#if ENABLE_UNLZMA //kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o
//kbuild:lib-$(CONFIG_LZMA) += bbunzip.o
#if ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc UNUSED_PARAM, char **argv) int unlzma_main(int argc UNUSED_PARAM, char **argv)
{ {
@ -512,7 +537,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage(); bb_show_usage();
# endif # endif
/* lzcat? */ /* lzcat? */
if (applet_name[2] == 'c') if (ENABLE_LZCAT && applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT; option_mask32 |= OPT_STDOUT;
argv += optind; argv += optind;
@ -527,19 +552,26 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
//config: help //config: help
//config: unxz is a unlzma successor. //config: unxz is a unlzma successor.
//config: //config:
//config:config XZ //config:config XZCAT
//config: bool "Provide xz alias which supports only unpacking" //config: bool "xzcat"
//config: default y
//config: help
//config: Alias to "unxz -c".
//config:
//config:config XZ
//config: bool "xz -d"
//config: default y //config: default y
//config: depends on UNXZ
//config: help //config: help
//config: Enable this option if you want commands like "xz -d" to work. //config: Enable this option if you want commands like "xz -d" to work.
//config: IOW: you'll get xz applet, but it will always require -d option. //config: IOW: you'll get xz applet, but it will always require -d option.
//applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) //applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) //applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
//applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) //applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))
//kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o //kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o
#if ENABLE_UNXZ //kbuild:lib-$(CONFIG_XZCAT) += bbunzip.o
//kbuild:lib-$(CONFIG_XZ) += bbunzip.o
#if ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unxz_main(int argc UNUSED_PARAM, char **argv) int unxz_main(int argc UNUSED_PARAM, char **argv)
{ {
@ -550,7 +582,7 @@ int unxz_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage(); bb_show_usage();
# endif # endif
/* xzcat? */ /* xzcat? */
if (applet_name[2] == 'c') if (ENABLE_XZCAT && applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT; option_mask32 |= OPT_STDOUT;
argv += optind; argv += optind;

View File

@ -31,19 +31,33 @@
//config: help //config: help
//config: Lzop compression/decompresion. //config: Lzop compression/decompresion.
//config: //config:
//config:config UNLZOP
//config: bool "unlzop"
//config: default y
//config: help
//config: Lzop decompresion.
//config:
//config:config LZOPCAT
//config: bool "lzopcat"
//config: default y
//config: help
//config: Alias to "unlzop -c".
//config:
//config:config LZOP_COMPR_HIGH //config:config LZOP_COMPR_HIGH
//config: bool "lzop compression levels 7,8,9 (not very useful)" //config: bool "lzop compression levels 7,8,9 (not very useful)"
//config: default n //config: default n
//config: depends on LZOP //config: depends on LZOP || UNLZOP || LZOPCAT
//config: help //config: help
//config: High levels (7,8,9) of lzop compression. These levels //config: High levels (7,8,9) of lzop compression. These levels
//config: are actually slower than gzip at equivalent compression ratios //config: are actually slower than gzip at equivalent compression ratios
//config: and take up 3.2K of code. //config: and take up 3.2K of code.
//applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) //applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) //applet:IF_UNLZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))
//applet:IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) //applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))
//kbuild:lib-$(CONFIG_LZOP) += lzop.o //kbuild:lib-$(CONFIG_LZOP) += lzop.o
//kbuild:lib-$(CONFIG_UNLZOP) += lzop.o
//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o
//usage:#define lzop_trivial_usage //usage:#define lzop_trivial_usage
//usage: "[-cfvd123456789CF] [FILE]..." //usage: "[-cfvd123456789CF] [FILE]..."
@ -57,18 +71,18 @@
//usage: "\n -C Also write checksum of compressed block" //usage: "\n -C Also write checksum of compressed block"
//usage: //usage:
//usage:#define lzopcat_trivial_usage //usage:#define lzopcat_trivial_usage
//usage: "[-vCF] [FILE]..." //usage: "[-vF] [FILE]..."
//usage:#define lzopcat_full_usage "\n\n" //usage:#define lzopcat_full_usage "\n\n"
//usage: " -v Verbose" //usage: " -v Verbose"
//usage: "\n -F Don't store or verify checksum" //usage: "\n -F Don't verify checksum"
//usage: //usage:
//usage:#define unlzop_trivial_usage //usage:#define unlzop_trivial_usage
//usage: "[-cfvCF] [FILE]..." //usage: "[-cfvF] [FILE]..."
//usage:#define unlzop_full_usage "\n\n" //usage:#define unlzop_full_usage "\n\n"
//usage: " -c Write to stdout" //usage: " -c Write to stdout"
//usage: "\n -f Force" //usage: "\n -f Force"
//usage: "\n -v Verbose" //usage: "\n -v Verbose"
//usage: "\n -F Don't store or verify checksum" //usage: "\n -F Don't verify checksum"
#include "libbb.h" #include "libbb.h"
#include "common_bufsiz.h" #include "common_bufsiz.h"
@ -1111,10 +1125,10 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
getopt32(argv, OPTION_STRING); getopt32(argv, OPTION_STRING);
argv += optind; argv += optind;
/* lzopcat? */ /* lzopcat? */
if (applet_name[4] == 'c') if (ENABLE_LZOPCAT && applet_name[4] == 'c')
option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS); option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS);
/* unlzop? */ /* unlzop? */
if (applet_name[4] == 'o') if (ENABLE_UNLZOP && applet_name[4] == 'o')
option_mask32 |= OPT_DECOMPRESS; option_mask32 |= OPT_DECOMPRESS;
global_crc32_table = crc32_filltable(NULL, 0); global_crc32_table = crc32_filltable(NULL, 0);