toolbox/meson.build

78 lines
2 KiB
Meson
Raw Normal View History

project(
'toolbox',
'c',
2021-12-10 02:28:35 +00:00
version: '0.0.99.3',
license: 'ASL 2.0',
meson_version: '>= 0.58.0',
)
build: Call 'systemd-tmpfiles --create' when installing It's only necessary to call 'systemd-tmpfiles --create' when building and installing from source on the host operating system. It's not needed 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. It's also not needed when installing inside a toolbox container because the files that 'systemd-tmpfiles --create' is supposed to create are meant to be on the host. Downstream distributors set the DESTDIR environment variable when building their packages. Therefore, it's used to detect when a downstream package is being built. Unfortunately, environment variables are messy and, generally, Meson doesn't support accessing them inside its scripts [1]. Therefore, this adds a spurious build-time dependency on systemd for downstream distributors. However, that's probably not a big problem because all supported downstream operating systems are already expected to use systemd for the tmpfiles.d(5) snippets to work. [1] https://github.com/mesonbuild/meson/issues/9 https://github.com/containers/toolbox/issues/955
2021-12-17 16:45:43 +00:00
fs = import('fs')
cc = meson.get_compiler('c')
if not cc.has_argument('-print-file-name=libc.so')
error('C compiler does not support the -print-file-name argument.')
endif
go = find_program('go')
go_md2man = find_program('go-md2man')
shellcheck = find_program('shellcheck', required: false)
skopeo = find_program('skopeo', required: false)
bash_completion_dep = dependency('bash-completion', required: false)
fish_dep = dependency('fish', required: false)
migration_path_for_coreos_toolbox = get_option('migration_path_for_coreos_toolbox')
profiledir = get_option('profile_dir')
tmpfilesdir = get_option('tmpfiles_dir')
build: Call 'systemd-tmpfiles --create' when installing It's only necessary to call 'systemd-tmpfiles --create' when building and installing from source on the host operating system. It's not needed 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. It's also not needed when installing inside a toolbox container because the files that 'systemd-tmpfiles --create' is supposed to create are meant to be on the host. Downstream distributors set the DESTDIR environment variable when building their packages. Therefore, it's used to detect when a downstream package is being built. Unfortunately, environment variables are messy and, generally, Meson doesn't support accessing them inside its scripts [1]. Therefore, this adds a spurious build-time dependency on systemd for downstream distributors. However, that's probably not a big problem because all supported downstream operating systems are already expected to use systemd for the tmpfiles.d(5) snippets to work. [1] https://github.com/mesonbuild/meson/issues/9 https://github.com/containers/toolbox/issues/955
2021-12-17 16:45:43 +00:00
if tmpfilesdir == '' or not fs.exists('/run/.containerenv')
systemd_dep = dependency('systemd')
build: Call 'systemd-tmpfiles --create' when installing It's only necessary to call 'systemd-tmpfiles --create' when building and installing from source on the host operating system. It's not needed 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. It's also not needed when installing inside a toolbox container because the files that 'systemd-tmpfiles --create' is supposed to create are meant to be on the host. Downstream distributors set the DESTDIR environment variable when building their packages. Therefore, it's used to detect when a downstream package is being built. Unfortunately, environment variables are messy and, generally, Meson doesn't support accessing them inside its scripts [1]. Therefore, this adds a spurious build-time dependency on systemd for downstream distributors. However, that's probably not a big problem because all supported downstream operating systems are already expected to use systemd for the tmpfiles.d(5) snippets to work. [1] https://github.com/mesonbuild/meson/issues/9 https://github.com/containers/toolbox/issues/955
2021-12-17 16:45:43 +00:00
if tmpfilesdir == ''
tmpfilesdir = systemd_dep.get_variable(pkgconfig: 'tmpfilesdir')
endif
endif
Give access to removable devices and other temporary mounts Currently, when udisks is configured to use /run/media instead of /media, on most operating systems, the /run/media directory is created by udisks itself when the first mount is handled [1]. This causes problems when creating the toolbox container, if nothing has been mounted after the current boot, because a missing directory cannot be bind mounted. Fedora Silverblue is a significant exception to the above, where rpm-ostree takes care of creating /run/media with systemd-tmpfiles [2] during boot. The correct long-term solution is to get udisks to create /run/media during boot with systemd-tmpfiles by installing a snippet in tmpfiles.d [3, 4]. Until that happens, and is widely deployed, the toolbox needs to provide the snippet itself to make things work on the majority of operating systems. Note that, in case udisks is configured to use /media instead of /run/media, then this will create an unused /run/media directory. This is probably fine because /run/media is the default setting for udisks. Moreover, an unused directory is way better than not being able to access mount points from a toolbox container or having 'podman create' fail due to a missing directory. Based on 4a2a15f2eb3a6b810fcf9b699272fcc9a7871c6e and as suggested by Daniel J Walsh. [1] UDisks commit aa02e5fc53efdeaf https://github.com/storaged-project/udisks/commit/aa02e5fc53efdeaf [2] rpm-ostree commit 958dfa435e4e4a3e https://github.com/projectatomic/rpm-ostree/commit/958dfa435e4e4a3e [3] https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html [4] https://github.com/storaged-project/udisks/pull/641 https://github.com/debarshiray/toolbox/issues/3
2019-03-12 17:45:19 +00:00
toolbox_sh = files('toolbox')
if shellcheck.found()
test('shellcheck toolbox (deprecated)', shellcheck, args: [toolbox_sh])
endif
if not skopeo.found()
message('Running system tests requires Skopeo for OCI image manipulation.')
endif
install_subdir(
'test',
install_dir: join_paths(get_option('datadir'), meson.project_name()),
exclude_files: [
'system/libs/bats-assert/.git',
'system/libs/bats-assert/.gitignore',
'system/libs/bats-assert/.travis.yml',
'system/libs/bats-assert/package.json',
'system/libs/bats-support/.git',
'system/libs/bats-support/.gitignore',
'system/libs/bats-support/.travis.yml',
'system/libs/bats-support/package.json'
],
exclude_directories: [
'system/libs/bats-assert/.git',
'system/libs/bats-assert/script',
'system/libs/bats-assert/test',
'system/libs/bats-support/.git',
'system/libs/bats-support/script',
'system/libs/bats-support/test'
]
)
Give access to removable devices and other temporary mounts Currently, when udisks is configured to use /run/media instead of /media, on most operating systems, the /run/media directory is created by udisks itself when the first mount is handled [1]. This causes problems when creating the toolbox container, if nothing has been mounted after the current boot, because a missing directory cannot be bind mounted. Fedora Silverblue is a significant exception to the above, where rpm-ostree takes care of creating /run/media with systemd-tmpfiles [2] during boot. The correct long-term solution is to get udisks to create /run/media during boot with systemd-tmpfiles by installing a snippet in tmpfiles.d [3, 4]. Until that happens, and is widely deployed, the toolbox needs to provide the snippet itself to make things work on the majority of operating systems. Note that, in case udisks is configured to use /media instead of /run/media, then this will create an unused /run/media directory. This is probably fine because /run/media is the default setting for udisks. Moreover, an unused directory is way better than not being able to access mount points from a toolbox container or having 'podman create' fail due to a missing directory. Based on 4a2a15f2eb3a6b810fcf9b699272fcc9a7871c6e and as suggested by Daniel J Walsh. [1] UDisks commit aa02e5fc53efdeaf https://github.com/storaged-project/udisks/commit/aa02e5fc53efdeaf [2] rpm-ostree commit 958dfa435e4e4a3e https://github.com/projectatomic/rpm-ostree/commit/958dfa435e4e4a3e [3] https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html [4] https://github.com/storaged-project/udisks/pull/641 https://github.com/debarshiray/toolbox/issues/3
2019-03-12 17:45:19 +00:00
subdir('data')
subdir('doc')
subdir('profile.d')
subdir('src')
if get_option('install_completions')
subdir('completion')
endif
build: Call 'systemd-tmpfiles --create' when installing It's only necessary to call 'systemd-tmpfiles --create' when building and installing from source on the host operating system. It's not needed 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. It's also not needed when installing inside a toolbox container because the files that 'systemd-tmpfiles --create' is supposed to create are meant to be on the host. Downstream distributors set the DESTDIR environment variable when building their packages. Therefore, it's used to detect when a downstream package is being built. Unfortunately, environment variables are messy and, generally, Meson doesn't support accessing them inside its scripts [1]. Therefore, this adds a spurious build-time dependency on systemd for downstream distributors. However, that's probably not a big problem because all supported downstream operating systems are already expected to use systemd for the tmpfiles.d(5) snippets to work. [1] https://github.com/mesonbuild/meson/issues/9 https://github.com/containers/toolbox/issues/955
2021-12-17 16:45:43 +00:00
meson.add_install_script('meson_post_install.py')