From: Luca Boccassi Date: Thu, 27 Mar 2025 23:51:17 +0000 (+0000) Subject: meson: add feature flag for nspawn build X-Git-Tag: v258-rc1~994^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d95818f5221d9b9b19648cffa0cb2407f023b27e;p=thirdparty%2Fsystemd.git meson: add feature flag for nspawn build Other tools have it, nspawn doesn't, add one --- diff --git a/.github/workflows/unit_tests.sh b/.github/workflows/unit_tests.sh index 168bcc55c36..883f6489a1d 100755 --- a/.github/workflows/unit_tests.sh +++ b/.github/workflows/unit_tests.sh @@ -107,7 +107,7 @@ for phase in "${PHASES[@]}"; do MESON_ARGS+=(-Db_lundef=false -Dfuzz-tests=true) if [[ "$phase" == "RUN_CLANG_ASAN_UBSAN_NO_DEPS" ]]; then - MESON_ARGS+=(--auto-features=disabled) + MESON_ARGS+=(--auto-features=disabled -Dnspawn=enabled) fi fi MESON_ARGS+=(--fatal-meson-warnings) diff --git a/man/rules/meson.build b/man/rules/meson.build index 2b06442d62d..ba7b6d92238 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -1027,7 +1027,7 @@ manpages = [ 'ENABLE_NETWORKD'], ['systemd-networkd.service', '8', ['systemd-networkd'], 'ENABLE_NETWORKD'], ['systemd-notify', '1', [], ''], - ['systemd-nspawn', '1', [], ''], + ['systemd-nspawn', '1', [], 'ENABLE_NSPAWN'], ['systemd-nsresourced.service', '8', ['systemd-nsresourced'], @@ -1192,7 +1192,7 @@ manpages = [ ['systemd.net-naming-scheme', '7', [], ''], ['systemd.netdev', '5', [], 'ENABLE_NETWORKD'], ['systemd.network', '5', [], 'ENABLE_NETWORKD'], - ['systemd.nspawn', '5', [], ''], + ['systemd.nspawn', '5', [], 'ENABLE_NSPAWN'], ['systemd.offline-updates', '7', [], ''], ['systemd.path', '5', [], ''], ['systemd.pcrlock', '5', ['systemd.pcrlock.d'], ''], diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml index 1ade5483a8f..6d6fd2de11a 100644 --- a/man/systemd-nspawn.xml +++ b/man/systemd-nspawn.xml @@ -6,7 +6,7 @@ ]> - diff --git a/meson.build b/meson.build index 3ddc15473cd..38de520aaec 100644 --- a/meson.build +++ b/meson.build @@ -1610,6 +1610,9 @@ conf.set10('ENABLE_REMOTE', have) feature = get_option('vmspawn').disable_auto_if(conf.get('BUILD_MODE_DEVELOPER') == 0) conf.set10('ENABLE_VMSPAWN', feature.allowed()) +feature = get_option('nspawn') +conf.set10('ENABLE_NSPAWN', feature.allowed()) + conf.set10('DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES', get_option('default-mountfsd-trusted-directories')) foreach term : ['analyze', @@ -3046,6 +3049,7 @@ foreach tuple : [ ['machined'], ['mountfsd'], ['networkd'], + ['nspawn'], ['nsresourced'], ['nss-myhostname'], ['nss-mymachines'], diff --git a/meson_options.txt b/meson_options.txt index ee30d721bc7..1e752eeb9ef 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -178,6 +178,8 @@ option('rfkill', type : 'boolean', description : 'support for the rfkill tools') option('xdg-autostart', type : 'boolean', description : 'install the xdg-autostart-generator and unit') +option('nspawn', type : 'feature', + description : 'build and install systemd-nspawn') option('man', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, value : 'disabled', description : 'build and install man pages') diff --git a/shell-completion/bash/meson.build b/shell-completion/bash/meson.build index 2d895a10e47..362347f828f 100644 --- a/shell-completion/bash/meson.build +++ b/shell-completion/bash/meson.build @@ -28,7 +28,7 @@ items = [['busctl', ''], ['systemd-delta', ''], ['systemd-detect-virt', ''], ['systemd-id128', ''], - ['systemd-nspawn', ''], + ['systemd-nspawn', 'ENABLE_NSPAWN'], ['systemd-path', ''], ['systemd-run', ''], ['systemd-vpick', ''], diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build index 26a7e7bfb94..b995e69cb3f 100644 --- a/src/nspawn/meson.build +++ b/src/nspawn/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +if conf.get('ENABLE_NSPAWN') != 1 + subdir_done() +endif + libnspawn_core_sources = files( 'nspawn-bind-user.c', 'nspawn-cgroup.c', @@ -58,14 +62,18 @@ executables += [ }, nspawn_test_template + { 'sources' : files('test-nspawn-tables.c'), + 'conditions' : ['ENABLE_NSPAWN'], }, nspawn_test_template + { 'sources' : files('test-nspawn-util.c'), + 'conditions' : ['ENABLE_NSPAWN'], }, nspawn_fuzz_template + { 'sources' : files('fuzz-nspawn-settings.c'), + 'conditions' : ['ENABLE_NSPAWN'], }, nspawn_fuzz_template + { 'sources' : files('fuzz-nspawn-oci.c'), + 'conditions' : ['ENABLE_NSPAWN'], }, ] diff --git a/test/fuzz/meson.build b/test/fuzz/meson.build index db1dcb291c9..3f97e3fa6fb 100644 --- a/test/fuzz/meson.build +++ b/test/fuzz/meson.build @@ -60,7 +60,7 @@ sanitize_address_undefined = custom_target( 'fuzzers', ' '.join(fuzz_c_args + '-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION'), ' '.join(fuzz_cpp_args + '-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION'), - '-Dfuzz-tests=true -Db_lundef=false -Db_sanitize=address,undefined --optimization=@0@ @1@ --auto-features=@2@'.format( + '-Dfuzz-tests=true -Db_lundef=false -Db_sanitize=address,undefined -Dnspawn=enabled --optimization=@0@ @1@ --auto-features=@2@'.format( get_option('optimization'), get_option('werror') ? '--werror' : '', sanitize_auto_features diff --git a/test/units/TEST-13-NSPAWN.sh b/test/units/TEST-13-NSPAWN.sh index dd7f2746316..311b64a6a04 100755 --- a/test/units/TEST-13-NSPAWN.sh +++ b/test/units/TEST-13-NSPAWN.sh @@ -10,6 +10,11 @@ if [[ "$FSTYPE" == "fuseblk" ]]; then exit 77 fi +if ! command -v systemd-nspawn >/dev/null; then + echo "no systemd-nspawn" >/skipped + exit 77 +fi + # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh diff --git a/units/meson.build b/units/meson.build index bcb8e0cc61c..eabd1eea137 100644 --- a/units/meson.build +++ b/units/meson.build @@ -514,7 +514,10 @@ units = [ 'file' : 'systemd-networkd.socket', 'conditions' : ['ENABLE_NETWORKD'], }, - { 'file' : 'systemd-nspawn@.service.in' }, + { + 'file' : 'systemd-nspawn@.service.in', + 'conditions' : ['ENABLE_NSPAWN'], + }, { 'file' : 'systemd-vmspawn@.service.in', 'conditions' : ['ENABLE_VMSPAWN'],