pengutronix / genimage

tool to generate multiple filesystem and flash images from a tree
GNU General Public License v2.0
305 stars 110 forks source link

Filesystem overlays #183

Open Harvie opened 2 years ago

Harvie commented 2 years ago

I think it would be really beneficial to allow filesystems to be overlayed.

For example, currently if you want to build ext4, you use something like this:

image rootfs2.ext4 {
  ext4 {}
  mountpoint = "/"
}

But what i actualy need for serious work is bit different. Eg. i have following directories

Then i would want to do something like this:

image generic.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
  }
}

image alice.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
    "overlay_alice"
  }
}

image bob.img {
  ext4 {}
  overlay_dirs {
    "root"
    "overlay_generic"
    "overlay_bob"
  }
}

So that i will only need to build one debootstrap chroot and then copy it to all of my ext4 images. without having to manage several copies of the chroot. Then apply/copy the overlays over it in exact order as specified in genimage.cfg, assuming that the files from later overlay will overwrite the files in former.

BTW This is probably related to #181 which points out that genimage is dogmaticaly stuck on some "root path" concept, which often does not reflect reality of embedded development very well. Project structure tends to be more complex than just having one root that contains everything. I suggest not to force such concept and leave the directory structure up to users.

michaelolbrich commented 2 years ago

Tools like mke2fs only accept one directory for root. So at some point, all those directories must be copied together. I think that's out of scope for genimage. But with #184 you could probably do it in a exec-pre command.