[OpenWrt-Devel] [RFC 0/3] PoC for per-image package sets

Bjørn Mork bjorn at mork.no
Wed Apr 22 16:58:49 EDT 2020

These patches can also be found in a branch here:

Dumping this as-is for discussion.  Not sure I'm capable of, or
will have time to, finish it.  But I am hoping it is a useful
start if someone else wants to give it a try.  If not, then I
guess it isn't a useful enough feature after all.

The state of this is sort-of working for me, but definitely
not complete and working for all different build scenarios.
I have not tested IB or PER_TARGET_ROOTFS builds.  legacy-devices
haven't been updated at all and are therefore broken. etc.

To recap the use case:  I have a device where the vendor tftp
server limits the size of the initial OpenWrt image we can 
upload. An initramfs image is preferrable due to the ability to
boot from either of the dual partitions.

For this reason I wanted to build an initramfs with a limited
set of packages, without having to reduce the default device
packages for the other images.

I have noticed that this use case is not unique.  We have for
example Build/ubnt-erx-factory-image in mt7621.mk, attempting
to build an initramfs based image which will fit within
$(KERNEL_SIZE), which is a tiny 3MB.  This is obviously futile
and there is therefore no such image on downloads.openwrt.org.
You can build one yourself by carefully removing packages, but
it would be nice if we could let the buildbots produce one too.

Anyway, look at the code and see if my ideas can be used. I'll
admit that I'm no make Guru...

The first patch simplifies the current initramfs process, and
avoids copying the special initramfs /init into the shared
TARGET_DIR. It still makes a copy of the file to be able to
set the timestamp though.  I believe this patch is useful by
itself, and I don't think it breaks anything.  Not mcuh at
least :-)

The second patch tries to abuse the per-target rootfs code
for doing per-image roofs.  The default package set can be
adjusted by adding packages to an IMAGE_PACKAGES/<image>
variable.  Or more useful: Packages can be removed by
prefixing them with a '-'.  As usual, you'll need to resolve
dependencies manually if other packackes depend on the ones
you want to remove.

The third patch is the yuckiest one.  It delays the kernel
part of the initramfs building until we have some idea about
images, devices and packages.  It then uses the same 
per-image rootfs source directory scheme as input for the
kernel.  I'm not proud of how this curretly looks.  But I had
to stop here.  

Bjørn Mork (3):
  kernel-defaults: refactor initramfs build
  build: implement per-image package sets
  build: per-image package set for initramfs

 include/image.mk           | 33 ++++++++++++----
 include/kernel-build.mk    |  1 -
 include/kernel-defaults.mk | 77 ++++++++++++++------------------------
 3 files changed, 53 insertions(+), 58 deletions(-)


openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list