summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-29 14:36:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-29 14:36:11 +0200
commit9ce07e778f05719115f354d4907f51295fb3fd1a (patch)
tree1f204121b58c0a86904e376d2fc6b08f9c3ce881
parent7715b48c36a453b41f4555ee57c2f936e25f06f1 (diff)
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--Makefile2
-rw-r--r--archival/libunarchive/Kbuild.src1
-rw-r--r--miscutils/Config.src14
-rw-r--r--miscutils/bbconfig.c22
-rwxr-xr-xscripts/mkconfigs40
5 files changed, 70 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index d13abc887..b7afaa9e7 100644
--- a/Makefile
+++ b/Makefile
@@ -842,7 +842,7 @@ export CPPFLAGS_busybox.lds += -P -C -U$(ARCH)
# Split autoconf.h into include/linux/config/*
quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h
- cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs > include/bbconfigopts.h
+ cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs include/bbconfigopts.h include/bbconfigopts_bz2.h
quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/*
cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config
#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
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
+lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += decompress_bunzip2.o
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
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
The bbconfig applet will print the config file with which
busybox was built.
+config FEATURE_COMPRESS_BBCONFIG
+ bool "Compress bbconfig data"
+ default y
+ depends on BBCONFIG
+ help
+ Store bbconfig data in compressed form, uncompress them on-the-fly
+ before output.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
config BEEP
bool "beep"
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 @@
*/
#include "libbb.h"
#include "bbconfigopts.h"
+#if ENABLE_FEATURE_COMPRESS_BBCONFIG
+# include "unarchive.h"
+# include "bbconfigopts_bz2.h"
+#endif
int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
+#if ENABLE_FEATURE_COMPRESS_BBCONFIG
+ bunzip_data *bd;
+ int i = start_bunzip(&bd,
+ /* src_fd: */ -1,
+ /* inbuf: */ (void *)bbconfig_config_bz2,
+ /* len: */ sizeof(bbconfig_config_bz2));
+ /* read_bunzip can longjmp to start_bunzip, and ultimately
+ * end up here with i != 0 on read data errors! Not trivial */
+ if (!i) {
+ /* Cannot use xmalloc: will leak bd in NOFORK case! */
+ char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
+ if (outbuf) {
+ read_bunzip(bd, outbuf, sizeof(bbconfig_config));
+ full_write1_str(outbuf);
+ }
+ }
+#else
full_write1_str(bbconfig_config);
+#endif
return 0;
}
diff --git a/scripts/mkconfigs b/scripts/mkconfigs
index 65dd44179..38d7ac054 100755
--- a/scripts/mkconfigs
+++ b/scripts/mkconfigs
@@ -26,12 +26,9 @@
# - Retain lines that begin with "# CONFIG_"
# - lines that use double-quotes must \\-escape-quote them
-config="$1"
-if [ $# -lt 1 ]
-then
- config=.config
-fi
+config=.config
+{
echo "\
#ifndef _BBCONFIGOPTS_H
#define _BBCONFIGOPTS_H
@@ -43,9 +40,36 @@ echo "\
* This file is generated automatically by scripts/mkconfigs.
* Do not edit.
*/
-static const char bbconfig_config[] ="
+static const char bbconfig_config[] ALIGN1 ="
-sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}'
+grep '^#\? \?CONFIG_' "$config" \
+| sed -e 's/\"/\\\"/g' -e 's/^/"/' -e 's/$/\\n"/'
echo ";"
-echo "#endif /* _BBCONFIGOPTS_H */"
+echo "#endif"
+} >"$1"
+
+{
+echo "\
+#ifndef _BBCONFIGOPTS_BZ2_H
+#define _BBCONFIGOPTS_BZ2_H
+/*
+ * busybox configuration settings.
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ *
+ * This file is generated automatically by scripts/mkconfigs.
+ * Do not edit.
+ */
+static const char bbconfig_config_bz2[] ALIGN1 = {"
+
+grep '^#\? \?CONFIG_' "$config" \
+| bzip2 -1 | tee z.bz2 | dd bs=2 skip=1 2>/dev/null | od -v -t x1 \
+| sed -e 's/^[^ ]*//' \
+ -e 's/ //g' \
+ -e '/^$/d' \
+ -e 's/\(..\)/0x\1,/g'
+
+echo "};"
+echo "#endif"
+} >"$2"