Add concept of state overlays
authorJonathan Lebon <jonathan@jlebon.com>
Thu, 14 Dec 2023 21:46:14 +0000 (16:46 -0500)
committerJonathan Lebon <jonathan@jlebon.com>
Wed, 10 Jan 2024 04:20:41 +0000 (23:20 -0500)
commit92b1a2720234dc01edfe44b8a188ba5c754027c0
treec902458a08a615d26a5578e80f6b50d5d4d2f7ad
parent062cf603bd5499119e21628eade57b995bd55b33
Add concept of state overlays

In the OSTree model, executables go in `/usr`, state in `/var` and
configuration in `/etc`. Software that lives in `/opt` however messes
this up because it often mixes code *and* state, making it harder to
manage.

More generally, it's sometimes useful to have the OSTree commit contain
code under a certain path, but still allow that path to be writable by
software and the sysadmin at runtime (`/usr/local` is another instance).

Add the concept of state overlays. A state overlay is an overlayfs
mount whose upper directory, which contains unmanaged state, is carried
forward on top of a lower directory, containing OSTree-managed files.

In the example of `/usr/local`, OSTree commits can ship content there,
all while allowing users to e.g. add scripts in `/usr/local/bin` when
booted into that commit.

Some reconciliation logic is executed whenever the base is updated so
that newer files in the base are never shadowed by a copied up version
in the upper directory. This matches RPM semantics when upgrading
packages whose files may have been modified.

For ease of integration, this is exposed as a systemd template unit which
any downstream distro/user can enable. The instance name is the mountpath
in escaped systemd path notation (e.g.
`ostree-state-overlay@usr-local.service`).

See discussions in https://github.com/ostreedev/ostree/issues/3113 for
more details.
Makefile-boot.am
Makefile-man.am
Makefile-ostree.am
man/ostree-state-overlay@.service.xml [new file with mode: 0644]
src/boot/ostree-state-overlay@.service [new file with mode: 0644]
src/ostree/ot-admin-builtin-state-overlay.c [new file with mode: 0644]
src/ostree/ot-admin-builtins.h
src/ostree/ot-builtin-admin.c
tests/kolainst/destructive/state-overlay.sh [new file with mode: 0755]