[libvirt PATCH 034/351] meson: add AppArmor build dependency

Pavel Hrdina posted 351 patches 5 years, 6 months ago
There is a newer version of this series
[libvirt PATCH 034/351] meson: add AppArmor build dependency
Posted by Pavel Hrdina 5 years, 6 months ago
APPARMOR_MOUNT is not used so dropping it in meson.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 configure.ac        |  3 ---
 m4/virt-apparmor.m4 | 41 -----------------------------------------
 meson.build         |  8 ++++++++
 meson_options.txt   |  4 ++++
 4 files changed, 12 insertions(+), 44 deletions(-)
 delete mode 100644 m4/virt-apparmor.m4

diff --git a/configure.ac b/configure.ac
index 53c87b4e293..5bf4727faa7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,7 +114,6 @@ fi
 
 # Check for compiler and library settings.
 
-LIBVIRT_ARG_APPARMOR
 LIBVIRT_ARG_ATTR
 LIBVIRT_ARG_AUDIT
 LIBVIRT_ARG_BASH_COMPLETION
@@ -150,7 +149,6 @@ LIBVIRT_ARG_VIRTUALPORT
 LIBVIRT_ARG_WIRESHARK
 LIBVIRT_ARG_YAJL
 
-LIBVIRT_CHECK_APPARMOR
 LIBVIRT_CHECK_ATTR
 LIBVIRT_CHECK_AUDIT
 LIBVIRT_CHECK_BASH_COMPLETION
@@ -479,7 +477,6 @@ LIBVIRT_RESULT_DRIVER_MODULES
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
-LIBVIRT_RESULT_APPARMOR
 LIBVIRT_RESULT_ATTR
 LIBVIRT_RESULT_AUDIT
 LIBVIRT_RESULT_BASH_COMPLETION
diff --git a/m4/virt-apparmor.m4 b/m4/virt-apparmor.m4
deleted file mode 100644
index ebddfce2015..00000000000
--- a/m4/virt-apparmor.m4
+++ /dev/null
@@ -1,41 +0,0 @@
-dnl The libapparmor.so library
-dnl
-dnl Copyright (C) 2012-2013 Red Hat, Inc.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library.  If not, see
-dnl <http://www.gnu.org/licenses/>.
-dnl
-
-AC_DEFUN([LIBVIRT_ARG_APPARMOR],[
-  LIBVIRT_ARG_WITH_FEATURE([APPARMOR], [AppArmor], [check])
-  LIBVIRT_ARG_WITH([APPARMOR_MOUNT], [set AppArmor mount point], [check])
-])
-
-AC_DEFUN([LIBVIRT_CHECK_APPARMOR],[
-  LIBVIRT_CHECK_LIB([APPARMOR], [apparmor],
-                    [aa_change_profile], [sys/apparmor.h])
-
-  if test "$with_apparmor" = "yes"; then
-    AC_DEFINE_UNQUOTED([APPARMOR_DIR],
-                       "/etc/apparmor.d",
-                       [path to apparmor directory])
-    AC_DEFINE_UNQUOTED([APPARMOR_PROFILES_PATH],
-                       "/sys/kernel/security/apparmor/profiles",
-                       [path to kernel profiles])
-  fi
-])
-
-AC_DEFUN([LIBVIRT_RESULT_APPARMOR],[
-  LIBVIRT_RESULT_LIB([APPARMOR])
-])
diff --git a/meson.build b/meson.build
index d8ff8e0d658..be0bc975116 100644
--- a/meson.build
+++ b/meson.build
@@ -951,6 +951,13 @@ else
   acl_dep = dependency('', required: false)
 endif
 
+apparmor_dep = cc.find_library('AppArmor', required: get_option('apparmor'))
+if apparmor_dep.found()
+  conf.set('WITH_APPARMOR', 1)
+  conf.set_quoted('APPARMOR_DIR', '/etc/apparmor.d')
+  conf.set_quoted('APPARMOR_PROFILES_PATH', '/sys/kernel/security/apparmor/profiles')
+endif
+
 
 # define top include directory
 
@@ -972,6 +979,7 @@ configure_file(output: 'meson-config.h', configuration: conf)
 
 libs_summary = {
   'acl': acl_dep.found(),
+  'apparmor': apparmor_dep.found(),
 }
 summary(libs_summary, section: 'Libraries', bool_yn: true)
 
diff --git a/meson_options.txt b/meson_options.txt
index 0f79f8aea03..dc60d569dd2 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,3 +6,7 @@ option('runstatedir', type: 'string', value: '', description: 'State directory f
 option('test_suite', type: 'boolean', value: true, description: 'Whether to enable and build test suite by default')
 option('expensive_tests', type: 'feature', value: 'auto', description: 'set the default for enabling expensive tests (long timeouts), use VIR_TEST_EXPENSIVE to override')
 option('test_coverage', type: 'boolean', value: false, description: 'turn on code coverage instrumentation')
+
+
+# build dependencies options
+option('apparmor', type: 'feature', value: 'auto', description: 'apparmor support')
-- 
2.26.2

Re: [libvirt PATCH 034/351] meson: add AppArmor build dependency
Posted by Michal Privoznik 5 years, 6 months ago
On 7/16/20 11:54 AM, Pavel Hrdina wrote:
> APPARMOR_MOUNT is not used so dropping it in meson.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>   configure.ac        |  3 ---
>   m4/virt-apparmor.m4 | 41 -----------------------------------------
>   meson.build         |  8 ++++++++
>   meson_options.txt   |  4 ++++
>   4 files changed, 12 insertions(+), 44 deletions(-)
>   delete mode 100644 m4/virt-apparmor.m4
> 
> diff --git a/configure.ac b/configure.ac
> index 53c87b4e293..5bf4727faa7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -114,7 +114,6 @@ fi
>   
>   # Check for compiler and library settings.
>   
> -LIBVIRT_ARG_APPARMOR
>   LIBVIRT_ARG_ATTR
>   LIBVIRT_ARG_AUDIT
>   LIBVIRT_ARG_BASH_COMPLETION
> @@ -150,7 +149,6 @@ LIBVIRT_ARG_VIRTUALPORT
>   LIBVIRT_ARG_WIRESHARK
>   LIBVIRT_ARG_YAJL
>   
> -LIBVIRT_CHECK_APPARMOR
>   LIBVIRT_CHECK_ATTR
>   LIBVIRT_CHECK_AUDIT
>   LIBVIRT_CHECK_BASH_COMPLETION
> @@ -479,7 +477,6 @@ LIBVIRT_RESULT_DRIVER_MODULES
>   AC_MSG_NOTICE([])
>   AC_MSG_NOTICE([Libraries])
>   AC_MSG_NOTICE([])
> -LIBVIRT_RESULT_APPARMOR
>   LIBVIRT_RESULT_ATTR
>   LIBVIRT_RESULT_AUDIT
>   LIBVIRT_RESULT_BASH_COMPLETION
> diff --git a/m4/virt-apparmor.m4 b/m4/virt-apparmor.m4
> deleted file mode 100644
> index ebddfce2015..00000000000
> --- a/m4/virt-apparmor.m4
> +++ /dev/null
> @@ -1,41 +0,0 @@
> -dnl The libapparmor.so library
> -dnl
> -dnl Copyright (C) 2012-2013 Red Hat, Inc.
> -dnl
> -dnl This library is free software; you can redistribute it and/or
> -dnl modify it under the terms of the GNU Lesser General Public
> -dnl License as published by the Free Software Foundation; either
> -dnl version 2.1 of the License, or (at your option) any later version.
> -dnl
> -dnl This library is distributed in the hope that it will be useful,
> -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
> -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -dnl Lesser General Public License for more details.
> -dnl
> -dnl You should have received a copy of the GNU Lesser General Public
> -dnl License along with this library.  If not, see
> -dnl <http://www.gnu.org/licenses/>.
> -dnl
> -
> -AC_DEFUN([LIBVIRT_ARG_APPARMOR],[
> -  LIBVIRT_ARG_WITH_FEATURE([APPARMOR], [AppArmor], [check])
> -  LIBVIRT_ARG_WITH([APPARMOR_MOUNT], [set AppArmor mount point], [check])
> -])
> -
> -AC_DEFUN([LIBVIRT_CHECK_APPARMOR],[
> -  LIBVIRT_CHECK_LIB([APPARMOR], [apparmor],
> -                    [aa_change_profile], [sys/apparmor.h])
> -
> -  if test "$with_apparmor" = "yes"; then
> -    AC_DEFINE_UNQUOTED([APPARMOR_DIR],
> -                       "/etc/apparmor.d",
> -                       [path to apparmor directory])
> -    AC_DEFINE_UNQUOTED([APPARMOR_PROFILES_PATH],
> -                       "/sys/kernel/security/apparmor/profiles",
> -                       [path to kernel profiles])
> -  fi
> -])
> -
> -AC_DEFUN([LIBVIRT_RESULT_APPARMOR],[
> -  LIBVIRT_RESULT_LIB([APPARMOR])
> -])
> diff --git a/meson.build b/meson.build
> index d8ff8e0d658..be0bc975116 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -951,6 +951,13 @@ else
>     acl_dep = dependency('', required: false)
>   endif
>   
> +apparmor_dep = cc.find_library('AppArmor', required: get_option('apparmor'))

IIUC this tries to find -lAppArmor, but the library is called 
/usr/lib64/libapparmor.so.1.6.2. And also, it provides pkgconfig file: 
/usr/lib64/pkgconfig/libapparmor.pc

I don't know how to fix it, so I'm just reporting it.

Sorry,
Michal

Re: [libvirt PATCH 034/351] meson: add AppArmor build dependency
Posted by Pavel Hrdina 5 years, 6 months ago
On Tue, Jul 28, 2020 at 07:03:56PM +0200, Michal Privoznik wrote:
> On 7/16/20 11:54 AM, Pavel Hrdina wrote:
> > APPARMOR_MOUNT is not used so dropping it in meson.
> > 
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >   configure.ac        |  3 ---
> >   m4/virt-apparmor.m4 | 41 -----------------------------------------
> >   meson.build         |  8 ++++++++
> >   meson_options.txt   |  4 ++++
> >   4 files changed, 12 insertions(+), 44 deletions(-)
> >   delete mode 100644 m4/virt-apparmor.m4
> > 
> > diff --git a/configure.ac b/configure.ac
> > index 53c87b4e293..5bf4727faa7 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -114,7 +114,6 @@ fi
> >   # Check for compiler and library settings.
> > -LIBVIRT_ARG_APPARMOR
> >   LIBVIRT_ARG_ATTR
> >   LIBVIRT_ARG_AUDIT
> >   LIBVIRT_ARG_BASH_COMPLETION
> > @@ -150,7 +149,6 @@ LIBVIRT_ARG_VIRTUALPORT
> >   LIBVIRT_ARG_WIRESHARK
> >   LIBVIRT_ARG_YAJL
> > -LIBVIRT_CHECK_APPARMOR
> >   LIBVIRT_CHECK_ATTR
> >   LIBVIRT_CHECK_AUDIT
> >   LIBVIRT_CHECK_BASH_COMPLETION
> > @@ -479,7 +477,6 @@ LIBVIRT_RESULT_DRIVER_MODULES
> >   AC_MSG_NOTICE([])
> >   AC_MSG_NOTICE([Libraries])
> >   AC_MSG_NOTICE([])
> > -LIBVIRT_RESULT_APPARMOR
> >   LIBVIRT_RESULT_ATTR
> >   LIBVIRT_RESULT_AUDIT
> >   LIBVIRT_RESULT_BASH_COMPLETION
> > diff --git a/m4/virt-apparmor.m4 b/m4/virt-apparmor.m4
> > deleted file mode 100644
> > index ebddfce2015..00000000000
> > --- a/m4/virt-apparmor.m4
> > +++ /dev/null
> > @@ -1,41 +0,0 @@
> > -dnl The libapparmor.so library
> > -dnl
> > -dnl Copyright (C) 2012-2013 Red Hat, Inc.
> > -dnl
> > -dnl This library is free software; you can redistribute it and/or
> > -dnl modify it under the terms of the GNU Lesser General Public
> > -dnl License as published by the Free Software Foundation; either
> > -dnl version 2.1 of the License, or (at your option) any later version.
> > -dnl
> > -dnl This library is distributed in the hope that it will be useful,
> > -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
> > -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > -dnl Lesser General Public License for more details.
> > -dnl
> > -dnl You should have received a copy of the GNU Lesser General Public
> > -dnl License along with this library.  If not, see
> > -dnl <http://www.gnu.org/licenses/>.
> > -dnl
> > -
> > -AC_DEFUN([LIBVIRT_ARG_APPARMOR],[
> > -  LIBVIRT_ARG_WITH_FEATURE([APPARMOR], [AppArmor], [check])
> > -  LIBVIRT_ARG_WITH([APPARMOR_MOUNT], [set AppArmor mount point], [check])
> > -])
> > -
> > -AC_DEFUN([LIBVIRT_CHECK_APPARMOR],[
> > -  LIBVIRT_CHECK_LIB([APPARMOR], [apparmor],
> > -                    [aa_change_profile], [sys/apparmor.h])
> > -
> > -  if test "$with_apparmor" = "yes"; then
> > -    AC_DEFINE_UNQUOTED([APPARMOR_DIR],
> > -                       "/etc/apparmor.d",
> > -                       [path to apparmor directory])
> > -    AC_DEFINE_UNQUOTED([APPARMOR_PROFILES_PATH],
> > -                       "/sys/kernel/security/apparmor/profiles",
> > -                       [path to kernel profiles])
> > -  fi
> > -])
> > -
> > -AC_DEFUN([LIBVIRT_RESULT_APPARMOR],[
> > -  LIBVIRT_RESULT_LIB([APPARMOR])
> > -])
> > diff --git a/meson.build b/meson.build
> > index d8ff8e0d658..be0bc975116 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -951,6 +951,13 @@ else
> >     acl_dep = dependency('', required: false)
> >   endif
> > +apparmor_dep = cc.find_library('AppArmor', required: get_option('apparmor'))
> 
> IIUC this tries to find -lAppArmor, but the library is called
> /usr/lib64/libapparmor.so.1.6.2. And also, it provides pkgconfig file:
> /usr/lib64/pkgconfig/libapparmor.pc
> 
> I don't know how to fix it, so I'm just reporting it.

Thanks for the report, the -lAppArmor was my mistake, not using
pkgconfig is pre-existing with autotools but in this case I can convert
it directly to pkgconfig in meson. The libapparmor.pc file exits on all
supported distributions so we should be safe.

No worries :) I'll fix it.

Pavel