From c5018d9dbf763aa9d4dcad21a06a36751ca7a2d3 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 24 Oct 2026 10:39:50 +0100 Subject: [PATCH] meson: add feature flag for clonesetup clonesetup builds and installs binaries, docs, units, etc. Add a feature flag to make it easier to avoid shipping it. --- man/clonetab.xml | 3 ++- man/rules/meson.build | 9 ++++++--- man/systemd-clonesetup-generator.xml | 3 ++- man/systemd-clonesetup.xml | 3 ++- meson.build | 2 ++ meson_options.txt | 2 ++ src/clonesetup/meson.build | 4 ++++ test/units/TEST-93-CLONESETUP.sh | 7 ++++++- units/meson.build | 1 + 9 files changed, 27 insertions(+), 7 deletions(-) diff --git a/man/clonetab.xml b/man/clonetab.xml index aa202e57fa7..81a67681be1 100644 --- a/man/clonetab.xml +++ b/man/clonetab.xml @@ -5,7 +5,8 @@ - + clonetab diff --git a/man/rules/meson.build b/man/rules/meson.build index 17fccb0b7fe..fdf7aa6ce9e 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -15,7 +15,7 @@ manpages = [ ['bootup', '7', [], ''], ['busctl', '1', [], ''], ['capsule@.service', '5', [], ''], - ['clonetab', '5', [], ''], + ['clonetab', '5', [], 'ENABLE_CLONESETUP'], ['coredump.conf', '5', ['coredump.conf.d'], 'ENABLE_COREDUMP'], ['coredumpctl', '1', [], 'ENABLE_COREDUMP'], ['crypttab', '5', [], 'HAVE_LIBCRYPTSETUP'], @@ -1051,8 +1051,11 @@ manpages = [ ['systemd-cat', '1', [], ''], ['systemd-cgls', '1', [], ''], ['systemd-cgtop', '1', [], ''], - ['systemd-clonesetup-generator', '8', [], ''], - ['systemd-clonesetup', '8', ['systemd-clonesetup@.service'], ''], + ['systemd-clonesetup-generator', '8', [], 'ENABLE_CLONESETUP'], + ['systemd-clonesetup', + '8', + ['systemd-clonesetup@.service'], + 'ENABLE_CLONESETUP'], ['systemd-coredump', '8', ['systemd-coredump-register.service', diff --git a/man/systemd-clonesetup-generator.xml b/man/systemd-clonesetup-generator.xml index 28c8b5ad004..d39cba9e025 100644 --- a/man/systemd-clonesetup-generator.xml +++ b/man/systemd-clonesetup-generator.xml @@ -3,7 +3,8 @@ - + systemd-clonesetup-generator diff --git a/man/systemd-clonesetup.xml b/man/systemd-clonesetup.xml index 4f25b501692..3314a98bb2c 100644 --- a/man/systemd-clonesetup.xml +++ b/man/systemd-clonesetup.xml @@ -3,7 +3,8 @@ - + systemd-clonesetup diff --git a/meson.build b/meson.build index 03a79059434..d7a2ce9fa32 100644 --- a/meson.build +++ b/meson.build @@ -1794,6 +1794,7 @@ conf.set10('ENABLE_NSPAWN', feature.allowed()) conf.set10('DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES', get_option('default-mountfsd-trusted-directories')) conf.set10('ENABLE_BATTERY_CHECK', get_option('battery-check').allowed()) +conf.set10('ENABLE_CLONESETUP', get_option('clonesetup').allowed()) foreach tuple : [ ['analyze'], @@ -3440,6 +3441,7 @@ foreach tuple : [ ['binfmt'], ['bootloader'], ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1], + ['clonesetup'], ['coredump'], ['efi'], ['environment.d'], diff --git a/meson_options.txt b/meson_options.txt index 8980e0ca04e..6b6a122fa2c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -167,6 +167,8 @@ option('battery-check', type : 'feature', description : 'install systemd-battery-check and associated files') option('binfmt', type : 'boolean', description : 'support for custom binary formats') +option('clonesetup', type : 'feature', + description : 'install systemd-clonesetup and associated files') option('coredump', type : 'boolean', description : 'install the coredump handler') option('create-log-dirs', type : 'boolean', diff --git a/src/clonesetup/meson.build b/src/clonesetup/meson.build index 044f69b8138..9f27f3a7f5c 100644 --- a/src/clonesetup/meson.build +++ b/src/clonesetup/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +if conf.get('ENABLE_CLONESETUP') != 1 + subdir_done() +endif + systemd_clonesetup_sources = files( 'clonesetup-ioctl.c', 'clonesetup.c', diff --git a/test/units/TEST-93-CLONESETUP.sh b/test/units/TEST-93-CLONESETUP.sh index 537c40b9720..b49288e50c6 100755 --- a/test/units/TEST-93-CLONESETUP.sh +++ b/test/units/TEST-93-CLONESETUP.sh @@ -4,10 +4,15 @@ set -eux set -o pipefail set -E +CLONESETUP_BIN=/usr/lib/systemd/systemd-clonesetup +if [[ ! -x "$CLONESETUP_BIN" ]]; then + echo "systemd-clonesetup is not installed, skipping test." >/skipped + exit 77 +fi + # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh -CLONESETUP_BIN=/usr/lib/systemd/systemd-clonesetup # Test clonesetup generator and systemd-clonesetup # Disable pager usage so interactive/manual runs do not block in `less`. export SYSTEMD_PAGER=cat diff --git a/units/meson.build b/units/meson.build index 0a447c4dedd..685a2a06ac7 100644 --- a/units/meson.build +++ b/units/meson.build @@ -15,6 +15,7 @@ units = [ { 'file' : 'capsule.slice' }, { 'file' : 'clonesetup.target', + 'conditions' : ['ENABLE_CLONESETUP'], 'symlinks' : ['sysinit.target.wants/'], }, { 'file' : 'console-getty.service.in' },