Is it possible to use config fragments with Buildroot's .config?

Viewed 2592

I'm using Buildroot as a submodule, and I want to reuse existing in-tree defconfigs with a few modification of my own.

I'd like to store just the modified options in a config fragment, just like I can do with BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES for the Linux kernel config.

Right now I'm doing something like:

cd buildroot
make BR2_EXTERNAL="$(pwd)/../mypackage" qemu_x86_64_defconfig
echo '
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"
' >> .config
make

Is there a nicer way to avoid that echo with a config fragment, just like I'm using for the Linux kernel config fragment? I'd expect something like:

make BR2_CONFIG_FRAG=br_config_frag

where br_config_frag contains the lines:

BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"

and then I'd be able to write just:

make -C buildroot BR2_CONFIG_FRAG=br_config_frag qemu_x86_64_defconfig all

Here's the full example repo.

Edit

One slight improvement is to put the "config fragment" in a separate file buildroot_config_fragment:

BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"

and then cat that:

cat ../buildroot_config_fragment >> .config
3 Answers

Arnout's make alldefconfig patch is now merged in buildroot as of 26 Jul 2017 (https://github.com/buildroot/buildroot/commit/dab80981d15979eab3aea28a33694396635a52a1).

This means you can now do:

./support/kconfig/merge_config.sh configs/qemu_x86_64_defconfig fragment1.config fragment2.config

This will use qemu_x86_64_defconfig as the base and add modifications given in the listed fragment config files. The tool will also show nice warnings if you override items.

Related