How do you not interactively include functions in the .config file of the Linux kernel?

I have a situation where our software needs to work with several different kernel distributions of the kernel kernel. (including Android forks)

When I tried to automate our build process, I found that some of the defconfig files for specific collections that we must support do not include the kernel modules on which we depend.

For example, let's say I need the XXX option in my .config . For some dependencies, I can do something like this:

 sed -i 's/# CONFIG_XXX is not set/CONFIG_XXX=m/' .config 

For others, this is not so simple, since a dependency can span multiple lines of .config statements.

Is there any more way that could be made non-interacting, or am I stuck in writing a more complex search and replace script?

+8
linux linux-kernel build
Sep 21 '11 at 18:59
source share
3 answers

Yes, some configuration parameters change names between releases, sometimes as an indication of subtle semantic changes.

I wrote python classes to combine a set of configuration fragments into base kernel configuration files. However, this is too much for you; you can do the same thing as a sed script; You are not limited to one layer.

 sed -ir 's/^(CONFIG_XXX=.*|# CONFIG_XXX is not set)/CONFIG_XXX=m/; s/^(CONFIG_FOO=.*|# CONFIG_FOO is not set)/CONFIG_FOO=m/; s/^(CONFIG_BAR=.*|# CONFIG_BAR is not set)/CONFIG_BAR=m/' .config 

Or even create a separate script. Say config.sed that contains the lines:

 s/^(CONFIG_XXX=.*|# CONFIG_XXX is not set)/CONFIG_XXX=m/; s/^(CONFIG_FOO=.*|# CONFIG_FOO is not set)/CONFIG_FOO=m/; s/^(CONFIG_BAR=.*|# CONFIG_BAR is not set)/CONFIG_BAR=m/; 

Then you can run

 sed -ire config.sed .config 

Hope this helps!

+6
Sep 21 '11 at 19:58
source share
β€” -

merge_config.sh configuration merge_config.sh

 $ cd linux $ git checkout v4.9 $ make x86_64_defconfig $ grep -E 'CONFIG_(DEBUG_INFO|GDB_SCRIPTS)[= ]' .config # CONFIG_DEBUG_INFO is not set $ # GDB_SCRIPTS depends on CONFIG_DEBUG_INFO in lib/Kconfig.debug. $ cat <<EOF >.config-fragment > CONFIG_DEBUG_INFO=y > CONFIG_GDB_SCRIPTS=y > EOF $ # Order is important here. Must be first base config, then fragment. $ ./scripts/kconfig/merge_config.sh .config .config-fragment $ grep -E 'CONFIG_(DEBUG_INFO|GDB_SCRIPTS)[= ]' .config CONFIG_DEBUG_INFO=y CONFIG_GDB_SCRIPTS=y 

The substitution process does not work, unfortunately:

 ./scripts/kconfig/merge_config.sh arch/x86/configs/x86_64_defconfig \ <( printf 'CONFIG_DEBUG_INFO=y\nCONFIG_GDB_SCRIPTS=y\n' ) 

due to: https://unix.stackexchange.com/a/164109/32558

merge_config.sh is a simple interface for the make alldefconfig .

When cross-compiling, ARCH should be exported when merge_config.sh run, for example:

 export ARCH=arm64 export CROSS_COMPILE=aarch64-linux-gnu- make defconfig ./scripts/kconfig/merge_config.sh .config .config-fragment 

The combined output file can be specified explicitly using the KCONFIG_CONFIG environment KCONFIG_CONFIG ; otherwise, it just overwrites .config :

 KCONFIG_CONFIG=some/path/.config ./scripts/kconfig/merge_config.sh .config .config-fragment 

Buildroot automates it using BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES : how to configure the Linux kernel in Buildroot?

Related: https://unix.stackexchange.com/questions/19905/how-to-non-interactively-configure-the-linux-kernel-build Moved 20 days earlier :-)

+2
Sep 11 '16 at 21:32
source share

There is a tool in the kernel (./scripts/config) for changing certain parameters in .config. Here is an example:

 ./scripts/config --set-val CONFIG_OPTION y 

Although it does not validate the .config file.

0
Jun 09 '19 at 15:28
source share



All Articles