From a77293d22bc58fe23bdc9bdec64ac9b2f153718b Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Thu, 7 Dec 2023 14:47:32 +0100
Subject: [PATCH v2] Don't remove initdb template when initdb fails

pg_regress doesn't do that either, so keep a copy around
to allow us to debug those issues.

While we're here, use the long options for initdb, to
make this code more self-documenting.

Reviewed-by: Daniel Gustafsson
---
 meson.build            | 3 ++-
 src/Makefile.global.in | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 0095fb183a..502f511588 100644
--- a/meson.build
+++ b/meson.build
@@ -3112,7 +3112,8 @@ sys.exit(sp.returncode)
 ''',
        test_initdb_template,
        temp_install_bindir / 'initdb',
-       '-A', 'trust', '-N', '--no-instructions', '--no-locale'
+       '--auth', 'trust', '--no-sync', '--no-instructions', '--no-locale',
+       '--no-clean'
      ],
      priority: setup_tests_priority - 1,
      timeout: 300,
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index b3ca6392a6..104e5de0fe 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -423,7 +423,7 @@ ifeq ($(MAKELEVEL),0)
 	$(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
 	$(MAKE) -j1 $(if $(CHECKPREP_TOP),-C $(CHECKPREP_TOP),) checkprep >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
 
-	$(with_temp_install) initdb -A trust -N --no-instructions --no-locale '$(abs_top_builddir)'/tmp_install/initdb-template >>'$(abs_top_builddir)'/tmp_install/log/initdb-template.log 2>&1
+	$(with_temp_install) initdb --auth trust --no-sync --no-instructions --no-locale --no-clean '$(abs_top_builddir)'/tmp_install/initdb-template >>'$(abs_top_builddir)'/tmp_install/log/initdb-template.log 2>&1
 endif
 endif
 endif
-- 
2.40.1

