[libvirt] [dbus PATCH] meson: fix construction of data directories

Pavel Hrdina posted 1 patch 31 weeks ago
Failed in applying to current master (apply log)
meson.build | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)

[libvirt] [dbus PATCH] meson: fix construction of data directories

Posted by Pavel Hrdina 31 weeks ago
We need to use prefix for all directories and there is no need to check
if the user provided path starts with '/' as that is done automatically
by the join_paths() function or '/' operator.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 meson.build | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/meson.build b/meson.build
index 472e4e2..b293b8c 100644
--- a/meson.build
+++ b/meson.build
@@ -9,12 +9,30 @@ project(
     ],
 )
 
+prefix = get_option('prefix')
+datadir = prefix / get_option('datadir')
+sbindir = prefix / get_option('sbindir')
+
+opt_dirs = [
+    'dbus_interfaces',
+    'dbus_services',
+    'dbus_system_services',
+    'dbus_system_policies',
+    'polkit_rules',
+]
+
+foreach opt_dir : opt_dirs
+    value = get_option(opt_dir)
+    varname = '@0@_dir'.format(opt_dir)
+    set_variable(varname, datadir / value)
+endforeach
+
 conf = configuration_data()
 conf.set('MESON_VERSION', '0.49.0')
 conf.set('PACKAGE', meson.project_name())
 conf.set('VERSION', meson.project_version())
 conf.set('build_root', meson.build_root())
-conf.set('sbindir', get_option('sbindir'))
+conf.set('sbindir', sbindir)
 conf.set('source_root', meson.source_root())
 
 
@@ -40,24 +58,6 @@ git = run_command('test', '-d', '.git').returncode() == 0
 
 conf.set('SYSTEM_USER', get_option('system_user'))
 
-opt_dirs = [
-    'dbus_interfaces',
-    'dbus_services',
-    'dbus_system_services',
-    'dbus_system_policies',
-    'polkit_rules',
-]
-
-foreach opt_dir : opt_dirs
-    value = get_option(opt_dir)
-    varname = '@0@_dir'.format(opt_dir)
-    if opt_dir.startswith('/')
-        set_variable(varname, value)
-    else
-        set_variable(varname, join_paths(get_option('datadir'), value))
-    endif
-endforeach
-
 
 # Compile flags
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH] meson: fix construction of data directories

Posted by Andrea Bolognani 28 weeks ago
On Thu, 2019-10-24 at 15:54 +0200, Pavel Hrdina wrote:
> +prefix = get_option('prefix')
> +datadir = prefix / get_option('datadir')
> +sbindir = prefix / get_option('sbindir')
> +
> +opt_dirs = [
> +    'dbus_interfaces',
> +    'dbus_services',
> +    'dbus_system_services',
> +    'dbus_system_policies',
> +    'polkit_rules',
> +]
> +
> +foreach opt_dir : opt_dirs
> +    value = get_option(opt_dir)
> +    varname = '@0@_dir'.format(opt_dir)
> +    set_variable(varname, datadir / value)
> +endforeach

Quoting the documentation[1]:

  If any one of the individual segments is an absolute path,
  all segments before it are dropped. That means that
  join_paths('foo', '/bar') returns /bar.

Wow, that is some magic going on right there! Not sure whether I
like it, but it's not my decision to make anyway :)

The patch itself is correct, so

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>


[1] https://mesonbuild.com/Reference-manual.html#join_paths
-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list