]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: add build option for install path of main config files
authorFranck Bui <fbui@suse.com>
Mon, 21 Aug 2023 10:37:00 +0000 (12:37 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Oct 2023 16:57:45 +0000 (18:57 +0200)
This allows distros to install configuration file templates in /usr/lib/systemd
for example.

Currently we install "empty" config files in /etc/systemd/. They serve two
purposes:

- The file contains commented-out values that show the default settings.
- It is easier to edit the right file if it is already there, the user doesn't
  have to type in the path correctly, and the basic file structure is already in
  place so it's easier to edit.

Things that have happened since this approach was put in place:

- We started supporting drop-ins for config files, and drop-ins are the
  recommended way to create local configuration overrides.
- We have systemd-analyze cat-config which takes care of iterating over
  all possible locations (/etc, /run, /usr, /usr/local) and figuring out
  the right file.
- Because of the first two points, systemd-analyze cat-config is much better,
  because it takes care of finding all the drop-ins and figuring out the
  precedence. Looking at files manually is still possible of course, but not
  very convenient.

The disadvantages of the current approach with "empty" files in /etc:

- We clutter up /etc so it's harder to see what the local configuration actually is.
- If a user edits the file, package updates will not override the file (e.g.
  systemd.rpm uses %config(noreplace). This means that the "documented defaults"
  will become stale over time, if the user ever edits the main config file.

Thus, I think that it's reasonable to:

- Install the main config file to /usr/lib so that it serves as reference for
  syntax and option names and default values and is properly updated on package
  upgrades.
- Recommend to users to always use drop-ins for configuration and
  systemd-analyze cat-config to view the documentation.

This setting makes this change opt-in.

Fixes #18420.

[zjs: add more text to the description]

15 files changed:
meson.build
meson_options.txt
src/core/meson.build
src/coredump/meson.build
src/home/meson.build
src/journal-remote/meson.build
src/journal/meson.build
src/login/meson.build
src/network/meson.build
src/oom/meson.build
src/pstore/meson.build
src/resolve/meson.build
src/sleep/meson.build
src/timesync/meson.build
src/udev/meson.build

index 356e1839e9178ca2b6903fe439d8f924894754ac..7f5d465783b998d405a40a3842580d6e9df359be 100644 (file)
@@ -175,6 +175,12 @@ repartdefinitionsdir = libexecdir / 'repart/definitions'
 ntpservicelistdir = prefixdir / 'lib/systemd/ntp-units.d'
 credstoredir = prefixdir / 'lib/credstore'
 
+configfiledir = get_option('configfiledir')
+if configfiledir == ''
+        configfiledir= sysconfdir
+endif
+pkgconfigfiledir = configfiledir / 'systemd'
+
 docdir = get_option('docdir')
 if docdir == ''
         docdir = datadir / 'doc/systemd'
index b8116bcedde12ec8e24a83982ecf12176e869f79..831d23e299a785240d066b18312d6cd8cc5b669c 100644 (file)
@@ -210,7 +210,9 @@ option('libcryptsetup-plugins-dir', type : 'string',
 option('docdir', type : 'string',
        description : 'documentation directory')
 option('install-sysconfdir', type : 'combo', choices : ['true', 'no-samples', 'false'], value : 'true',
-       description : 'install configuration files and directories to $sysconfdir')
+       description : 'install configuration files and directories')
+option('configfiledir', type : 'string', value : '',
+       description : 'directory for configuration files')
 
 option('fallback-hostname', type : 'string', value : 'localhost',
        description : 'the hostname used if none configured')
index 44af28a3f32df4e81b40f4c00ae8cb756697fe51..ce20b51aec136254c7bee46a1ee34cbfaa85a5e3 100644 (file)
@@ -194,8 +194,8 @@ executables += [
         },
 ]
 
-in_files = [['system.conf',                     pkgsysconfdir],
-            ['user.conf',                       pkgsysconfdir],
+in_files = [['system.conf',                     pkgconfigfiledir],
+            ['user.conf',                       pkgconfigfiledir],
             ['org.freedesktop.systemd1.policy', polkitpolicydir]]
 
 foreach item : in_files
@@ -207,7 +207,7 @@ foreach item : in_files
                 input : file + '.in',
                 output: file,
                 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
-                install : (dir == pkgsysconfdir) ? install_sysconfdir_samples : (dir != 'no'),
+                install : (dir == pkgconfigfiledir) ? install_sysconfdir_samples : (dir != 'no'),
                 install_dir : dir)
 endforeach
 
index ba313ce42e6fc58f5644288102e598853b50491a..a69974672cce4167538b6346889b2ee1038c693d 100644 (file)
@@ -44,5 +44,5 @@ executables += [
 
 if conf.get('ENABLE_COREDUMP') == 1 and install_sysconfdir_samples
         install_data('coredump.conf',
-                     install_dir : pkgsysconfdir)
+                     install_dir : pkgconfigfiledir)
 endif
index 8dcc4d41f679ae5f758f5b4fa4c02154bbc08224..b909cfdd47b92009851c2afe8410800da8218c0c 100644 (file)
@@ -135,6 +135,6 @@ if conf.get('ENABLE_HOMED') == 1
 
         if install_sysconfdir_samples
                 install_data('homed.conf',
-                             install_dir : pkgsysconfdir)
+                             install_dir : pkgconfigfiledir)
         endif
 endif
index 4251624864059018f634015421e494fb4e2a4f02..964a2517744fd91fe4ce5add3a4e319a33f0e1f7 100644 (file)
@@ -102,7 +102,7 @@ foreach tuple : in_files
                 output: file,
                 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
                 install : tuple[1],
-                install_dir : pkgsysconfdir)
+                install_dir : pkgconfigfiledir)
 endforeach
 
 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
index 4187dab6734653f369eef2300866d9ed36941f6b..36600bf2c6e17c63ba5cf823ab292deb8153c4a6 100644 (file)
@@ -163,7 +163,7 @@ executables += [
 
 if install_sysconfdir_samples
         install_data('journald.conf',
-                     install_dir : pkgsysconfdir)
+                     install_dir : pkgconfigfiledir)
 endif
 
 if get_option('create-log-dirs')
index 1ba996d51711605dc21cc5b7085c2d57964815df..6fb09b48e2a9b9e89fdc94be6defedbbf356f47d 100644 (file)
@@ -124,7 +124,7 @@ custom_target(
         output : 'logind.conf',
         command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
         install : enable_logind and install_sysconfdir_samples and pkgsysconfdir != 'no',
-        install_dir : pkgsysconfdir)
+        install_dir : pkgconfigfiledir)
 
 custom_target(
         'systemd-user',
index 2ca9eac714b3ee329bf431cc82e4ba622656f1c6..5c05eba095531dc8ba7bcaff653223ae61e2b87c 100644 (file)
@@ -261,6 +261,6 @@ if conf.get('ENABLE_NETWORKD') == 1
 
         if install_sysconfdir_samples
                 install_data('networkd.conf',
-                             install_dir : pkgsysconfdir)
+                             install_dir : pkgconfigfiledir)
         endif
 endif
index d2f4c076e31152d6d3f87655746590c4ce6ced09..690ed7ac6bc028b235fa301bb8ed8af6c8de95d8 100644 (file)
@@ -39,6 +39,6 @@ if conf.get('ENABLE_OOMD') == 1
 
         if install_sysconfdir_samples
                 install_data('oomd.conf',
-                             install_dir : pkgsysconfdir)
+                             install_dir : pkgconfigfiledir)
         endif
 endif
index 122ba2ee3ee3a13cee3d7ec3b7182adab9b57ea7..b6fda8723d552cf93df112172488d470bff6843f 100644 (file)
@@ -17,5 +17,5 @@ executables += [
 
 if conf.get('ENABLE_PSTORE') == 1 and install_sysconfdir_samples
         install_data('pstore.conf',
-                     install_dir : pkgsysconfdir)
+                     install_dir : pkgconfigfiledir)
 endif
index 2c34dc50322553c93110e0d477f52c810ad76d8c..e7867e2f85afe63b9021b47d929cf9fe76f38e9a 100644 (file)
@@ -237,4 +237,4 @@ custom_target(
         output : 'resolved.conf',
         command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
         install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
-        install_dir : pkgsysconfdir)
+        install_dir : pkgconfigfiledir)
index da44ee6dcabd6d71c1d4d8872d7a74214a2113eb..fc0037e3876cdf489baee0fccc2f9c9701d0fbef 100644 (file)
@@ -18,5 +18,5 @@ executables += [
 
 if install_sysconfdir_samples
         install_data('sleep.conf',
-                     install_dir : pkgsysconfdir)
+                     install_dir : pkgconfigfiledir)
 endif
index 27367e311e96740e87e7a2d7a9a137cc84009a84..684448097c6294f8887e96467b02ff8edf8c7a33 100644 (file)
@@ -66,7 +66,7 @@ custom_target(
         output : 'timesyncd.conf',
         command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
         install : conf.get('ENABLE_TIMESYNCD') == 1 and install_sysconfdir_samples,
-        install_dir : pkgsysconfdir)
+        install_dir : pkgconfigfiledir)
 
 if conf.get('ENABLE_TIMESYNCD') == 1
         install_data('org.freedesktop.timesync1.conf',
index cd4d1f42775fe7d26409fe259c58bfe267d6eb39..ac9a4c3ccae5fdedd63d66801c3c32ca5fbd40cb 100644 (file)
@@ -253,9 +253,9 @@ meson.add_install_script(sh, '-c', ln_s.format(bindir / 'udevadm',
 
 if install_sysconfdir_samples
         install_data('udev.conf',
-                     install_dir : sysconfdir / 'udev')
+                     install_dir : configfiledir / 'udev')
         install_data('iocost/iocost.conf',
-                     install_dir : sysconfdir / 'udev')
+                     install_dir : configfiledir / 'udev')
 endif
 
 udev_pc = custom_target(