I am writing a script to build several OpenWrt versions for several targets. I cannot realistically do a manual "make menuconfig" every time.
Automating "make menuconfig" appears to be neglected both in the Linux Kernel and in OpenWrt, or at least I could not find any official and comprehensive documentation about it yet.
The scripted solution I have at the moment is as follows:
Step 1) Generate a .config file like this with the following kind of content for each target:
Step 2) Expand file .config to a full configuration with "make defconfig".
Step 3) Use script "scripts/config" from the Linux kernel to set some configuration options I wish. For example:
config --set-val "CONFIG_DOWNLOAD_FOLDER" "/my/download/folder"
config --set-val "GRUB_TIMEOUT" "0"
config --enable "CONFIG_CCACHE"
Setting option CONFIG_DOWNLOAD_FOLDER could be problematic, because it actually needs option CONFIG_DEVEL=y beforehand, at least when manually doing a "make menuconfig". I actually found this requirement confusing when using the menus. Option CONFIG_DOWNLOAD_FOLDER seems to work fine without CONFIG_DEVEL=y anyway.
I then realised that OpenWrt was being built without Luci, so I tried to enable it in the same way. The trouble is, enabling this option is not so straightforward:
Symbol: PACKAGE_luci [=m]
Type : tristate
Prompt: luci................... LuCI interface with Uhttpd as Webserver (default)
-> 1. Collections
Defined at tmp/.config-package.in:62363
Selects: PACKAGE_libiwinfo-lua [=m] && PACKAGE_libpthread [=y] && PACKAGE_rpcd-mod-rrdns [=m] && PACKAGE_uhttpd [=m] && PACKAGE_luci-app-firewall [=m] && \
PACKAGE_uhttpd-mod-ubus [=m] && PACKAGE_luci-proto-ipv6 [=m] && PACKAGE_luci-app-opkg [=m] && PACKAGE_luci-theme-bootstrap [=m] && PACKAGE_libc [=y] && \
PACKAGE_librt [=y] && PACKAGE_luci-proto-ppp [=m] && PACKAGE_luci-mod-admin-full [=m] && PACKAGE_libssp [=n]
Selected by: PACKAGE_luci-ssl [=n] || PACKAGE_luci-ssl-openssl [=n] || PACKAGE_luci-app-noddos [=n]
That means that setting CONFIG_PACKAGE_luci=y actually enables many other options automaticallly, even more than the ones listed above. I guess some sort of dependency recursion is going on for such options.
I would like to programmatically simulate what the user is doing in "make menuconfig" when he clicks on the "luci" setting. All dependent options should then be automatically set in the same way.
If the option no longer exists, it should error. Script "scripts/config" from the Linux kernel is very simple and does not seem to be doing any validation at all.
I have seen that there are other ways to handle the OpenWrt configuration with commands like "make oldconfig", but I have not quite understood what they do yet. None seems a good fit for my purposes anyway.
What is the best way to achieve the automation I am looking for?
I guess that OpenWrt release build scripts must be doing this kind of automation somehow. After all, the official x86_64_Generic binary (openwrt-19.07.2-x86-64-combined-ext4.img.gz) does ship with Luci enabled, which is not the default when running "make menuconfig".
Thanks in advance,