Compression for bbconfig applet

Denys Vlasenko vda.linux at googlemail.com
Sun Aug 29 11:43:05 UTC 2010


On Sunday 29 August 2010 08:46, Harald Becker wrote:
>  Hi!
> 
> Looking for the best place to store the configuration files of different
> busybox installations, I take a look on the bbconfig applet. Nice idea
> to store the configuration in the binary itself, at least on machines,
> where the size doesn't that matter, but ... bbconfig stores the
> configuration data in an uncompressed string :-( ...so I did some quick
> hacking ... now the configuration could be stored compressed in
> bbconfig, using either gzip, bzip2, lzma or xz.
> 
> scripts/bbzconfig -g .config >include/bbconfigopts.h
> ( use -g for gzip, -b for bzip2, -l for lzma, -x for xz )
> 
> This creates the compressed configuration data to be included in busybox.
> 
> busybox bbconfig | scripts/bbzconfig >.config
> 
> Restores the configuration from busybox binary.
> 
> Saves me about 20k on my i686 machine.
> 
> But it's not perfect ...

Can you make it work similarly to FEATURE_COMPRESS_USAGE?

That is, make it a config option which depents on BBCONFIG,
and then conditionally include decompress_bunzip2.o
if this options is selected. See below how it is done
for FEATURE_COMPRESS_USAGE in ./archival/libunarchive/Kbuild.src:

$ grep -r FEATURE_COMPRESS_USAGE .
./libbb/appletlib.c:#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
./libbb/appletlib.c:#if ENABLE_FEATURE_COMPRESS_USAGE
./libbb/appletlib.c:#endif /* FEATURE_COMPRESS_USAGE */
./scripts/Makefile.IMA:ifdef CONFIG_FEATURE_COMPRESS_USAGE
./TEST_config_rh9:CONFIG_FEATURE_COMPRESS_USAGE=y
./archival/libunarchive/Kbuild.src:lib-$(CONFIG_FEATURE_COMPRESS_USAGE)    += decompress_bunzip2.o
./Config.in:config FEATURE_COMPRESS_USAGE
./TEST_config_nommu:CONFIG_FEATURE_COMPRESS_USAGE=y
./TEST_config_noprintf:# CONFIG_FEATURE_COMPRESS_USAGE is not set


Generation of compressed version of bbconfigopts.h
should probably be added to scripts/mkconfigs. Currently
it is used like this (see top-level Makefile):

$(srctree)/scripts/mkconfigs > include/bbconfigopts.h

By changing it so that it takes parameters
instead of spewing data to stdout:

$(srctree)/scripts/mkconfigs include/bbconfigopts.h include/bbconfigopts_compressed.h

you can generate both uncompressed and compressed versions
(see applets/usage_compressed for an example).

Then just use one or the other from bbconfig.c depending
on the selected bbconfig methd (uncompressed or compressed).

-- 
vda


More information about the busybox mailing list