Overwrite imagebuilder .config variables from commandline

I'd like to change CONFIG_TARGET_KERNEL_PARTSIZE and CONFIG_TARGET_ROOTFS_PARTSIZE from the script that automates imagebuilder. But the only way I've found is to edit .config as it doesn't work from the commandline. Is this a bug that should be reported or I'm doing something wrong?

The original tread is from 2017 and the last post is 4years later saying that only changing the conf file works.

That function isn’t a function at all in the userguide and I doubt anyone will do much effort correcting this since imagebuilder isn’t made to do these operations. You are supposed to build from source code if you want to do any advanced configs.

1 Like

the commandline to change those options is not implemented, but editing config manually or through a wrapper script is safe.

You can try opening a bug report to ask for the feature, since it's not a wrong thing to want from a tool that generates a firmware image.

I'm even ready to try to PR it, but have not found what's wrong with a quick glance into the Makefile.

There is nothing "wrong", it was never designed to do this so maybe in the past it worked by chance but then it was reworked for other reasons and it does not anymore.

If just adding it as a commandline as said by jow does not work, I think it means that the .config file is read at some point and the environment variable you defined in the command line is overwritten.

So I think it's worth to try editing the makefile here https://github.com/openwrt/openwrt/blob/master/target/imagebuilder/files/Makefile (which is what is responsible for imagebuilder console commands) should read that variable from console, store it in a variable with a different name (so it is not overwritten) and then add the
CONFIG_TARGET_KERNEL_PARTSIZE=$(VARIABLE1) CONFIG_TARGET_ROOTFS_PARTSIZE=$(VARIABLE2)
somewhere down in the blocks where it's actually calling the commands to build the image.
for example here
https://github.com/openwrt/openwrt/blob/master/target/imagebuilder/files/Makefile#L125
or here
https://github.com/openwrt/openwrt/blob/master/target/imagebuilder/files/Makefile#L183
as there is probably already past the point the .config file is read so you can overwrite the variable with your own value.

It is just a game of whack-a-mole between you with your variable defined by console and the variable read by .config file. If you manage to find the step where that is happening, you can add your override just after it to change the value.

Maybe it's not in the makefile of imagebuilder but in another makefile that is used during build process, who knows. I think it is a matter of tracing the steps that it is doing and finding where the .config file is read.

1 Like

I had the same issue, as I wanted to add docker & podman into my custom build.
I used sed to set the values as part of my script.

package="kmod-usb-net"
package="${package} nano"
package="${package} docker"
package="${package} podman"
package="${package} zlib glib2 cni cni-plugins"
package="${package} luci luci-ssl uhttpd hostapd-openssl"
package="${package} kmod-usb-net-rtl8152"
package="${package} kmod-usb-net-asix"
package="${package} kmod-usb-net-asix-ax88179"
package="${package} usbutils"
package="${package} kmod-mt76-usb"
package="${package} kmod-mt76-core"
package="${package} kmod-mt76x2u"
package="${package} kmod-mt76x02-common"
package="${package} kmod-mt76x02-usb"
package="${package} usb-modeswitch"
sed -i 's/CONFIG_TARGET_KERNEL_PARTSIZE=.*/CONFIG_TARGET_KERNEL_PARTSIZE=18/' .config
sed -i 's/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=256/' .config
make image PACKAGES="${package}" FILES="files"

yeah that's what I do as well, I just call the image builder from a script that does a sed to edit the .config.

But the OP knows this, he is trying to add the command line option to imagebuilder

1 Like