[libvirt PATCH 1/4] meson: Print custom message when GNU grep is not installed

Andrea Bolognani abologna at redhat.com
Wed Mar 24 18:37:57 UTC 2021


Currently, if GNU grep is not installed on a FreeBSD system the
configuration step will fail with

  Program grep found: YES (/usr/bin/grep)
  Program /usr/local/bin/grep found: NO

  ERROR: Program '/usr/local/bin/grep' not found

which is confusing and not very useful; after this change, the
message will be

  Program grep found: YES (/usr/bin/grep)
  Program /usr/local/bin/grep found: NO

  ERROR: Problem encountered: GNU grep not found

instead, which should do a better job helping the user figure
out that they need to install GNU grep from ports to proceed.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 build-aux/meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/build-aux/meson.build b/build-aux/meson.build
index c44ed6821c..06b7a7c01f 100644
--- a/build-aux/meson.build
+++ b/build-aux/meson.build
@@ -18,7 +18,10 @@ if host_machine.system() == 'freebsd'
 
   grep_cmd = run_command(grep_prog, '--version')
   if grep_cmd.stdout().startswith('grep (BSD grep')
-    grep_prog = find_program('/usr/local/bin/grep')
+    grep_prog = find_program('/usr/local/bin/grep', required: false)
+    if not grep_prog.found()
+      error('GNU grep not found')
+    endif
     grep_cmd = run_command(grep_prog, '--version')
     if grep_cmd.stdout().startswith('grep (BSD grep')
       error('GNU grep not found')
-- 
2.26.3




More information about the libvir-list mailing list