Use systemd-tmpfiles for var dirs when on systemd

Putting packages files in /var prevent makes new install start with an
already populated /var, which prevent taking advantage of the systemd
provided tmpfiles.d/var.conf, which notably has this line:
q /var 0755 - - -
-> on supported filesystems (currently that means btrfs), this creates
/var as a subvolume, which has the benefit of excluding it from /
snapshots.

On non-systemd system, the `meson install` behavior stays the same,
/var/lib/pacman and /var/cache/pacman/pkg are included in DESTDIR.

Signed-off-by: Max Gautier <mg@max.gautier.name>
This commit is contained in:
Max Gautier 2024-02-28 21:19:59 +01:00
parent f343db5b8e
commit 7da78a3102
No known key found for this signature in database
2 changed files with 18 additions and 3 deletions

View file

@ -445,9 +445,20 @@ install_data(
'proto/proto.install',
install_dir : join_paths(DATAROOTDIR, 'pacman'))
foreach path : [
join_paths(LOCALSTATEDIR, 'lib/pacman/'),
join_paths(LOCALSTATEDIR, 'cache/pacman/pkg/'),
systemd = dependency('systemd', required: false)
if systemd.found()
install_data('tmpfiles.conf',
rename: 'pacman.conf',
install_dir: systemd.get_variable(pkgconfig: 'tmpfilesdir'))
var_paths = []
else
var_paths = [
join_paths(LOCALSTATEDIR, 'lib/pacman/'),
join_paths(LOCALSTATEDIR, 'cache/pacman/pkg/'),
]
endif
foreach path : var_paths + [
join_paths(DATAROOTDIR, 'makepkg-template/'),
join_paths(DATAROOTDIR, 'libalpm/hooks/'),
]

4
tmpfiles.conf Normal file
View file

@ -0,0 +1,4 @@
# Setup pacman data and cache directories
d %S/pacman
d %C/pacman/pkg