diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-29 14:36:11 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-29 14:36:11 +0200 |
commit | 9ce07e778f05719115f354d4907f51295fb3fd1a (patch) | |
tree | 1f204121b58c0a86904e376d2fc6b08f9c3ce881 | |
parent | 7715b48c36a453b41f4555ee57c2f936e25f06f1 (diff) | |
download | busybox-w32-9ce07e778f05719115f354d4907f51295fb3fd1a.tar.gz busybox-w32-9ce07e778f05719115f354d4907f51295fb3fd1a.tar.bz2 busybox-w32-9ce07e778f05719115f354d4907f51295fb3fd1a.zip |
bbconfig: add COMPRESS_BBCONFIG option
function old new delta
bbconfig_config_bz2 - 4905 +4905
bbconfig_main 13 70 +57
bbconfig_config 21811 - -21811
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 4962/-21811) Total: -16849 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | archival/libunarchive/Kbuild.src | 1 | ||||
-rw-r--r-- | miscutils/Config.src | 14 | ||||
-rw-r--r-- | miscutils/bbconfig.c | 22 | ||||
-rwxr-xr-x | scripts/mkconfigs | 40 |
5 files changed, 70 insertions, 9 deletions
@@ -842,7 +842,7 @@ export CPPFLAGS_busybox.lds += -P -C -U$(ARCH) | |||
842 | 842 | ||
843 | # Split autoconf.h into include/linux/config/* | 843 | # Split autoconf.h into include/linux/config/* |
844 | quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h | 844 | quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h |
845 | cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs > include/bbconfigopts.h | 845 | cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs include/bbconfigopts.h include/bbconfigopts_bz2.h |
846 | quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/* | 846 | quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/* |
847 | cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config | 847 | cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config |
848 | #bbox# piggybacked generation of few .h files | 848 | #bbox# piggybacked generation of few .h files |
diff --git a/archival/libunarchive/Kbuild.src b/archival/libunarchive/Kbuild.src index c7ba4479c..e92b4aad2 100644 --- a/archival/libunarchive/Kbuild.src +++ b/archival/libunarchive/Kbuild.src | |||
@@ -54,6 +54,7 @@ lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2 | |||
54 | lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o | 54 | lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o |
55 | lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o | 55 | lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o |
56 | lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o | 56 | lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o |
57 | lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += decompress_bunzip2.o | ||
57 | lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o | 58 | lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o |
58 | 59 | ||
59 | ifneq ($(lib-y),) | 60 | ifneq ($(lib-y),) |
diff --git a/miscutils/Config.src b/miscutils/Config.src index cadaabb65..151f61bcc 100644 --- a/miscutils/Config.src +++ b/miscutils/Config.src | |||
@@ -22,6 +22,20 @@ config BBCONFIG | |||
22 | The bbconfig applet will print the config file with which | 22 | The bbconfig applet will print the config file with which |
23 | busybox was built. | 23 | busybox was built. |
24 | 24 | ||
25 | config FEATURE_COMPRESS_BBCONFIG | ||
26 | bool "Compress bbconfig data" | ||
27 | default y | ||
28 | depends on BBCONFIG | ||
29 | help | ||
30 | Store bbconfig data in compressed form, uncompress them on-the-fly | ||
31 | before output. | ||
32 | |||
33 | If you have a really tiny busybox with few applets enabled (and | ||
34 | bunzip2 isn't one of them), the overhead of the decompressor might | ||
35 | be noticeable. Also, if you run executables directly from ROM | ||
36 | and have very little memory, this might not be a win. Otherwise, | ||
37 | you probably want this. | ||
38 | |||
25 | config BEEP | 39 | config BEEP |
26 | bool "beep" | 40 | bool "beep" |
27 | default y | 41 | default y |
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c index 0d649b4e5..286077168 100644 --- a/miscutils/bbconfig.c +++ b/miscutils/bbconfig.c | |||
@@ -3,10 +3,32 @@ | |||
3 | */ | 3 | */ |
4 | #include "libbb.h" | 4 | #include "libbb.h" |
5 | #include "bbconfigopts.h" | 5 | #include "bbconfigopts.h" |
6 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG | ||
7 | # include "unarchive.h" | ||
8 | # include "bbconfigopts_bz2.h" | ||
9 | #endif | ||
6 | 10 | ||
7 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 11 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
8 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 12 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
9 | { | 13 | { |
14 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG | ||
15 | bunzip_data *bd; | ||
16 | int i = start_bunzip(&bd, | ||
17 | /* src_fd: */ -1, | ||
18 | /* inbuf: */ (void *)bbconfig_config_bz2, | ||
19 | /* len: */ sizeof(bbconfig_config_bz2)); | ||
20 | /* read_bunzip can longjmp to start_bunzip, and ultimately | ||
21 | * end up here with i != 0 on read data errors! Not trivial */ | ||
22 | if (!i) { | ||
23 | /* Cannot use xmalloc: will leak bd in NOFORK case! */ | ||
24 | char *outbuf = malloc_or_warn(sizeof(bbconfig_config)); | ||
25 | if (outbuf) { | ||
26 | read_bunzip(bd, outbuf, sizeof(bbconfig_config)); | ||
27 | full_write1_str(outbuf); | ||
28 | } | ||
29 | } | ||
30 | #else | ||
10 | full_write1_str(bbconfig_config); | 31 | full_write1_str(bbconfig_config); |
32 | #endif | ||
11 | return 0; | 33 | return 0; |
12 | } | 34 | } |
diff --git a/scripts/mkconfigs b/scripts/mkconfigs index 65dd44179..38d7ac054 100755 --- a/scripts/mkconfigs +++ b/scripts/mkconfigs | |||
@@ -26,12 +26,9 @@ | |||
26 | # - Retain lines that begin with "# CONFIG_" | 26 | # - Retain lines that begin with "# CONFIG_" |
27 | # - lines that use double-quotes must \\-escape-quote them | 27 | # - lines that use double-quotes must \\-escape-quote them |
28 | 28 | ||
29 | config="$1" | 29 | config=.config |
30 | if [ $# -lt 1 ] | ||
31 | then | ||
32 | config=.config | ||
33 | fi | ||
34 | 30 | ||
31 | { | ||
35 | echo "\ | 32 | echo "\ |
36 | #ifndef _BBCONFIGOPTS_H | 33 | #ifndef _BBCONFIGOPTS_H |
37 | #define _BBCONFIGOPTS_H | 34 | #define _BBCONFIGOPTS_H |
@@ -43,9 +40,36 @@ echo "\ | |||
43 | * This file is generated automatically by scripts/mkconfigs. | 40 | * This file is generated automatically by scripts/mkconfigs. |
44 | * Do not edit. | 41 | * Do not edit. |
45 | */ | 42 | */ |
46 | static const char bbconfig_config[] =" | 43 | static const char bbconfig_config[] ALIGN1 =" |
47 | 44 | ||
48 | sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' | 45 | grep '^#\? \?CONFIG_' "$config" \ |
46 | | sed -e 's/\"/\\\"/g' -e 's/^/"/' -e 's/$/\\n"/' | ||
49 | 47 | ||
50 | echo ";" | 48 | echo ";" |
51 | echo "#endif /* _BBCONFIGOPTS_H */" | 49 | echo "#endif" |
50 | } >"$1" | ||
51 | |||
52 | { | ||
53 | echo "\ | ||
54 | #ifndef _BBCONFIGOPTS_BZ2_H | ||
55 | #define _BBCONFIGOPTS_BZ2_H | ||
56 | /* | ||
57 | * busybox configuration settings. | ||
58 | * | ||
59 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
60 | * | ||
61 | * This file is generated automatically by scripts/mkconfigs. | ||
62 | * Do not edit. | ||
63 | */ | ||
64 | static const char bbconfig_config_bz2[] ALIGN1 = {" | ||
65 | |||
66 | grep '^#\? \?CONFIG_' "$config" \ | ||
67 | | bzip2 -1 | tee z.bz2 | dd bs=2 skip=1 2>/dev/null | od -v -t x1 \ | ||
68 | | sed -e 's/^[^ ]*//' \ | ||
69 | -e 's/ //g' \ | ||
70 | -e '/^$/d' \ | ||
71 | -e 's/\(..\)/0x\1,/g' | ||
72 | |||
73 | echo "};" | ||
74 | echo "#endif" | ||
75 | } >"$2" | ||