4

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
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • 1
    a quick question Ciro, I am trying to test a kernel module and have a config fragment for it in my kernel source subdirectory, what's an easy way to pull that in to a buildroot? – Ahmed Masud May 01 '18 at 15:49
  • @AhmedMasud Hi Ahmed, I don't understand exactly what you mean by "a config fragment in my kernel source". Is that a Linux kernel config fragment? To just add a kernel module to Buildroot, have a look at: https://stackoverflow.com/questions/40307328/how-to-add-a-linux-kernel-driver-module-as-a-buildroot-package/43874273#43874273 – Ciro Santilli OurBigBook.com May 01 '18 at 16:44
  • Hehe I figured it out. Will write a gist. Yes it was a kernel config fragment that I wanted to append to the default arch config – Ahmed Masud May 01 '18 at 16:53

3 Answers3

3

First side note: your script should run make olddefconfig before make, so that any new options are set to their default value instead of being asked for interactively.

You could simplify the script a little by doing:

cat configs/qemu_x86_64_defconfig br_config_frag > .config
make olddefconfig

You can also use the script support/kconfig/merge_config.sh from the kconfig infrastructure. However, that script internally uses make alldefconfig which currently doesn't work - you need a patch for that.

If you would like to add support for BR2_CONFIG_FRAG to the Buildroot infrastructure, feel free to send a patch to the Buildroot mailing list!

Arnout
  • 2,927
  • 16
  • 24
  • Thanks Arnout. I knew about `olddefconfig`, but what does `alldefconfig` do? Is the patch just changing those 3 lines, or are there more changes? I can't use that patchwork thing :-) – Ciro Santilli OurBigBook.com May 29 '17 at 05:58
  • alldefconfig does the same as olddefconfig, but instead of starting from an existing .config file, it starts from a config file passed in through the `KCONFIG_ALLCONFIG` environment variable. I think the main difference is that when you interrupt the process, the old `.config` doesn't get overwritten. For using patchwork: there is a "download patch" link; you can apply the downloaded patch with `patch -p1`. – Arnout May 29 '17 at 11:27
1

I asked on the IRC, and an user who seems to be Yann E. Morin, who seems to be an active developer, said it is not possible currently.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
0

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.

Jaakko
  • 4,674
  • 2
  • 26
  • 20