[libvirt PATCH 222/351] meson: src: add support for installing libvirt conf and augeas files

Pavel Hrdina posted 351 patches 5 years, 6 months ago
There is a newer version of this series
[libvirt PATCH 222/351] meson: src: add support for installing libvirt conf and augeas files
Posted by Pavel Hrdina 5 years, 6 months ago
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/Makefile.am        |   5 --
 src/meson.build        | 103 +++++++++++++++++++++++++++++++++++++++++
 src/remote/meson.build |  26 +++++++++++
 3 files changed, 129 insertions(+), 5 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 99bb71e6a03..471ebae2b79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,13 +69,8 @@ include storage/Makefile.inc.am
 include remote/Makefile.inc.am
 
 
-confdir = $(sysconfdir)/libvirt
 conf_DATA += libvirt.conf
 
-augeasdir = $(datadir)/augeas/lenses
-
-augeastestdir = $(datadir)/augeas/lenses/tests
-
 # .libs/libvirt.so is built by libtool as a side-effect of the Makefile
 # rule for libvirt.la.  However, checking symbols relies on Linux ELF layout
 if WITH_LINUX
diff --git a/src/meson.build b/src/meson.build
index bb970f10c61..3a44cd9d663 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -149,6 +149,32 @@ virt_daemons = []
 #   * install_dir - installation directory (optional, libexecdir)
 virt_helpers = []
 
+# virt_conf_files:
+#   libvirt conf files
+virt_conf_files = []
+
+# virt_aug_files:
+#   libvirt aug files
+virt_aug_files = []
+
+# virt_test_aug_files:
+#   generate libvirt augeas test files
+#   * name - augeas test file name (required)
+#   * aug - augeas test file source (required)
+#   * conf - conf file (required)
+virt_test_aug_files = []
+
+# virt_daemon_confs:
+#   generation libvirt daemon conf files
+#   each entry is a dictionary with following items:
+#   * name - daemon name (required)
+#   * name_uc - daemon name with first letter uppercase (required)
+#   * with_ip - only for libvirtd and virtproxyd (optional, default false)
+virt_daemon_confs = []
+
+virt_aug_dir = datadir / 'augeas' / 'lenses'
+virt_test_aug_dir = datadir / 'augeas' / 'lenses' / 'tests'
+
 
 # list subdirectories
 
@@ -547,3 +573,80 @@ foreach helper : virt_helpers
     install_rpath: libdir,
   )
 endforeach
+
+
+# Generate daemon config, augeas and augeas test files
+
+install_data(virt_conf_files, install_dir: confdir)
+install_data(virt_aug_files, install_dir: virt_aug_dir)
+
+foreach data : virt_test_aug_files
+  custom_target(
+    data['name'],
+    input: [ data['conf'], data['aug'] ],
+    output: data['name'],
+    command: [ meson_python_prog, augeas_gentest_prog, '@INPUT@' ],
+    capture: true,
+    install: true,
+    install_dir: virt_test_aug_dir,
+  )
+endforeach
+
+foreach data : virt_daemon_confs
+  daemon_conf = configuration_data()
+  daemon_conf.set('runstatedir', runstatedir)
+  daemon_conf.set('sbindir', sbindir)
+  daemon_conf.set('sysconfdir', sysconfdir)
+  daemon_conf.set('DAEMON_NAME', data['name'])
+  daemon_conf.set('DAEMON_NAME_UC', data['name_uc'])
+  # to silence meson warning about missing 'CONFIG' in the configuration_data
+  daemon_conf.set('CONFIG', '@CONFIG@')
+
+  if data.get('with_ip', false)
+    conf_in = libvirtd_conf_tmp
+  else
+    conf_in = virtd_conf_tmp
+  endif
+  conf_out = configure_file(
+    input: conf_in,
+    output: '@0@.conf'.format(data['name']),
+    configuration: daemon_conf,
+    install: true,
+    install_dir: confdir,
+  )
+
+  if data.get('with_ip', false)
+    aug_in = libvirtd_aug_tmp
+  else
+    aug_in = virtd_aug_tmp
+  endif
+  configure_file(
+    input: aug_in,
+    output: '@0@.aug'.format(data['name']),
+    configuration: daemon_conf,
+    install: true,
+    install_dir: virt_aug_dir,
+  )
+
+  if data.get('with_ip', false)
+    test_aug_in = test_libvirtd_aug_tmp
+  else
+    test_aug_in = test_virtd_aug_tmp
+  endif
+  test_aug_tmp = configure_file(
+    input: test_aug_in,
+    output: 'test_@0@.aug.tmp'.format(data['name']),
+    configuration: daemon_conf,
+  )
+
+  test_aug_out = 'test_@0@.aug'.format(data['name'])
+  custom_target(
+    test_aug_out,
+    input: [ conf_out, test_aug_tmp ],
+    output: test_aug_out,
+    command: [ meson_python_prog, augeas_gentest_prog, '@INPUT@' ],
+    capture: true,
+    install: true,
+    install_dir: virt_test_aug_dir,
+  )
+endforeach
diff --git a/src/remote/meson.build b/src/remote/meson.build
index ee38364868e..6635bcd4cff 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -63,6 +63,32 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
   )
 endforeach
 
+libvirt_conf_files = [
+  [ 'libvirtd.conf.in', 'libvirtd.conf.tmp', 'virtd.conf.tmp' ],
+  [ 'libvirtd.aug.in', 'libvirtd.aug.tmp', 'virtd.aug.tmp' ],
+  [ 'test_libvirtd.aug.in', 'test_libvirtd.aug.tmp', 'test_virtd.aug.tmp' ],
+]
+
+foreach name : libvirt_conf_files
+  tmp = configure_file(
+    input: name[0],
+    output: name[1],
+    command: [ 'sed', '-e', '/[@]CUT_ENABLE_IP[@]/d', '-e', '/[@]END[@]/d', '@INPUT@' ],
+    capture: true,
+  )
+  set_variable(name[1].underscorify(), tmp)
+endforeach
+
+foreach name : libvirt_conf_files
+  tmp = configure_file(
+    input: name[0],
+    output: name[2],
+    command: [ 'sed', '-e', '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d', '@INPUT@' ],
+    capture: true,
+  )
+  set_variable(name[2].underscorify(), tmp)
+endforeach
+
 if conf.has('WITH_REMOTE')
   remote_driver_lib = static_library(
     'virt_remote_driver',
-- 
2.26.2

Re: [libvirt PATCH 222/351] meson: src: add support for installing libvirt conf and augeas files
Posted by Peter Krempa 5 years, 6 months ago
On Thu, Jul 16, 2020 at 11:57:38 +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/Makefile.am        |   5 --
>  src/meson.build        | 103 +++++++++++++++++++++++++++++++++++++++++
>  src/remote/meson.build |  26 +++++++++++
>  3 files changed, 129 insertions(+), 5 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 99bb71e6a03..471ebae2b79 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -69,13 +69,8 @@ include storage/Makefile.inc.am
>  include remote/Makefile.inc.am
>  
>  
> -confdir = $(sysconfdir)/libvirt
>  conf_DATA += libvirt.conf
>  
> -augeasdir = $(datadir)/augeas/lenses
> -
> -augeastestdir = $(datadir)/augeas/lenses/tests
> -
>  # .libs/libvirt.so is built by libtool as a side-effect of the Makefile
>  # rule for libvirt.la.  However, checking symbols relies on Linux ELF layout
>  if WITH_LINUX
> diff --git a/src/meson.build b/src/meson.build
> index bb970f10c61..3a44cd9d663 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -149,6 +149,32 @@ virt_daemons = []
>  #   * install_dir - installation directory (optional, libexecdir)
>  virt_helpers = []
>  
> +# virt_conf_files:
> +#   libvirt conf files
> +virt_conf_files = []
> +
> +# virt_aug_files:
> +#   libvirt aug files
> +virt_aug_files = []
> +
> +# virt_test_aug_files:
> +#   generate libvirt augeas test files
> +#   * name - augeas test file name (required)
> +#   * aug - augeas test file source (required)
> +#   * conf - conf file (required)
> +virt_test_aug_files = []
> +
> +# virt_daemon_confs:
> +#   generation libvirt daemon conf files
> +#   each entry is a dictionary with following items:
> +#   * name - daemon name (required)
> +#   * name_uc - daemon name with first letter uppercase (required)

I've seen that you called some magic inline python to calculate stuff
somewhere else.

Can't we do it here too?

> +#   * with_ip - only for libvirtd and virtproxyd (optional, default false)
> +virt_daemon_confs = []
> +
> +virt_aug_dir = datadir / 'augeas' / 'lenses'
> +virt_test_aug_dir = datadir / 'augeas' / 'lenses' / 'tests'
> +
>  
>  # list subdirectories
>  
> @@ -547,3 +573,80 @@ foreach helper : virt_helpers
>      install_rpath: libdir,
>    )
>  endforeach
> +
> +
> +# Generate daemon config, augeas and augeas test files
> +
> +install_data(virt_conf_files, install_dir: confdir)
> +install_data(virt_aug_files, install_dir: virt_aug_dir)
> +
> +foreach data : virt_test_aug_files
> +  custom_target(
> +    data['name'],
> +    input: [ data['conf'], data['aug'] ],
> +    output: data['name'],
> +    command: [ meson_python_prog, augeas_gentest_prog, '@INPUT@' ],
> +    capture: true,
> +    install: true,

Why do we install test files?

> +    install_dir: virt_test_aug_dir,
> +  )
> +endforeach
> +

[...]

> diff --git a/src/remote/meson.build b/src/remote/meson.build
> index ee38364868e..6635bcd4cff 100644
> --- a/src/remote/meson.build
> +++ b/src/remote/meson.build
> @@ -63,6 +63,32 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
>    )
>  endforeach
>  
> +libvirt_conf_files = [
> +  [ 'libvirtd.conf.in', 'libvirtd.conf.tmp', 'virtd.conf.tmp' ],
> +  [ 'libvirtd.aug.in', 'libvirtd.aug.tmp', 'virtd.aug.tmp' ],
> +  [ 'test_libvirtd.aug.in', 'test_libvirtd.aug.tmp', 'test_virtd.aug.tmp' ],
> +]
> +
> +foreach name : libvirt_conf_files
> +  tmp = configure_file(
> +    input: name[0],
> +    output: name[1],

Please at least document the fields in the above list, but preferably
use a dict.

> +    command: [ 'sed', '-e', '/[@]CUT_ENABLE_IP[@]/d', '-e', '/[@]END[@]/d', '@INPUT@' ],
> +    capture: true,
> +  )
> +  set_variable(name[1].underscorify(), tmp)
> +endforeach

Re: [libvirt PATCH 222/351] meson: src: add support for installing libvirt conf and augeas files
Posted by Pavel Hrdina 5 years, 6 months ago
On Mon, Jul 27, 2020 at 04:56:41PM +0200, Peter Krempa wrote:
> On Thu, Jul 16, 2020 at 11:57:38 +0200, Pavel Hrdina wrote:
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  src/Makefile.am        |   5 --
> >  src/meson.build        | 103 +++++++++++++++++++++++++++++++++++++++++
> >  src/remote/meson.build |  26 +++++++++++
> >  3 files changed, 129 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index 99bb71e6a03..471ebae2b79 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -69,13 +69,8 @@ include storage/Makefile.inc.am
> >  include remote/Makefile.inc.am
> >  
> >  
> > -confdir = $(sysconfdir)/libvirt
> >  conf_DATA += libvirt.conf
> >  
> > -augeasdir = $(datadir)/augeas/lenses
> > -
> > -augeastestdir = $(datadir)/augeas/lenses/tests
> > -
> >  # .libs/libvirt.so is built by libtool as a side-effect of the Makefile
> >  # rule for libvirt.la.  However, checking symbols relies on Linux ELF layout
> >  if WITH_LINUX
> > diff --git a/src/meson.build b/src/meson.build
> > index bb970f10c61..3a44cd9d663 100644
> > --- a/src/meson.build
> > +++ b/src/meson.build
> > @@ -149,6 +149,32 @@ virt_daemons = []
> >  #   * install_dir - installation directory (optional, libexecdir)
> >  virt_helpers = []
> >  
> > +# virt_conf_files:
> > +#   libvirt conf files
> > +virt_conf_files = []
> > +
> > +# virt_aug_files:
> > +#   libvirt aug files
> > +virt_aug_files = []
> > +
> > +# virt_test_aug_files:
> > +#   generate libvirt augeas test files
> > +#   * name - augeas test file name (required)
> > +#   * aug - augeas test file source (required)
> > +#   * conf - conf file (required)
> > +virt_test_aug_files = []
> > +
> > +# virt_daemon_confs:
> > +#   generation libvirt daemon conf files
> > +#   each entry is a dictionary with following items:
> > +#   * name - daemon name (required)
> > +#   * name_uc - daemon name with first letter uppercase (required)
> 
> I've seen that you called some magic inline python to calculate stuff
> somewhere else.
> 
> Can't we do it here too?

Sure we can, I was just following what we have with autotools where we
have both strings as well. I figured that calling

name_uc = run_command(python3_prog, '-c', 'print("{0}".capitalize())'.format(data['name'])).stdout().strip()

would a bit overkill for this.

> > +#   * with_ip - only for libvirtd and virtproxyd (optional, default false)
> > +virt_daemon_confs = []
> > +
> > +virt_aug_dir = datadir / 'augeas' / 'lenses'
> > +virt_test_aug_dir = datadir / 'augeas' / 'lenses' / 'tests'
> > +
> >  
> >  # list subdirectories
> >  
> > @@ -547,3 +573,80 @@ foreach helper : virt_helpers
> >      install_rpath: libdir,
> >    )
> >  endforeach
> > +
> > +
> > +# Generate daemon config, augeas and augeas test files
> > +
> > +install_data(virt_conf_files, install_dir: confdir)
> > +install_data(virt_aug_files, install_dir: virt_aug_dir)
> > +
> > +foreach data : virt_test_aug_files
> > +  custom_target(
> > +    data['name'],
> > +    input: [ data['conf'], data['aug'] ],
> > +    output: data['name'],
> > +    command: [ meson_python_prog, augeas_gentest_prog, '@INPUT@' ],
> > +    capture: true,
> > +    install: true,
> 
> Why do we install test files?

No idea :) but with autotools we install them as well. If we want to
change it I would do it as followup patch once this is merged.

> 
> > +    install_dir: virt_test_aug_dir,
> > +  )
> > +endforeach
> > +
> 
> [...]
> 
> > diff --git a/src/remote/meson.build b/src/remote/meson.build
> > index ee38364868e..6635bcd4cff 100644
> > --- a/src/remote/meson.build
> > +++ b/src/remote/meson.build
> > @@ -63,6 +63,32 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
> >    )
> >  endforeach
> >  
> > +libvirt_conf_files = [
> > +  [ 'libvirtd.conf.in', 'libvirtd.conf.tmp', 'virtd.conf.tmp' ],
> > +  [ 'libvirtd.aug.in', 'libvirtd.aug.tmp', 'virtd.aug.tmp' ],
> > +  [ 'test_libvirtd.aug.in', 'test_libvirtd.aug.tmp', 'test_virtd.aug.tmp' ],
> > +]
> > +
> > +foreach name : libvirt_conf_files
> > +  tmp = configure_file(
> > +    input: name[0],
> > +    output: name[1],
> 
> Please at least document the fields in the above list, but preferably
> use a dict.

Good point, I'll change it into dictionary.

Thanks

Pavel
Re: [libvirt PATCH 222/351] meson: src: add support for installing libvirt conf and augeas files
Posted by Peter Krempa 5 years, 6 months ago
On Tue, Jul 28, 2020 at 09:24:13 +0200, Pavel Hrdina wrote:
> On Mon, Jul 27, 2020 at 04:56:41PM +0200, Peter Krempa wrote:
> > On Thu, Jul 16, 2020 at 11:57:38 +0200, Pavel Hrdina wrote:
> > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > > ---
> > >  src/Makefile.am        |   5 --
> > >  src/meson.build        | 103 +++++++++++++++++++++++++++++++++++++++++
> > >  src/remote/meson.build |  26 +++++++++++
> > >  3 files changed, 129 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/src/Makefile.am b/src/Makefile.am
> > > index 99bb71e6a03..471ebae2b79 100644
> > > --- a/src/Makefile.am
> > > +++ b/src/Makefile.am
> > > @@ -69,13 +69,8 @@ include storage/Makefile.inc.am
> > >  include remote/Makefile.inc.am
> > >  
> > >  
> > > -confdir = $(sysconfdir)/libvirt
> > >  conf_DATA += libvirt.conf
> > >  
> > > -augeasdir = $(datadir)/augeas/lenses
> > > -
> > > -augeastestdir = $(datadir)/augeas/lenses/tests
> > > -
> > >  # .libs/libvirt.so is built by libtool as a side-effect of the Makefile
> > >  # rule for libvirt.la.  However, checking symbols relies on Linux ELF layout
> > >  if WITH_LINUX
> > > diff --git a/src/meson.build b/src/meson.build
> > > index bb970f10c61..3a44cd9d663 100644
> > > --- a/src/meson.build
> > > +++ b/src/meson.build
> > > @@ -149,6 +149,32 @@ virt_daemons = []
> > >  #   * install_dir - installation directory (optional, libexecdir)
> > >  virt_helpers = []
> > >  
> > > +# virt_conf_files:
> > > +#   libvirt conf files
> > > +virt_conf_files = []
> > > +
> > > +# virt_aug_files:
> > > +#   libvirt aug files
> > > +virt_aug_files = []
> > > +
> > > +# virt_test_aug_files:
> > > +#   generate libvirt augeas test files
> > > +#   * name - augeas test file name (required)
> > > +#   * aug - augeas test file source (required)
> > > +#   * conf - conf file (required)
> > > +virt_test_aug_files = []
> > > +
> > > +# virt_daemon_confs:
> > > +#   generation libvirt daemon conf files
> > > +#   each entry is a dictionary with following items:
> > > +#   * name - daemon name (required)
> > > +#   * name_uc - daemon name with first letter uppercase (required)
> > 
> > I've seen that you called some magic inline python to calculate stuff
> > somewhere else.
> > 
> > Can't we do it here too?
> 
> Sure we can, I was just following what we have with autotools where we
> have both strings as well. I figured that calling
> 
> name_uc = run_command(python3_prog, '-c', 'print("{0}".capitalize())'.format(data['name'])).stdout().strip()
> 
> would a bit overkill for this.

I think it's _WAY_ better than having another entry in the dictionary
just for the name with uppercase first letter.

The autoconf thing was probably just because it wasn't possible to
automate.

> > > +#   * with_ip - only for libvirtd and virtproxyd (optional, default false)
> > > +virt_daemon_confs = []
> > > +
> > > +virt_aug_dir = datadir / 'augeas' / 'lenses'
> > > +virt_test_aug_dir = datadir / 'augeas' / 'lenses' / 'tests'
> > > +
> > >  
> > >  # list subdirectories
> > >  
> > > @@ -547,3 +573,80 @@ foreach helper : virt_helpers
> > >      install_rpath: libdir,
> > >    )
> > >  endforeach
> > > +
> > > +
> > > +# Generate daemon config, augeas and augeas test files
> > > +
> > > +install_data(virt_conf_files, install_dir: confdir)
> > > +install_data(virt_aug_files, install_dir: virt_aug_dir)
> > > +
> > > +foreach data : virt_test_aug_files
> > > +  custom_target(
> > > +    data['name'],
> > > +    input: [ data['conf'], data['aug'] ],
> > > +    output: data['name'],
> > > +    command: [ meson_python_prog, augeas_gentest_prog, '@INPUT@' ],
> > > +    capture: true,
> > > +    install: true,
> > 
> > Why do we install test files?
> 
> No idea :) but with autotools we install them as well. If we want to
> change it I would do it as followup patch once this is merged.

Fair enough. This can be kept as-is.