]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
ci: install the "oldest" libpq from pgdg repository
authorDenis Laxalde <denis@laxalde.org>
Sat, 7 Jan 2023 18:50:37 +0000 (19:50 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 9 Jan 2023 08:22:49 +0000 (08:22 +0000)
.github/workflows/tests.yml
tools/build/ci_install_libpq.sh

index e9ee92d8075e0f5f833c25e3d4b0e40ae87ab125..7660f4049f17e4956e15f2a068eba9f827e4006e 100644 (file)
@@ -67,7 +67,7 @@ jobs:
             -c max_prepared_transactions=10
 
       - name: Install the wanted libpq version
-        run: ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }}
+        run: sudo ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }}
 
       - name: Include psycopg-c to the packages to install
         if: ${{ matrix.impl == 'c' }}
@@ -258,7 +258,7 @@ jobs:
             cockroachdb/cockroach:${{ matrix.crdb }} start-single-node --insecure
 
       - name: Install the wanted libpq version
-        run: ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }}
+        run: sudo ./tools/build/ci_install_libpq.sh ${{ matrix.libpq }}
 
       - name: Include psycopg-c to the packages to install
         if: ${{ matrix.impl == 'c' }}
index 64b78241408b504a535966f7766ce8936494b691..55525e37dbc07f7ffadba20fa98ee9321dac3ad5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Install the desired libpw in github action (Linux runner)
+# Install the desired libpq in github action (Linux runner)
 #
 # Specify `oldest` or `newest` as first argument in order to choose the oldest
 # available to the debian distro or the newest available from the pgdg ppa.
@@ -9,6 +9,16 @@ set -euo pipefail
 set -x
 
 libpq=${1:-}
+rel=$(lsb_release -c -s)
+
+setup_repo () {
+    version=${1:-}
+    curl -sL -o /etc/apt/trusted.gpg.d/apt.postgresql.org.asc \
+        https://www.postgresql.org/media/keys/ACCC4CF8.asc
+    echo "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main ${version}" \
+        >> /etc/apt/sources.list.d/pgdg.list
+    apt-get -qq update
+}
 
 case "$libpq" in
     "")
@@ -18,26 +28,15 @@ case "$libpq" in
         ;;
 
     oldest)
+        setup_repo 10
         pqver=$(apt-cache show libpq5 | grep ^Version: | tail -1 | awk '{print $2}')
-        sudo apt-get -qq -y --allow-downgrades install \
-            "libpq-dev=${pqver}" "libpq5=${pqver}"
+        apt-get -qq -y --allow-downgrades install "libpq-dev=${pqver}" "libpq5=${pqver}"
         ;;
 
     newest)
-        curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
-            | gpg --dearmor \
-            | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null
-
-        # NOTE: in order to test with a preview release, add its number to
-        # the deb entry. For instance, to test on preview Postgres 16, use:
-        # "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main 16"
-        rel=$(lsb_release -c -s)
-        echo "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main" \
-            | sudo tee -a /etc/apt/sources.list.d/pgdg.list > /dev/null
-        sudo apt-get -qq update
-
+        setup_repo
         pqver=$(apt-cache show libpq5 | grep ^Version: | head -1 | awk '{print $2}')
-        sudo apt-get -qq -y install "libpq-dev=${pqver}" "libpq5=${pqver}"
+        apt-get -qq -y install "libpq-dev=${pqver}" "libpq5=${pqver}"
         ;;
 
     *)