mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-20 18:09:21 +03:00
f81b9fa166
We've long struggled with semantics for `/var`. Our stance of "/var should start out empty and be managed by the OS" is a strict one, that pushes things closer to the original systemd upstream ideal of the "OS state is in /usr". However...well, a few things. First, we had some legacy bits here which were always populating the deployment `/var`. I don't think we need that if systemd is in use, so detect if the tree has `usr/lib/tmpfiles.d`, and don't create that stuff at `ostree admin stateroot-init` time if so. Building on that then, we have the stateroot `var` starting out actually empty. When we do a deployment, if the stateroot `var` is empty, make a copy (reflink if possible of course) of the commit's `/var` into it. This matches the semantics that Docker created with volumes, and this is sufficiently simple and easy to explain that I think it's closer to the right thing to do. Crucially...it's just really handy to have some pre-existing directories in `/var` in container images, because Docker (and podman/kube/etc) don't run systemd and hence don't run `tmpfiles.d` on startup. I really hit on the fact that we need `/var/tmp` in our container images by default for example. So there's still some overlap here with e.g. `/usr/lib/tmpfiles.d/var.conf` as shipped by systemd, but that's fine - they don't actually conflict per se.
22 lines
687 B
Bash
Executable File
22 lines
687 B
Bash
Executable File
#!/bin/bash
|
|
set -xeuo pipefail
|
|
|
|
. ${KOLA_EXT_DATA}/libinsttest.sh
|
|
|
|
require_writable_sysroot
|
|
prepare_tmpdir
|
|
|
|
mkdir -p rootfs/var/testcontent
|
|
ostree commit -b testlint --no-bindings --selinux-policy-from-base --tree=ref="${host_refspec}" --consume --tree=dir=rootfs
|
|
ostree admin deploy testlint 2>err.txt
|
|
assert_not_file_has_content err.txt 'Deploying commit.*which contains content in /var/testcontent'
|
|
test '!' -d /var/testcontent
|
|
echo "ok deploy var"
|
|
|
|
ostree admin stateroot-init newstatedir
|
|
ostree admin deploy --stateroot=newstatedir testlint
|
|
ls -al /sysroot/ostree/deploy/newstatedir/var
|
|
test -d /sysroot/ostree/deploy/newstatedir/var/testcontent
|
|
|
|
echo "ok deploy var new stateroot"
|