On 18.12.23 14:52, Peter Eisentraut wrote:
2) I had seen that if sed/gzip is not available meson build will fail:
2.a)
Program gsed sed found: NO
meson.build:334:6: ERROR: Program 'gsed sed' not found or not executable

Yes, this would need to be improved.  Currently, sed is only required if either selinux or dtrace is enabled, which isn't supported on Windows. But we should adjust the build scripts to not fail the top-level setup run unless those options are enabled.

2.b)
Program gzip found: NO
meson.build:337:7: ERROR: Program 'gzip' not found or not executable

gzip is only required for certain test suites, so again we should adjust the build scripts to not fail the build but instead skip the tests as appropriate.

Here are patches for these two issues.  More testing would be appreciated.
From 8c51d31676b8a5b9ee17ab3a04be142076f2a48f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 19 Dec 2023 16:05:54 +0100
Subject: [PATCH 1/2] meson: Require sed only when needed

sed is required only if dtrace or selinux is enabled.  Otherwise, we
don't need it.  This avoids making sed a hard requirement on Windows.
---
 meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index d3771690f0..b8c7ed8bf2 100644
--- a/meson.build
+++ b/meson.build
@@ -331,7 +331,8 @@ perl = find_program(get_option('PERL'), required: true, 
native: true)
 python = find_program(get_option('PYTHON'), required: true, native: true)
 flex = find_program(get_option('FLEX'), native: true, version: '>= 2.5.35')
 bison = find_program(get_option('BISON'), native: true, version: '>= 2.3')
-sed = find_program(get_option('SED'), 'sed', native: true)
+sed = find_program(get_option('SED'), 'sed', native: true,
+                   required: get_option('dtrace').enabled() or 
get_option('selinux').enabled())
 prove = find_program(get_option('PROVE'), native: true, required: false)
 tar = find_program(get_option('TAR'), native: true)
 gzip = find_program(get_option('GZIP'), native: true)
-- 
2.43.0

From d95033439f60ea19c5a316f658f0016b6691a232 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 19 Dec 2023 16:20:41 +0100
Subject: [PATCH 2/2] meson: Make gzip and tar optional

They are only used for some tests.  The tests are already set to skip
as appropriate if they are not available.
---
 contrib/basebackup_to_shell/meson.build | 4 ++--
 meson.build                             | 4 ++--
 src/bin/pg_basebackup/meson.build       | 4 ++--
 src/bin/pg_dump/meson.build             | 2 +-
 src/bin/pg_verifybackup/meson.build     | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/contrib/basebackup_to_shell/meson.build 
b/contrib/basebackup_to_shell/meson.build
index a5488c3023..331ee1c9be 100644
--- a/contrib/basebackup_to_shell/meson.build
+++ b/contrib/basebackup_to_shell/meson.build
@@ -24,7 +24,7 @@ tests += {
     'tests': [
       't/001_basic.pl',
     ],
-    'env': {'GZIP_PROGRAM': gzip.path(),
-            'TAR': tar.path()},
+    'env': {'GZIP_PROGRAM': gzip.found() ? gzip.path() : '',
+            'TAR': tar.found() ? tar.path() : '' },
   },
 }
diff --git a/meson.build b/meson.build
index b8c7ed8bf2..c8a2630db8 100644
--- a/meson.build
+++ b/meson.build
@@ -334,8 +334,8 @@ bison = find_program(get_option('BISON'), native: true, 
version: '>= 2.3')
 sed = find_program(get_option('SED'), 'sed', native: true,
                    required: get_option('dtrace').enabled() or 
get_option('selinux').enabled())
 prove = find_program(get_option('PROVE'), native: true, required: false)
-tar = find_program(get_option('TAR'), native: true)
-gzip = find_program(get_option('GZIP'), native: true)
+tar = find_program(get_option('TAR'), native: true, required: false)
+gzip = find_program(get_option('GZIP'), native: true, required: false)
 program_lz4 = find_program(get_option('LZ4'), native: true, required: false)
 openssl = find_program(get_option('OPENSSL'), native: true, required: false)
 program_zstd = find_program(get_option('ZSTD'), native: true, required: false)
diff --git a/src/bin/pg_basebackup/meson.build 
b/src/bin/pg_basebackup/meson.build
index c426173db3..5445903a5b 100644
--- a/src/bin/pg_basebackup/meson.build
+++ b/src/bin/pg_basebackup/meson.build
@@ -80,8 +80,8 @@ tests += {
   'sd': meson.current_source_dir(),
   'bd': meson.current_build_dir(),
   'tap': {
-    'env': {'GZIP_PROGRAM': gzip.path(),
-            'TAR': tar.path(),
+    'env': {'GZIP_PROGRAM': gzip.found() ? gzip.path() : '',
+            'TAR': tar.found() ? tar.path() : '',
             'LZ4': program_lz4.found() ? program_lz4.path() : '',
     },
     'tests': [
diff --git a/src/bin/pg_dump/meson.build b/src/bin/pg_dump/meson.build
index b6603e26a5..77d162cad4 100644
--- a/src/bin/pg_dump/meson.build
+++ b/src/bin/pg_dump/meson.build
@@ -90,7 +90,7 @@ tests += {
   'bd': meson.current_build_dir(),
   'tap': {
     'env': {
-      'GZIP_PROGRAM': gzip.path(),
+      'GZIP_PROGRAM': gzip.found() ? gzip.path() : '',
       'LZ4': program_lz4.found() ? program_lz4.path() : '',
       'ZSTD': program_zstd.found() ? program_zstd.path() : '',
       'with_icu': icu.found() ? 'yes' : 'no',
diff --git a/src/bin/pg_verifybackup/meson.build 
b/src/bin/pg_verifybackup/meson.build
index 9369da1bc6..a14a1a48a5 100644
--- a/src/bin/pg_verifybackup/meson.build
+++ b/src/bin/pg_verifybackup/meson.build
@@ -23,8 +23,8 @@ tests += {
   'sd': meson.current_source_dir(),
   'bd': meson.current_build_dir(),
   'tap': {
-    'env': {'GZIP_PROGRAM': gzip.path(),
-            'TAR': tar.path(),
+    'env': {'GZIP_PROGRAM': gzip.found() ? gzip.path() : '',
+            'TAR': tar.found() ? tar.path() : '',
             'LZ4': program_lz4.found() ? program_lz4.path() : '',
             'ZSTD': program_zstd.found() ? program_zstd.path() : ''},
     'tests': [
-- 
2.43.0

Reply via email to