richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ff6046
From 1a368abf7a3d72ecda504a69602b33b6869a485c Mon Sep 17 00:00:00 2001
ff6046
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ff6046
Date: Wed, 18 Jul 2018 09:25:57 +0900
ff6046
Subject: [PATCH] meson: allow building resolved and machined without nss
ff6046
 modules
ff6046
ff6046
This adds -Dnss-resolve= and -Dnss-mymachines= meson options.
ff6046
By using this option, e.g., resolved can be built without nss-resolve.
ff6046
When no nss modules are built, then test-nss is neither built.
ff6046
ff6046
Also, This changes the option name -Dmyhostname= to -Dnss-myhostname=
ff6046
for consistency to other nss related options.
ff6046
ff6046
Closes #9596.
ff6046
ff6046
(cherry picked from commit 08540a9591efe105439be81fc43d6dc65b715978)
ff6046
ff6046
Resolves: #1696224
ff6046
---
ff6046
 man/nss-myhostname.xml |  2 +-
ff6046
 man/nss-mymachines.xml |  2 +-
ff6046
 man/nss-resolve.xml    |  2 +-
ff6046
 man/rules/meson.build  |  6 +++---
ff6046
 meson.build            | 40 ++++++++++++++++++++++++++++++++++------
ff6046
 meson_options.txt      | 12 ++++++++----
ff6046
 src/test/meson.build   |  2 +-
ff6046
 src/test/test-nss.c    |  6 +++---
ff6046
 8 files changed, 52 insertions(+), 20 deletions(-)
ff6046
ff6046
diff --git a/man/nss-myhostname.xml b/man/nss-myhostname.xml
ff6046
index e1aabacad2..18a6f5f665 100644
ff6046
--- a/man/nss-myhostname.xml
ff6046
+++ b/man/nss-myhostname.xml
ff6046
@@ -6,7 +6,7 @@
ff6046
   SPDX-License-Identifier: LGPL-2.1+
ff6046
 -->
ff6046
 
ff6046
-<refentry id="nss-myhostname" conditional='ENABLE_MYHOSTNAME'>
ff6046
+<refentry id="nss-myhostname" conditional='ENABLE_NSS_MYHOSTNAME'>
ff6046
 
ff6046
   <refentryinfo>
ff6046
     <title>nss-myhostname</title>
ff6046
diff --git a/man/nss-mymachines.xml b/man/nss-mymachines.xml
ff6046
index 394a905665..d9811b24cc 100644
ff6046
--- a/man/nss-mymachines.xml
ff6046
+++ b/man/nss-mymachines.xml
ff6046
@@ -6,7 +6,7 @@
ff6046
   SPDX-License-Identifier: LGPL-2.1+
ff6046
 -->
ff6046
 
ff6046
-<refentry id="nss-mymachines" conditional='ENABLE_MACHINED'>
ff6046
+<refentry id="nss-mymachines" conditional='ENABLE_NSS_MYMACHINES'>
ff6046
 
ff6046
   <refentryinfo>
ff6046
     <title>nss-mymachines</title>
ff6046
diff --git a/man/nss-resolve.xml b/man/nss-resolve.xml
ff6046
index 588bc04976..56c8099e70 100644
ff6046
--- a/man/nss-resolve.xml
ff6046
+++ b/man/nss-resolve.xml
ff6046
@@ -6,7 +6,7 @@
ff6046
   SPDX-License-Identifier: LGPL-2.1+
ff6046
 -->
ff6046
 
ff6046
-<refentry id="nss-resolve" conditional='ENABLE_RESOLVE'>
ff6046
+<refentry id="nss-resolve" conditional='ENABLE_NSS_RESOLVE'>
ff6046
 
ff6046
   <refentryinfo>
ff6046
     <title>nss-resolve</title>
ff6046
diff --git a/man/rules/meson.build b/man/rules/meson.build
ff6046
index 9458a4012d..989d11c9b9 100644
ff6046
--- a/man/rules/meson.build
ff6046
+++ b/man/rules/meson.build
ff6046
@@ -37,9 +37,9 @@ manpages = [
ff6046
  ['modules-load.d', '5', [], 'HAVE_KMOD'],
ff6046
  ['networkctl', '1', [], 'ENABLE_NETWORKD'],
ff6046
  ['networkd.conf', '5', ['networkd.conf.d'], 'ENABLE_NETWORKD'],
ff6046
- ['nss-myhostname', '8', ['libnss_myhostname.so.2'], 'ENABLE_MYHOSTNAME'],
ff6046
- ['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_MACHINED'],
ff6046
- ['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_RESOLVE'],
ff6046
+ ['nss-myhostname', '8', ['libnss_myhostname.so.2'], 'ENABLE_NSS_MYHOSTNAME'],
ff6046
+ ['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_NSS_MYMACHINES'],
ff6046
+ ['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_NSS_RESOLVE'],
ff6046
  ['nss-systemd', '8', ['libnss_systemd.so.2'], 'ENABLE_NSS_SYSTEMD'],
ff6046
  ['os-release', '5', [], ''],
ff6046
  ['pam_systemd', '8', [], 'HAVE_PAM'],
ff6046
diff --git a/meson.build b/meson.build
ff6046
index c1013d525b..863e8eb399 100644
ff6046
--- a/meson.build
ff6046
+++ b/meson.build
ff6046
@@ -1216,7 +1216,6 @@ foreach term : ['utmp',
ff6046
                 'networkd',
ff6046
                 'timedated',
ff6046
                 'timesyncd',
ff6046
-                'myhostname',
ff6046
                 'firstboot',
ff6046
                 'randomseed',
ff6046
                 'backlight',
ff6046
@@ -1233,12 +1232,39 @@ foreach term : ['utmp',
ff6046
                 'smack',
ff6046
                 'gshadow',
ff6046
                 'idn',
ff6046
+                'nss-myhostname',
ff6046
                 'nss-systemd']
ff6046
         have = get_option(term)
ff6046
         name = 'ENABLE_' + term.underscorify().to_upper()
ff6046
         conf.set10(name, have)
ff6046
 endforeach
ff6046
 
ff6046
+foreach tuple : [['nss-mymachines', 'machined'],
ff6046
+                 ['nss-resolve',    'resolve']]
ff6046
+        want = get_option(tuple[0])
ff6046
+        if want != 'false'
ff6046
+                have = get_option(tuple[1])
ff6046
+                if want == 'true' and not have
ff6046
+                        error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
ff6046
+                endif
ff6046
+        else
ff6046
+                have = false
ff6046
+        endif
ff6046
+        name = 'ENABLE_' + tuple[0].underscorify().to_upper()
ff6046
+        conf.set10(name, have)
ff6046
+endforeach
ff6046
+
ff6046
+enable_nss = false
ff6046
+foreach term : ['ENABLE_NSS_MYHOSTNAME',
ff6046
+                'ENABLE_NSS_MYMACHINES',
ff6046
+                'ENABLE_NSS_RESOLVE',
ff6046
+                'ENABLE_NSS_SYSTEMD']
ff6046
+        if conf.get(term) == 1
ff6046
+                enable_nss = true
ff6046
+        endif
ff6046
+endforeach
ff6046
+conf.set10('ENABLE_NSS', enable_nss)
ff6046
+
ff6046
 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
ff6046
 
ff6046
 want_tests = get_option('tests')
ff6046
@@ -1417,10 +1443,10 @@ test_dlopen = executable(
ff6046
         link_with : [libbasic],
ff6046
         dependencies : [libdl])
ff6046
 
ff6046
-foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
ff6046
+foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
ff6046
                  ['systemd',    'ENABLE_NSS_SYSTEMD'],
ff6046
-                 ['mymachines', 'ENABLE_MACHINED'],
ff6046
-                 ['resolve',    'ENABLE_RESOLVE']]
ff6046
+                 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
ff6046
+                 ['resolve',    'ENABLE_NSS_RESOLVE']]
ff6046
 
ff6046
         condition = tuple[1] == '' or conf.get(tuple[1]) == 1
ff6046
         if condition
ff6046
@@ -2943,7 +2969,6 @@ foreach tuple : [
ff6046
         ['idn'],
ff6046
         ['libidn2'],
ff6046
         ['libidn'],
ff6046
-        ['nss-systemd'],
ff6046
         ['libiptc'],
ff6046
         ['elfutils'],
ff6046
         ['binfmt'],
ff6046
@@ -2978,7 +3003,10 @@ foreach tuple : [
ff6046
         ['blkid'],
ff6046
         ['dbus'],
ff6046
         ['glib'],
ff6046
-        ['nss-myhostname',   conf.get('ENABLE_MYHOSTNAME') == 1],
ff6046
+        ['nss-myhostname',   conf.get('ENABLE_NSS_MYHOSTNAME') == 1],
ff6046
+        ['nss-mymachines',   conf.get('ENABLE_NSS_MYMACHINES') == 1],
ff6046
+        ['nss-resolve',      conf.get('ENABLE_NSS_RESOLVE') == 1],
ff6046
+        ['nss-systemd',      conf.get('ENABLE_NSS_SYSTEMD') == 1],
ff6046
         ['hwdb'],
ff6046
         ['tpm'],
ff6046
         ['man pages',        want_man],
ff6046
diff --git a/meson_options.txt b/meson_options.txt
ff6046
index f06a130582..563b11f0a2 100644
ff6046
--- a/meson_options.txt
ff6046
+++ b/meson_options.txt
ff6046
@@ -91,8 +91,14 @@ option('timesyncd', type : 'boolean',
ff6046
        description : 'install the systemd-timesyncd daemon')
ff6046
 option('remote', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
        description : 'support for "journal over the network"')
ff6046
-option('myhostname', type : 'boolean',
ff6046
-       description : 'nss-myhostname support')
ff6046
+option('nss-myhostname', type : 'boolean',
ff6046
+       description : 'install nss-myhostname module')
ff6046
+option('nss-mymachines', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
+       description : 'install nss-mymachines module')
ff6046
+option('nss-resolve', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
+       description : 'install nss-resolve module')
ff6046
+option('nss-systemd', type : 'boolean',
ff6046
+       description : 'install nss-systemd module')
ff6046
 option('firstboot', type : 'boolean',
ff6046
        description : 'support for firstboot mechanism')
ff6046
 option('randomseed', type : 'boolean',
ff6046
@@ -249,8 +255,6 @@ option('libidn2', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
        description : 'libidn2 support')
ff6046
 option('libidn', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
        description : 'libidn support')
ff6046
-option('nss-systemd', type : 'boolean',
ff6046
-       description : 'enable nss-systemd')
ff6046
 option('libiptc', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
        description : 'libiptc support')
ff6046
 option('qrencode', type : 'combo', choices : ['auto', 'true', 'false'],
ff6046
diff --git a/src/test/meson.build b/src/test/meson.build
ff6046
index b982251b1f..0998f59897 100644
ff6046
--- a/src/test/meson.build
ff6046
+++ b/src/test/meson.build
ff6046
@@ -650,7 +650,7 @@ tests += [
ff6046
         [['src/test/test-nss.c'],
ff6046
          [],
ff6046
          [libdl],
ff6046
-         '', 'manual'],
ff6046
+         'ENABLE_NSS', 'manual'],
ff6046
 
ff6046
         [['src/test/test-umount.c',
ff6046
           'src/core/mount-setup.c',
ff6046
diff --git a/src/test/test-nss.c b/src/test/test-nss.c
ff6046
index 9e543e7557..e0e7bb300d 100644
ff6046
--- a/src/test/test-nss.c
ff6046
+++ b/src/test/test-nss.c
ff6046
@@ -431,13 +431,13 @@ static int parse_argv(int argc, char **argv,
ff6046
                 modules = strv_new(argv[1], NULL);
ff6046
         else
ff6046
                 modules = strv_new(
ff6046
-#if ENABLE_MYHOSTNAME
ff6046
+#if ENABLE_NSS_MYHOSTNAME
ff6046
                                 "myhostname",
ff6046
 #endif
ff6046
-#if ENABLE_RESOLVE
ff6046
+#if ENABLE_NSS_RESOLVE
ff6046
                                 "resolve",
ff6046
 #endif
ff6046
-#if ENABLE_MACHINED
ff6046
+#if ENABLE_NSS_MYMACHINES
ff6046
                                 "mymachines",
ff6046
 #endif
ff6046
                                 "dns",