anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0156-meson-allow-building-resolved-and-machined-without-n.patch

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