1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-31 21:18:09 +03:00

meson: add build option for install path of main config files

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]
This commit is contained in:
Franck Bui 2023-08-21 12:37:00 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent ee691c802b
commit 6495361c7d
15 changed files with 25 additions and 17 deletions

View 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'

View 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')

View 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

View 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

View 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

View 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

View 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')

View 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',

View 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

View 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

View 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

View 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)

View File

@ -18,5 +18,5 @@ executables += [
if install_sysconfdir_samples
install_data('sleep.conf',
install_dir : pkgsysconfdir)
install_dir : pkgconfigfiledir)
endif

View 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',

View 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(