Rebuilding images from the buildroot, without packaging the image generator

I'm building for multiple ar71xx devices at once, but not all can manage the same feature set (flash, RAM constraints etc.). So I'd like to repackage the images after compiling - since I only need one compile run that way, but can produce images that include different packages. That's what the image generator is for.

Now, when I look inside the image generator's tarball, all those scripts and directories in there are also present in a full buildroot, so I figured I'd try the make image PROFILE=xxx command from within the buildroot, but that fails:

$ make image PROFILE=wndr3700 PACKAGES="luci-ssl" V=s
make[1]: *** No rule to make target 'image'.  Stop.

The image generator is intended for standalone use, but it essentially replicates the final stages of the buildroot, if I'm not mistaken.

So - is there a way to repackage the images without it, in a fully functional buildroot? I suppose there is one, since the buildroot generates those images - so how can I re-run that manually?


@mkresin graciously pointed me to the CONFIG_TARGET_PER_DEVICE_ROOTFS setting in the buildroot (second entry under Target devices in the main menu). This only works, evidently, if you are already building for multiple devices.

Once you tick that, you'll see the devices you previously selected have now a submenu, where you can specify an array of additional packages.

I have few packages built-in, most are modular like LEDE's official builds:

$ grep -i package_mtr .config
$ grep -i package_luci-ssl= .config

Now, we'll specify per device which ones we want to include or exclude:


$ grep -i packages_ar71xx_generic_device_wndr3700= .config
CONFIG_TARGET_DEVICE_PACKAGES_ar71xx_generic_DEVICE_wndr3700="dmesg iperf3 kmod-usb-net-rndis luci-ssl luci-app-ddns luci-app-ntpc luci-app-sqm luci-app-statistics luci-theme-bootstrap tmux usbutils unbound unbound-anchor"

TL-WR1043ND v1

$ grep -i packages_ar71xx_generic_device_tl-wr1043nd-v1 .config
CONFIG_TARGET_DEVICE_PACKAGES_ar71xx_generic_DEVICE_tl-wr1043nd-v1="iperf3 kmod-usb-net-rndis luci -mtr usbutils"

I have not experimented yet to see if excluding packages also excludes the dependencies they have; however, I presume not since the buildroot doesn't do that either (e.g. disabling LuCi in your configuration won't disable uhttpd etc.).

And the results:


root@lede:~# opkg list-installed|grep luci-ssl
luci-ssl - git-16.306.57050-d7d9772-1

TL-WR1043ND v1

root@lede:~# opkg list-installed|grep mtr

As this magic feature promised, it adds extra packages to your WNDR3700 image, and removes the mtr package from my TL-WR1043ND v1 image.

Thanks to @neoraider for implementing this awesome feature!


As a follow-up, I have tested whether removing packages also removes their dependencies; it does not. You need to add those to the list manually. So it makes sense to keep your default setup as lean as possible, and add packages on a per-device basis rather than remove. E.g. for my TL-WR841N v7 build I'm down to this:

CONFIG_TARGET_DEVICE_PACKAGES_ar71xx_generic_DEVICE_tl-wr841-v7="-ca-certificates -dmesg -kmod-ppp -kmod-ppp-pppoe -kmod-ppp-pppox -kmod-usb-core -kmod-usb-ledtrig-usbport -kmod-usb-net -kmod-usb-net-cdc-ether -kmod-usb-net-rndis -kmod-usb-ohci -kmod-usb2 -libncursesw -mtr -ppp-mod-pppoe -ppp -terminfo