From bd727a7cd560140a1646e3afaba237dfb6a92dc4 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 v1] 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.
---
 meson.build            | 2 +-
 src/Makefile.global.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 0095fb183a..5bae1eb04c 100644
--- a/meson.build
+++ b/meson.build
@@ -3112,7 +3112,7 @@ sys.exit(sp.returncode)
 ''',
        test_initdb_template,
        temp_install_bindir / 'initdb',
-       '-A', 'trust', '-N', '--no-instructions', '--no-locale'
+       '-A', 'trust', '-N', '--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..06588b1c47 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 -A trust -N --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

