From 216499bba55ce20cb9ba50a3bf440d0929e7dd8f Mon Sep 17 00:00:00 2001
From: Jason Boyer <jboyer@equinoxOLI.org>
Date: Fri, 25 Mar 2022 13:45:13 -0400
Subject: [PATCH] Switch to pgtap installed from packages

Uses dpkg-query to find the version of postgresql currently
installed and then installs that version of pgtap.

Signed-off-by: Jason Boyer <jboyer@equinoxOLI.org>
---
 installer/stretch/eg_stretch_installer.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/installer/stretch/eg_stretch_installer.sh b/installer/stretch/eg_stretch_installer.sh
index 4c6be8dd3..3f45c02f1 100755
--- a/installer/stretch/eg_stretch_installer.sh
+++ b/installer/stretch/eg_stretch_installer.sh
@@ -908,13 +908,12 @@ function evergreen_db_create {
     echo Return Value = $?
 
     echo Installing pgtap
-    PG_TAP_VER="1.2.0"
-    wget -N http://api.pgxn.org/dist/pgtap/$PG_TAP_VER/pgtap-$PG_TAP_VER.zip \
-    && unzip pgtap-$PG_TAP_VER.zip \
-    && cd pgtap-$PG_TAP_VER \
-    && make \
-    && make installcheck \
-    && make install
+
+    # output the name of the currently installed pg server dev package, then
+    # throw away everything up to and including the last '-' to get the correct pg version
+    PGVERS=`dpkg-query --showformat="\\${binary:Package}" --show 'postgresql-server-dev-*'`
+    apt-get install postgresql-${PGVERS##*-}-pgtap
+
     echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
 
     echo End of Create Evergreen Database =~-._
-- 
2.11.0