]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Implement a runtime_dir option
authorSimon McVittie <smcv@collabora.com>
Fri, 24 Jun 2022 12:17:26 +0000 (13:17 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 13 Jul 2022 19:36:13 +0000 (20:36 +0100)
If the prefix is /usr, then this defaults to /run, similar to the
special cases for /var and /etc built into Meson. This is correct for
typical modern Linux distributions implementing FHS 3.0. This is
intentionally not consistent with Autotools and CMake: if distributions
are transitioning to a different way to build dbus, then that's a good
time to re-evaluate their build options.

Otherwise, this defaults to LOCALSTATEDIR/run, consistent with Autotools
and CMake.

Signed-off-by: Simon McVittie <smcv@collabora.com>
meson.build
meson_options.txt

index 469a267abb176ae44e9d3abeb587e37e5bb98851..0c21e86580aa269f22686dcbc286beb8759bff9f 100644 (file)
@@ -690,9 +690,21 @@ dbus_enable_modular_tests = (
 
 docs_dir = get_option('datadir') / 'doc' / 'dbus'
 
+# TODO: If a future Meson version gets a runstatedir option, try both.
+# https://github.com/mesonbuild/meson/issues/4141
+runstatedir = get_option('runtime_dir')
+
+if runstatedir == ''
+    if get_option('prefix') == '/usr'
+        runstatedir = '/run'
+    else
+        runstatedir = get_option('localstatedir') / 'run'
+    endif
+endif
+
 data_config.set('EXPANDED_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
 data_config.set('EXPANDED_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
-data_config.set('EXPANDED_RUNSTATEDIR',   '/' / 'run')
+data_config.set('EXPANDED_RUNSTATEDIR', get_option('prefix') / runstatedir)
 data_config.set('EXPANDED_BINDIR',  get_option('prefix') / get_option('bindir'))
 data_config.set('EXPANDED_DATADIR', get_option('prefix') / get_option('datadir'))
 
@@ -703,7 +715,7 @@ config.set_quoted('DBUS_DATADIR',get_option('prefix') / get_option('datadir'))
 data_config.set('DBUS_LIBEXECDIR', get_option('prefix') / get_option('libexecdir'))
 
 config.set_quoted('DBUS_RUNSTATEDIR',
-    get_option('localstatedir')
+    get_option('prefix') / runstatedir
 )
 config.set_quoted('DBUS_MACHINE_UUID_FILE',
     get_option('prefix') / get_option('localstatedir') / 'lib'/'dbus'/'machine-id'
@@ -747,7 +759,7 @@ config.set_quoted('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address)
 
 system_pid_file = get_option('system_pid_file')
 if system_pid_file == ''
-    system_pid_file = '/run'/'dbus'/'pid'
+    system_pid_file = get_option('prefix') / runstatedir / 'dbus'/'pid'
 endif
 data_config.set('DBUS_SYSTEM_PID_FILE', system_pid_file)
 
index ce2934537e3d840d79df2364bebc7fb7d49a2439..4babdd65f54f5d5dec1545b56c8b3b53559d05e4 100644 (file)
@@ -170,6 +170,15 @@ option(
   description: 'Make pkg-config metadata relocatable'
 )
 
+# Deliberately not named runstatedir to avoid colliding with
+# https://github.com/mesonbuild/meson/issues/4141
+option(
+  'runtime_dir',
+  type: 'string',
+  value: '',
+  description: 'Directory for transient runtime state [default: LOCALSTATEDIR/run or /run]'
+)
+
 option(
   'selinux',
   type: 'feature',