你如何以非交互开启功能在Linux内核的config文件? [英] How do you non-interactively turn on features in a Linux kernel .config file?

查看:244
本文介绍了你如何以非交互开启功能在Linux内核的config文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在那里我们的软件需要与几个不同的Linux内核发行/内核树工作的情况。 (包括Android叉)

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.

例如,假设我需要一个名为 XXX 在我的的.config 选项。对于一些依赖,我可以做这样的事情:

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 语句多行。

有没有更支持的方式做到这一点非交互,还是我卡住写一个更复杂的搜索和替换脚本?

Is there a more supported way to do this non-interactively, or am I stuck writing a more complex search-and-replace script?

推荐答案

是的,有些配置选项更改版本之间的名字,有时是微妙的语义变化的迹象。

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

我已经写蟒类一组配置片段合并为基本内核配置文件。这就是矫枉过正你,虽然;你可以做同样的事情作为一个sed脚本;你不局限于单行。

I have written python classes to merge together a set of configuration fragments into base kernel configuration files. That's overkill for you, though; you can do the same thing as a sed script; you aren't limited to one-liners.

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

甚至可以创建一个单独的脚本。说,config.sed包含行:

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/;

然后你可以运行

sed -ire config.sed .config

希望帮助!

这篇关于你如何以非交互开启功能在Linux内核的config文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆