]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: add feature flag for nspawn build
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 27 Mar 2025 23:51:17 +0000 (23:51 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 28 Mar 2025 10:34:02 +0000 (10:34 +0000)
Other tools have it, nspawn doesn't, add one

.github/workflows/unit_tests.sh
man/rules/meson.build
man/systemd-nspawn.xml
meson.build
meson_options.txt
shell-completion/bash/meson.build
src/nspawn/meson.build
test/fuzz/meson.build
test/units/TEST-13-NSPAWN.sh
units/meson.build

index 168bcc55c365bbbf60c2b89345926736189373e7..883f6489a1d13251bc24344dd1d0220bbfe79468 100755 (executable)
@@ -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)
index 2b06442d62d0d881ca426e05a7964cd64c6cec76..ba7b6d922383cfb8f44f54e171aa74200cea536e 100644 (file)
@@ -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'], ''],
index 1ade5483a8fa72b6853209636622feeed5910634..6d6fd2de11ac663abeebe22ec822e841e2a2f3c6 100644 (file)
@@ -6,7 +6,7 @@
 ]>
 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
 
-<refentry id="systemd-nspawn"
+<refentry id="systemd-nspawn" conditional="ENABLE_NSPAWN"
     xmlns:xi="http://www.w3.org/2001/XInclude">
 
   <refentryinfo>
index 3ddc15473cdc0f0a127d79f1433732db4a338695..38de520aaec4fc93697b3821ff2efd65c3acab9d 100644 (file)
@@ -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'],
index ee30d721bc7f702c5e1fae224237fe62fda0ef1b..1e752eeb9ef142dbb1afd3474ba0434049d65af9 100644 (file)
@@ -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')
index 2d895a10e478cba702663d2bf685ab3e6c127a7d..362347f828f35a9cb5178ad92e7ff3670a2026e7 100644 (file)
@@ -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',       ''],
index 26a7e7bfb942cf3039acba48d368ae2b8f0360cb..b995e69cb3ff30ce0ae29477546f9e773959e747 100644 (file)
@@ -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'],
         },
 ]
index db1dcb291c9b3422f776f63bad2802a11df9671e..3f97e3fa6fbf651ad43ee77830ae09580bbb2ff5 100644 (file)
@@ -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
index dd7f2746316e8c0e96a91c87ebf5fa1fbccda8e8..311b64a6a040c4845cc44b759400f99f43777f40 100755 (executable)
@@ -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
 
index bcb8e0cc61cfcb3696615a5e6cc5b6645d6d066d..eabd1eea1373caf8a44adf0f7b38931933e3e911 100644 (file)
@@ -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'],