Skip to content

Commit

Permalink
build: Call 'systemd-tmpfiles --create' when installing
Browse files Browse the repository at this point in the history
It's only necessary to call 'systemd-tmpfiles --create' when building
and installing from source, and not when using a pre-built binary
downstream package, because:

  * When 'meson install' is called as part of building the package,
    that's not when the temporary files need to be created. They need
    to be created when the binary package is later downloaded and
    installed by the user.

  * Downstream tools can sometimes handle it automatically. eg., on
    Fedora, the systemd RPM installs a trigger that tells RPM to call
    'systemd-tmpfiles --create' automatically when a tmpfiles.d snippet
    is installed.

Downstream distributors set the DESTDIR environment variable when
building their packages. Therefore, it's used to detect when a
downstream package is being built.

containers#955
  • Loading branch information
debarshiray committed Jan 10, 2022
1 parent 5d61a74 commit 73a33e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ subdir('data')
subdir('doc')
subdir('profile.d')
subdir('src')

meson.add_install_script('meson_post_install.py')
10 changes: 10 additions & 0 deletions meson_post_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

import os
import subprocess

destdir = os.environ.get('DESTDIR', '')

if not destdir and not os.path.exists('/run/.containerenv'):
print('Calling systemd-tmpfiles --create ...')
subprocess.call(['systemd-tmpfiles', '--create'])
7 changes: 0 additions & 7 deletions playbooks/setup-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,3 @@
args:
chdir: '{{ zuul.project.src_dir }}'
creates: /usr/local/bin/toolbox

- name: Setup environment
become: yes
command:
cmd: systemd-tmpfiles --create
creates: /run/media
creates: /run/host

0 comments on commit 73a33e2

Please sign in to comment.