Commit 05ff2f87 authored by Philip Withnall's avatar Philip Withnall
Browse files

gdbusprivate: Stop hard-coding path to /var/lib

This will require distributions to ensure they pass
`--localstatedir=/var` correctly to Meson, but they should be doing that
already.

See https://mesonbuild.com/Builtin-options.html#directories

 for details
about how Meson treats `localstatedir` differently from most other `dir`
variables.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <pwithnall@endlessos.org>
parent daa62a35
......@@ -2475,18 +2475,24 @@ _g_dbus_get_machine_id (GError **error)
gsize i;
gboolean non_zero = FALSE;
/* TODO: use PACKAGE_LOCALSTATEDIR ? */
if (!g_file_get_contents ("/var/lib/dbus/machine-id",
/* Copy what dbus.git does: allow the /var/lib path to be configurable at
* build time, but hard-code the system-wide machine ID path in /etc. */
const gchar *var_lib_path = LOCALSTATEDIR "/lib/dbus/machine-id";
const gchar *etc_path = "/etc/machine-id";
if (!g_file_get_contents (var_lib_path,
&ret,
NULL,
&first_error) &&
!g_file_get_contents ("/etc/machine-id",
!g_file_get_contents (etc_path,
&ret,
NULL,
NULL))
{
g_propagate_prefixed_error (error, g_steal_pointer (&first_error),
_("Unable to load /var/lib/dbus/machine-id or /etc/machine-id: "));
/* Translators: Both placeholders are file paths */
_("Unable to load %s or %s: "),
var_lib_path, etc_path);
return NULL;
}
......@@ -2510,8 +2516,9 @@ _g_dbus_get_machine_id (GError **error)
if (i != 32 || ret[i] != '\n' || ret[i + 1] != '\0' || !non_zero)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id");
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Invalid machine ID in %s or %s",
var_lib_path, etc_path);
g_free (ret);
return NULL;
}
......
......@@ -2,6 +2,7 @@ gio_c_args = [
'-DG_LOG_DOMAIN="GLib-GIO"',
'-DGIO_COMPILATION',
'-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
'-DLOCALSTATEDIR="@0@"'.format(glib_localstatedir),
]
gio_c_args += glib_hidden_visibility_args
......
......@@ -87,6 +87,12 @@ else
glib_charsetaliasdir = glib_libdir
endif
glib_localstatedir = get_option('localstatedir')
if not glib_localstatedir.startswith('/')
# See https://mesonbuild.com/Builtin-options.html#directories
glib_localstatedir = join_paths(glib_prefix, glib_localstatedir)
endif
installed_tests_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name())
installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
installed_tests_enabled = get_option('installed_tests')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment