如何以非交互方式打开 Linux 内核 .config 文件中的功能? [英] How do you non-interactively turn on features in a Linux kernel .config file?
问题描述
我遇到一种情况,我们的软件需要与多个不同的 Linux 内核发行版/内核树一起使用.(包括安卓分支)
I have a situation where our software needs to work with several different Linux kernel distributions / kernel trees. (including Android forks)
在尝试自动化我们的构建过程时,我发现我们需要支持的特定构建的一些 defconfig
文件不包含我们依赖的内核模块.
In trying to automate our build process, I am finding that some of the defconfig
files for particular builds we need to support do not include the kernel modules we depend on.
例如,让我们假设我的 .config
中需要一个名为 XXX
的选项.对于某些依赖项,我可以这样做:
For example, let's imagine I need an option called XXX
in my .config
. For some dependencies, I can do something like this:
sed -i 's/# CONFIG_XXX is not set/CONFIG_XXX=m/' .config
对于其他人来说,这并不容易,因为依赖项可能跨越多行 .config
语句.
For others, it's not so easy since the dependency may span multiple lines of .config
statements.
是否有更受支持的非交互式方式执行此操作,或者我是否一直在编写更复杂的搜索和替换脚本?
Is there a more supported way to do this non-interactively, or am I stuck writing a more complex search-and-replace script?
推荐答案
内核有一个工具 (./scripts/config) 来更改 .config 上的特定选项.下面是一个例子:
The kernel has a tool (./scripts/config) to change specific options on .config. Here is an example:
./scripts/config --set-val CONFIG_OPTION y
虽然,它不会检查 .config 文件的有效性.
Although, it doesn't check the validity of the .config file.
这篇关于如何以非交互方式打开 Linux 内核 .config 文件中的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!