From 57846ef1ca40c0b56e7719d9b45c7c2148d3e6fa Mon Sep 17 00:00:00 2001
From: "David E. Wheeler" <david.wheeler@tembo.io>
Date: Fri, 3 Jan 2025 16:28:23 -0500
Subject: [PATCH] Eliminate old-style `mv` install scripting

Update the install script configs that sill used `mv /usr/local/pgsql`
syntax that's not necessary when properly building with PGXS from these
extensions:

*   argm
*   citus
*   count_distinct
*   credcheck
*   db_migrator
*   extra_window_functions
*   h3_pg
*   pg_embedding
*   pg_ivm
*   pgroonga
*   postgresql_unit

Upgrade these extensions:

*   credcheck 3.0.0
*   pg_embedding 0.3.6
*   pgroonga 3.2.5
*   postgresql_unit 7.10.0

And do some housekeeping:

*   Upgrade to groonga 14.1.2 and require the version of
    trunk-test-tembo that includes it.
*   Rename `contrib/pg-base62` to `pg_base62` to match the name in its
    `Trunk.toml`.
*   Remove `contrib/pgbase36`, which already exists as
    `contrib/pg_base36`.
*   Remove `contrib/pg-base62`, which already exists as
    `contrib/pg_base62`.
*   Hack the postgresql_unit build to put `*.data` files in the right
    place for our images, and use `build.include` to tell Trunk to
    install them.
---
 .github/workflows/extensions.yaml         |  4 +--
 .github/workflows/trunk-install-test.yml  |  2 +-
 contrib/argm/Dockerfile                   | 14 +++++-----
 contrib/argm/Trunk.toml                   |  8 +-----
 contrib/citus/Dockerfile                  | 24 +++++++----------
 contrib/citus/Trunk.toml                  |  8 +-----
 contrib/count_distinct/Dockerfile         | 19 ++++++--------
 contrib/count_distinct/Trunk.toml         |  7 +----
 contrib/credcheck/Dockerfile              | 21 ++++++---------
 contrib/credcheck/Trunk.toml              |  9 ++-----
 contrib/db_migrator/Dockerfile            | 20 +++++---------
 contrib/db_migrator/Trunk.toml            |  7 +----
 contrib/envvar/Dockerfile                 |  2 +-
 contrib/extra_window_functions/Dockerfile | 16 +++++-------
 contrib/extra_window_functions/Trunk.toml |  7 +----
 contrib/h3_pg/Dockerfile                  | 23 ++++++----------
 contrib/h3_pg/Trunk.toml                  |  7 +----
 contrib/mobilitydb/Dockerfile             |  2 +-
 contrib/pg-base62/Dockerfile              | 12 ---------
 contrib/pg-base62/Trunk.toml              | 24 -----------------
 contrib/pg_embedding/Dockerfile           | 24 +++++------------
 contrib/pg_embedding/Trunk.toml           | 11 +++-----
 contrib/pg_ivm/Dockerfile                 | 16 +++++-------
 contrib/pg_ivm/Trunk.toml                 |  7 +----
 contrib/pgbase36/Dockerfile               | 12 ---------
 contrib/pgbase36/Trunk.toml               | 24 -----------------
 contrib/pgroonga/Dockerfile               | 32 +++++++++--------------
 contrib/pgroonga/Trunk.toml               | 13 +++------
 contrib/postgresql_unit/Dockerfile        | 21 ++++++++-------
 contrib/postgresql_unit/Trunk.toml        | 13 ++++-----
 30 files changed, 117 insertions(+), 292 deletions(-)
 delete mode 100644 contrib/pg-base62/Dockerfile
 delete mode 100644 contrib/pg-base62/Trunk.toml
 delete mode 100644 contrib/pgbase36/Dockerfile
 delete mode 100644 contrib/pgbase36/Trunk.toml

diff --git a/.github/workflows/extensions.yaml b/.github/workflows/extensions.yaml
index 81a95f39..4e95df11 100644
--- a/.github/workflows/extensions.yaml
+++ b/.github/workflows/extensions.yaml
@@ -57,7 +57,7 @@ jobs:
       - dind
       - xlarge-16x16
     container:
-      image: quay.io/tembo/trunk-test-tembo:f3b2a28-pg15
+      image: quay.io/tembo/trunk-test-tembo:bdb0905-pg15
       options: --user root
     needs:
       - find_directories
@@ -92,7 +92,7 @@ jobs:
       - dind
       - xlarge-16x16
     container:
-      image: quay.io/tembo/trunk-test-tembo:f3b2a28-pg15
+      image: quay.io/tembo/trunk-test-tembo:bdb0905-pg15
       options: --user root
     needs:
       - find_directories
diff --git a/.github/workflows/trunk-install-test.yml b/.github/workflows/trunk-install-test.yml
index 775b0bd3..7eb64e09 100644
--- a/.github/workflows/trunk-install-test.yml
+++ b/.github/workflows/trunk-install-test.yml
@@ -18,7 +18,7 @@ jobs:
       - dind
       - large-8x8
     container:
-      image: quay.io/tembo/trunk-test-tembo:f3b2a28-pg15
+      image: quay.io/tembo/trunk-test-tembo:bdb0905-pg15
       options: --user root
     env:
       PGHOST: "localhost"
diff --git a/contrib/argm/Dockerfile b/contrib/argm/Dockerfile
index c4c28240..0f902d5c 100644
--- a/contrib/argm/Dockerfile
+++ b/contrib/argm/Dockerfile
@@ -1,9 +1,11 @@
 # Set PostgreSQL version
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Clone repository
-RUN git clone https://github.com/bashtanov/argm.git
-
-# Build extension
-RUN cd argm && make
+ARG EXTENSION_NAME
+# ARG EXTENSION_VERSION
+ARG RELEASE=b8b2db3
+RUN git clone https://github.com/bashtanov/${EXTENSION_NAME}.git \
+    && cd ${EXTENSION_NAME} \
+    && git checkout ${RELEASE} \
+    && make
diff --git a/contrib/argm/Trunk.toml b/contrib/argm/Trunk.toml
index 9e763f19..0f1660a0 100644
--- a/contrib/argm/Trunk.toml
+++ b/contrib/argm/Trunk.toml
@@ -7,7 +7,6 @@ description = "Argm postgresql extension: argmax/argmin and anyold aggregate fun
 documentation = "https://github.com/bashtanov/argm"
 categories = ["query_optimizations"]
 
-
 [dependencies]
 apt = ["libc6"]
 
@@ -15,9 +14,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd argm && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C argm install"
diff --git a/contrib/citus/Dockerfile b/contrib/citus/Dockerfile
index a6a51245..c1594b31 100644
--- a/contrib/citus/Dockerfile
+++ b/contrib/citus/Dockerfile
@@ -1,9 +1,9 @@
 # Set PostgreSQL version
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
 
 # Extension build dependencies
+USER root
 RUN apt-get update && apt-get install -y \
     libcurl4-openssl-dev \
     liblz4-dev \
@@ -12,15 +12,11 @@ RUN apt-get update && apt-get install -y \
     libselinux1-dev \
     libxslt1-dev
 
-# Clone repository
-RUN git clone https://github.com/citusdata/citus.git
-
-# Set project version
-ARG RELEASE=v12.1.6
-
-# Build extension
-RUN cd citus && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    ./configure && \
-    make
+    # Download and build extension
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN curl -O https://api.pgxn.org/dist/${EXTENSION_NAME}/${EXTENSION_VERSION}/${EXTENSION_NAME}-${EXTENSION_VERSION}.zip \
+    && unzip ${EXTENSION_NAME}-${EXTENSION_VERSION}.zip \
+    && cd ${EXTENSION_NAME}-${EXTENSION_VERSION} \
+    && ./configure && make
+WORKDIR /app/${EXTENSION_NAME}-${EXTENSION_VERSION}
diff --git a/contrib/citus/Trunk.toml b/contrib/citus/Trunk.toml
index d3dcadf1..60f311a7 100644
--- a/contrib/citus/Trunk.toml
+++ b/contrib/citus/Trunk.toml
@@ -16,10 +16,4 @@ apt = ["libpq5", "openssl", "libc6", "liblz4-1", "libzstd1", "libssl3", "libcurl
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd citus && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
-
+install_command = "make install"
diff --git a/contrib/count_distinct/Dockerfile b/contrib/count_distinct/Dockerfile
index aa44b470..50b572c0 100644
--- a/contrib/count_distinct/Dockerfile
+++ b/contrib/count_distinct/Dockerfile
@@ -1,15 +1,12 @@
 # Set PostgreSQL version
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Clone repository
-RUN git clone https://github.com/tvondra/count_distinct.git 
-
-# Set project version
+# Clone and build the extension.
+ARG EXTENSION_NAME
+# ARG EXTENSION_VERSION
 ARG RELEASE=8f4883a
-
-# Build extension
-RUN cd count_distinct && \
-    # git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+RUN git clone https://github.com/tvondra/${EXTENSION_NAME}.git \
+    && cd ${EXTENSION_NAME} \
+    && git checkout ${RELEASE} \
+    && make
diff --git a/contrib/count_distinct/Trunk.toml b/contrib/count_distinct/Trunk.toml
index 21977ca0..a4443d4a 100644
--- a/contrib/count_distinct/Trunk.toml
+++ b/contrib/count_distinct/Trunk.toml
@@ -14,9 +14,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd count_distinct && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C count_distinct install"
diff --git a/contrib/credcheck/Dockerfile b/contrib/credcheck/Dockerfile
index bf210387..827a1c5a 100644
--- a/contrib/credcheck/Dockerfile
+++ b/contrib/credcheck/Dockerfile
@@ -1,17 +1,12 @@
-ARG PG_VERSION=15
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
 
 # Extension build dependencies
-RUN apt-get update && apt-get install -y \
-    libkrb5-dev
-
-# Clone repository
-RUN git clone https://github.com/HexaCluster/credcheck.git
-
-ARG RELEASE=v2.8
+USER root
+RUN apt-get update && apt-get install -y libkrb5-dev
 
-RUN cd credcheck && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "v$(perl -E 'print shift =~ s/[.]0$//gr' "${EXTENSION_VERSION}")" https://github.com/HexaCluster/${EXTENSION_NAME}.git \
+    && make -C ${EXTENSION_NAME}
diff --git a/contrib/credcheck/Trunk.toml b/contrib/credcheck/Trunk.toml
index b636555b..c83efecf 100644
--- a/contrib/credcheck/Trunk.toml
+++ b/contrib/credcheck/Trunk.toml
@@ -1,6 +1,6 @@
 [extension]
 name = "credcheck"
-version = "2.8.0"
+version = "3.0.0"
 repository = "https://github.com/HexaCluster/credcheck"
 license = "MIT"
 description = "PostgreSQL plain credential checker"
@@ -16,9 +16,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd credcheck && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C credcheck install"
diff --git a/contrib/db_migrator/Dockerfile b/contrib/db_migrator/Dockerfile
index 5b91801a..2c6b4570 100644
--- a/contrib/db_migrator/Dockerfile
+++ b/contrib/db_migrator/Dockerfile
@@ -1,17 +1,9 @@
 # Set PostgreSQL version
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Extension build dependencies
-
-# Clone repository
-RUN git clone https://github.com/cybertec-postgresql/db_migrator.git
-
-# Set project version
-ARG RELEASE=RELEASE_1_0_0
-
-# Build extension
-RUN cd db_migrator && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "RELEASE_$(perl -E 'print shift =~ s/\./_/gr' "${EXTENSION_VERSION}")" https://github.com/cybertec-postgresql/${EXTENSION_NAME}.git \
+    && make -C ${EXTENSION_NAME}
diff --git a/contrib/db_migrator/Trunk.toml b/contrib/db_migrator/Trunk.toml
index f3037db1..c573227e 100644
--- a/contrib/db_migrator/Trunk.toml
+++ b/contrib/db_migrator/Trunk.toml
@@ -12,9 +12,4 @@ categories = ["connectors"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd db_migrator && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C db_migrator install"
diff --git a/contrib/envvar/Dockerfile b/contrib/envvar/Dockerfile
index 6c41e7ff..b76ec244 100644
--- a/contrib/envvar/Dockerfile
+++ b/contrib/envvar/Dockerfile
@@ -1,7 +1,7 @@
 ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Extension build dependencies
+# Download and build extension
 ARG EXTENSION_NAME
 ARG EXTENSION_VERSION
 RUN curl -O https://api.pgxn.org/dist/${EXTENSION_NAME}/${EXTENSION_VERSION}/${EXTENSION_NAME}-${EXTENSION_VERSION}.zip \
diff --git a/contrib/extra_window_functions/Dockerfile b/contrib/extra_window_functions/Dockerfile
index 1350f6de..9542c2ef 100644
--- a/contrib/extra_window_functions/Dockerfile
+++ b/contrib/extra_window_functions/Dockerfile
@@ -1,12 +1,8 @@
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Clone repository
-RUN git clone https://github.com/xocolatl/extra_window_functions.git
-
-ARG RELEASE=v1.0
-
-RUN cd extra_window_functions && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "v$(perl -E 'print shift =~ s/[.]0$//gr' "${EXTENSION_VERSION}")" https://github.com/xocolatl/${EXTENSION_NAME}.git \
+    && make -C ${EXTENSION_NAME}
diff --git a/contrib/extra_window_functions/Trunk.toml b/contrib/extra_window_functions/Trunk.toml
index fc8ad556..174c41cc 100644
--- a/contrib/extra_window_functions/Trunk.toml
+++ b/contrib/extra_window_functions/Trunk.toml
@@ -14,9 +14,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd extra_window_functions && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C extra_window_functions install"
diff --git a/contrib/h3_pg/Dockerfile b/contrib/h3_pg/Dockerfile
index a4771392..0c3bf839 100644
--- a/contrib/h3_pg/Dockerfile
+++ b/contrib/h3_pg/Dockerfile
@@ -1,20 +1,13 @@
 # Set PostgreSQL version
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
 
 # Extension build dependencies
-RUN apt-get update && apt-get install -y \
-    cmake
-
-# Clone repository
-RUN git clone https://github.com/zachasme/h3-pg.git
-
-# Set project version
-ARG RELEASE=v4.1.4
+USER root
+RUN apt-get update && apt-get install -y cmake
 
-# Build extension
-RUN cd h3-pg && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+# ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "v${EXTENSION_VERSION}" https://github.com/zachasme/h3-pg.git \
+    && make -C h3-pg
\ No newline at end of file
diff --git a/contrib/h3_pg/Trunk.toml b/contrib/h3_pg/Trunk.toml
index 2dc7367f..ad3e020d 100644
--- a/contrib/h3_pg/Trunk.toml
+++ b/contrib/h3_pg/Trunk.toml
@@ -14,9 +14,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd h3-pg && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C h3-pg install"
diff --git a/contrib/mobilitydb/Dockerfile b/contrib/mobilitydb/Dockerfile
index b701be12..66b333d7 100644
--- a/contrib/mobilitydb/Dockerfile
+++ b/contrib/mobilitydb/Dockerfile
@@ -1,6 +1,6 @@
 ARG PG_VERSION
 # Set up iamge to copy trunk from.
-FROM quay.io/tembo/trunk-test-tembo:f3b2a28-pg15 AS trunk
+FROM quay.io/tembo/trunk-test-tembo:bdb0905-pg15 AS trunk
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
 USER root
diff --git a/contrib/pg-base62/Dockerfile b/contrib/pg-base62/Dockerfile
deleted file mode 100644
index 36a50734..00000000
--- a/contrib/pg-base62/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-ARG PG_VERSION=15
-FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
-
-# Extension build dependencies
-RUN apt-get update && apt-get install -y \
-	build-essential
-
-# Clone repository
-RUN git clone https://github.com/adjust/pg-base62.git
-
-RUN cd pg-base62 && make
\ No newline at end of file
diff --git a/contrib/pg-base62/Trunk.toml b/contrib/pg-base62/Trunk.toml
deleted file mode 100644
index 6f68c3e8..00000000
--- a/contrib/pg-base62/Trunk.toml
+++ /dev/null
@@ -1,24 +0,0 @@
-[extension]
-name = "pg_base62"
-extension_name = "base62"
-version = "0.0.1"
-repository = "https://github.com/adjust/pg-base62"
-license = "MIT"
-description = "base62 encoding and decoding"
-homepage = "https://github.com/adjust/pg-base62"
-documentation = "https://github.com/adjust/pg-base62"
-categories = ["data_transformations"]
-
-[dependencies]
-apt = ["libc6"]
-
-[build]
-postgres_version = "15"
-platform = "linux/amd64"
-dockerfile = "Dockerfile"
-install_command = """
-    cd pg-base62 && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
diff --git a/contrib/pg_embedding/Dockerfile b/contrib/pg_embedding/Dockerfile
index 4172efbf..b4a93675 100644
--- a/contrib/pg_embedding/Dockerfile
+++ b/contrib/pg_embedding/Dockerfile
@@ -1,8 +1,8 @@
-ARG PG_VERSION=15
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
 
 # Extension build dependencies
+USER root
 RUN apt-get update && apt-get install -y \
 	build-essential \
 	libreadline-dev \
@@ -15,18 +15,8 @@ RUN apt-get update && apt-get install -y \
 	xsltproc \
 	ccache
 
-# Clone repository
-RUN git clone https://github.com/postgres/postgres.git
-
-ARG PG_RELEASE=REL_15_3
-
-# Build extension
-RUN cd postgres && \
-	git fetch origin ${PG_RELEASE} && \
-	git checkout ${PG_RELEASE} && \
-	./configure && \
-	cd contrib && \
-	git clone https://github.com/neondatabase/pg_embedding.git && \
-	cd pg_embedding && \
-    git checkout 710f44d && \
-	make USE_PGXS=1
+# Clone and build the extension.
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "${EXTENSION_VERSION}" https://github.com/neondatabase/${EXTENSION_NAME}.git \
+    && make -C ${EXTENSION_NAME} USE_PGXS=1
diff --git a/contrib/pg_embedding/Trunk.toml b/contrib/pg_embedding/Trunk.toml
index 8588b237..25f8dd87 100644
--- a/contrib/pg_embedding/Trunk.toml
+++ b/contrib/pg_embedding/Trunk.toml
@@ -1,6 +1,6 @@
 [extension]
 name = "pg_embedding"
-version = "0.2.0"
+version = "0.3.6"
 repository = "https://github.com/neondatabase/pg_embedding"
 license = "PostgreSQL"
 description = "The pg_embedding extension enables the use of the Hierarchical Navigable Small World (HNSW) algorithm for vector similarity search in PostgreSQL."
@@ -13,12 +13,7 @@ categories = ["machine_learning"]
 apt = ["libc6", "libgcc-s1", "libstdc++6"]
 
 [build]
-postgres_version = "15"
+postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd postgres/contrib/pg_embedding && make USE_PGXS=1 install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C pg_embedding USE_PGXS=1 install"
diff --git a/contrib/pg_ivm/Dockerfile b/contrib/pg_ivm/Dockerfile
index 030e63e2..a50572ba 100644
--- a/contrib/pg_ivm/Dockerfile
+++ b/contrib/pg_ivm/Dockerfile
@@ -1,12 +1,8 @@
-ARG PG_VERSION=17
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Clone repository
-RUN git clone https://github.com/sraoss/pg_ivm.git
-
-ARG RELEASE=v1.9
-
-RUN cd pg_ivm && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "v$(perl -E 'print shift =~ s/[.]0$//gr' "${EXTENSION_VERSION}")" https://github.com/sraoss/${EXTENSION_NAME}.git \
+    && make -C ${EXTENSION_NAME}
diff --git a/contrib/pg_ivm/Trunk.toml b/contrib/pg_ivm/Trunk.toml
index de92611f..8e2a737a 100644
--- a/contrib/pg_ivm/Trunk.toml
+++ b/contrib/pg_ivm/Trunk.toml
@@ -15,9 +15,4 @@ apt = ["libc6"]
 postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd pg_ivm && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C pg_ivm install"
diff --git a/contrib/pgbase36/Dockerfile b/contrib/pgbase36/Dockerfile
deleted file mode 100644
index ed85603d..00000000
--- a/contrib/pgbase36/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-ARG PG_VERSION=15
-FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
-
-# Extension build dependencies
-RUN apt-get update && apt-get install -y \
-	build-essential
-
-# Clone repository
-RUN git clone https://github.com/adjust/pg-base36.git
-
-RUN cd pg-base36 && make
\ No newline at end of file
diff --git a/contrib/pgbase36/Trunk.toml b/contrib/pgbase36/Trunk.toml
deleted file mode 100644
index 5219bcc0..00000000
--- a/contrib/pgbase36/Trunk.toml
+++ /dev/null
@@ -1,24 +0,0 @@
-[extension]
-name = "pg_base36"
-extension_name = "base36"
-version = "0.0.1"
-repository = "https://github.com/adjust/pg-base36"
-license = "MIT"
-description = "base36 encoding and decoding"
-homepage = "https://github.com/adjust/pg-base36"
-documentation = "https://github.com/adjust/pg-base36"
-categories = ["data_transformations"]
-
-[dependencies]
-apt = ["libc6"]
-
-[build]
-postgres_version = "15"
-platform = "linux/amd64"
-dockerfile = "Dockerfile"
-install_command = """
-    cd pg-base36 && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
\ No newline at end of file
diff --git a/contrib/pgroonga/Dockerfile b/contrib/pgroonga/Dockerfile
index af66f6be..a2e8ad8c 100644
--- a/contrib/pgroonga/Dockerfile
+++ b/contrib/pgroonga/Dockerfile
@@ -1,31 +1,25 @@
 # Set PostgreSQL version
-ARG PG_VERSION=15
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
-USER root
 
 # Extension build dependencies
+USER root
 RUN apt-get update && apt-get install -y \
     wget tar build-essential zlib1g-dev liblzo2-dev libxxhash-dev \
     libmsgpack-dev libzmq3-dev libevent-dev libmecab-dev
 
-# Build Groonga 13.0.4
-RUN wget https://packages.groonga.org/source/groonga/groonga-13.0.4.tar.gz \
-    && tar xvzf groonga-13.0.4.tar.gz \
-    && cd groonga-13.0.4 \
+# Build Groonga 14.1.2
+RUN curl -LO https://packages.groonga.org/source/groonga/groonga-14.1.2.tar.gz \
+    && tar xvzf groonga-14.1.2.tar.gz \
+    && cd groonga-14.1.2 \
     && ./configure \
     && make -j$(grep '^processor' /proc/cpuinfo | wc -l) \
     && make install
 
-# Download and decompress the release's archive
-RUN curl -L -o pgroonga.tar.gz https://github.com/pgroonga/pgroonga/archive/refs/tags/3.1.1.tar.gz \
-    && mkdir pgroonga \
-    && tar -xzvf pgroonga.tar.gz -C pgroonga --strip-components=1 \
-    && cd pgroonga/vendor/ \
-    && git clone https://github.com/Cyan4973/xxHash
-
-# Set project version
-ARG RELEASE=3.1.1
-
-# Build extension
-RUN cd pgroonga \
-    && make
\ No newline at end of file
+# Download and build extension
+ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN curl -LO https://github.com/${EXTENSION_NAME}/${EXTENSION_NAME}/releases/download/${EXTENSION_VERSION}/${EXTENSION_NAME}-${EXTENSION_VERSION}.tar.gz \
+    && tar zxf ${EXTENSION_NAME}-${EXTENSION_VERSION}.tar.gz \
+    && cd ${EXTENSION_NAME}-${EXTENSION_VERSION} && make
+WORKDIR /app/${EXTENSION_NAME}-${EXTENSION_VERSION}
diff --git a/contrib/pgroonga/Trunk.toml b/contrib/pgroonga/Trunk.toml
index 242158e1..88df34ac 100644
--- a/contrib/pgroonga/Trunk.toml
+++ b/contrib/pgroonga/Trunk.toml
@@ -1,6 +1,6 @@
 [extension]
 name = "pgroonga"
-version = "3.1.1"
+version = "3.2.5"
 repository = "https://github.com/pgroonga/pgroonga"
 license = "PostgreSQL"
 description = "PGroonga makes PostgreSQL fast full text search platform for all languages."
@@ -8,15 +8,10 @@ documentation = "https://pgroonga.github.io/"
 categories = ["search"]
 
 [dependencies]
-apt = ["libgroonga0", "libc6"]
+apt = ["libc6"]
 
 [build]
-postgres_version = "15"
+postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd pgroonga && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make install"
diff --git a/contrib/postgresql_unit/Dockerfile b/contrib/postgresql_unit/Dockerfile
index ce8492f3..13d6360e 100644
--- a/contrib/postgresql_unit/Dockerfile
+++ b/contrib/postgresql_unit/Dockerfile
@@ -1,12 +1,13 @@
-ARG PG_VERSION=15
+ARG PG_VERSION
 FROM quay.io/coredb/c-builder:pg${PG_VERSION}
 
-# Clone repository
-RUN git clone https://github.com/df7cb/postgresql-unit.git
-
-ARG RELEASE=7.7
-
-RUN cd postgresql-unit && \
-    git fetch origin ${RELEASE} && \
-    git checkout ${RELEASE} && \
-    make
+# Clone and build the extension.
+# ARG EXTENSION_NAME
+ARG EXTENSION_VERSION
+RUN git clone --depth 1 --branch "$(perl -E 'print shift =~ s/[.]0$//gr' "${EXTENSION_VERSION}")" https://github.com/df7cb/postgresql-unit.git \
+    # Build .sql files to point to the Tembo image share directory before
+    # building everything else. Forces these lines to have the values we need:
+    # https://github.com/df7cb/postgresql-unit/blob/7.10/Makefile#L44-L45
+    && make -C postgresql-unit datadir=/var/lib/postgresql/data/tembo/extension *.sql \
+    # Build everything else as usual.
+    && make -C postgresql-unit
diff --git a/contrib/postgresql_unit/Trunk.toml b/contrib/postgresql_unit/Trunk.toml
index 97a66c92..8251299d 100644
--- a/contrib/postgresql_unit/Trunk.toml
+++ b/contrib/postgresql_unit/Trunk.toml
@@ -1,6 +1,6 @@
 [extension]
 name = "postgresql_unit"
-version = "7.0.0"
+version = "7.10.0"
 repository = "https://github.com/df7cb/postgresql-unit"
 license = "Copyright"
 description = "SI Units for PostgreSQL."
@@ -11,12 +11,9 @@ categories = ["analytics"]
 apt = ["libc6"]
 
 [build]
-postgres_version = "15"
+postgres_version = "17"
 platform = "linux/amd64"
 dockerfile = "Dockerfile"
-install_command = """
-    cd postgresql-unit && make install
-    set -x
-    mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension
-    mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
-    """
+install_command = "make -C postgresql-unit install"
+# Tell trunk to include unit_prefixes.data and unit_units.data.
+include = ["*.data"]