non-interactive build question
Grant Edwards
grant.b.edwards at gmail.com
Wed Oct 16 16:08:35 UTC 2013
On 2013-10-16, Qais Yousef <Qais.Yousef at imgtec.com> wrote:
>> This seems to work but I would still like to try and find a way to
>> generate the .config file I want without having to run menuconfig at
>> all. I think what I would really like is something like:
>
> You'll only have to run menuconfig manually once.
>
> Once you have a good set of config files it should be easy to
> manipulate them to produce other variants you like. I can't see how
> you can avoid the first manual menuconfig step personally.
Manipulating .config files programmatically is pretty easy.
The shell script I use to build a buildroot-based system doesn't
require any use of menuconfig.
The one thing you have to remember when manipulating a .config file is
that changing a config value often has side effects. For example: when
you want to enable and configure a previously disabled subsystem, you
have to do it in stages:
1) Enable the subsystem
2) Run "make oldconfig" to make the subsystem's configuration items
appear in the .config file with default values.
3) Enable/Disable/Set the subsystem's configuration items.
Depending on how the configuration items are defined, you can end up
with this process nesting several levels deep.
To that end, here are 3 bash functions I use:
set -o nounset
set -o errexit
# low level functions used to manipulate linux kernel-style .config
# files.
function SyncConfig()
{
yes '' | $Make oldconfig >/dev/null
}
# By default, UnsetValue and SetValue will, after modifying the
# .config file, do a "make oldconfig" to re-normalize the .config
# file. Use the -n option to prevent that.
function UnsetValue()
{
dosync=y
test "$1" = '-n' && { dosync=n; shift; }
Variable="$1"
echo "UnsetValue $Variable"
sed -i "s/^${Variable}=.*/# ${Variable} is not set/g" .config
test $dosync = y && SyncConfig
return 0
}
function SetValue()
{
dosync=y
test "$1" = '-n' && { dosync=n; shift; }
Variable="$1"
# default value is 'y'
Value="${2-y}"
echo "SetValue $Variable $Value"
# if value isn't 'y', then put it in double quotes
test "$Value" != y && Value="\"$Value\""
# escape any slashes
Value=${Value//\//\\\/}
sed -i "s/^${Variable}=.*/${Variable}=${Value}/g" .config
sed -i "s/^# ${Variable} is not set.*/${Variable}=${Value}/g" .config
test $dosync = y && SyncConfig
return 0
}
Then you can make function calls like this in a build script:
TPath=/path/to/my/toolchain
SetValue BR2_TOOLCHAIN_EXTERNAL_PATH "$TPath"
--
Grant Edwards grant.b.edwards Yow! Now that I have my
at "APPLE", I comprehend COST
gmail.com ACCOUNTING!!
More information about the uClibc
mailing list