I'm wondering if it's possible to set values that normally are set in .config
by using environment variables. For example, in .config
, I may need CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=/usr/local/go
. Is there a way to specify that outside the .config
file?
set a variable:
echo "CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=/usr/local/go" >>.config
make defconfig
Or do you mean put all or a selection from .config into variables ?
From an old script that I have written:
#!/bin/sh
eval $(awk -F= '/^[^#].*(foo|bar|ARCH_PACKAGES).*=.*/ {gsub("-","_",$1); print $1"="$2}' .config| xargs -d'\n' -n1 | sed 's/^/export /' )
arch=$CONFIG_TARGET_ARCH_PACKAGES
sdkversion=$CONFIG_SOMEVENDOR_FIRMWARE_VERSION
Explained, the awk script is read like this
- for each line not starting with #, and do contain foo, bar or ARCH_PACKAGES do:
- replaced - with _ to create variable names with allowed characters.
- prints export before the variable=value
- evals (runs the prints as a script to load everything into the environemnt).
This work satisfactory for my needs. I think you can play with foo and bar in the regex filter, perhaps you want to load everything unfiltered.