mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
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 <pwithnall@endlessos.org>
This commit is contained in:
parent
daa62a35e1
commit
05ff2f877c
@ -2475,18 +2475,24 @@ _g_dbus_get_machine_id (GError **error)
|
|||||||
gsize i;
|
gsize i;
|
||||||
gboolean non_zero = FALSE;
|
gboolean non_zero = FALSE;
|
||||||
|
|
||||||
/* TODO: use PACKAGE_LOCALSTATEDIR ? */
|
/* Copy what dbus.git does: allow the /var/lib path to be configurable at
|
||||||
if (!g_file_get_contents ("/var/lib/dbus/machine-id",
|
* 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,
|
&ret,
|
||||||
NULL,
|
NULL,
|
||||||
&first_error) &&
|
&first_error) &&
|
||||||
!g_file_get_contents ("/etc/machine-id",
|
!g_file_get_contents (etc_path,
|
||||||
&ret,
|
&ret,
|
||||||
NULL,
|
NULL,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
g_propagate_prefixed_error (error, g_steal_pointer (&first_error),
|
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;
|
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)
|
if (i != 32 || ret[i] != '\n' || ret[i + 1] != '\0' || !non_zero)
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id");
|
"Invalid machine ID in %s or %s",
|
||||||
|
var_lib_path, etc_path);
|
||||||
g_free (ret);
|
g_free (ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ gio_c_args = [
|
|||||||
'-DG_LOG_DOMAIN="GLib-GIO"',
|
'-DG_LOG_DOMAIN="GLib-GIO"',
|
||||||
'-DGIO_COMPILATION',
|
'-DGIO_COMPILATION',
|
||||||
'-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
|
'-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
|
||||||
|
'-DLOCALSTATEDIR="@0@"'.format(glib_localstatedir),
|
||||||
]
|
]
|
||||||
|
|
||||||
gio_c_args += glib_hidden_visibility_args
|
gio_c_args += glib_hidden_visibility_args
|
||||||
|
@ -87,6 +87,12 @@ else
|
|||||||
glib_charsetaliasdir = glib_libdir
|
glib_charsetaliasdir = glib_libdir
|
||||||
endif
|
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_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name())
|
||||||
installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
|
installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
|
||||||
installed_tests_enabled = get_option('installed_tests')
|
installed_tests_enabled = get_option('installed_tests')
|
||||||
|
Loading…
Reference in New Issue
Block a user