From: Denis Laxalde Date: Sat, 7 Jan 2023 18:50:37 +0000 (+0100) Subject: ci: install the "oldest" libpq from pgdg repository X-Git-Tag: 3.1.8~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc42d7fa5fa1ab1af56d255c9402acf3c70690e6;p=thirdparty%2Fpsycopg.git ci: install the "oldest" libpq from pgdg repository --- diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e9ee92d80..7660f4049 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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' }} diff --git a/tools/build/ci_install_libpq.sh b/tools/build/ci_install_libpq.sh index 64b782414..55525e37d 100755 --- a/tools/build/ci_install_libpq.sh +++ b/tools/build/ci_install_libpq.sh @@ -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}" ;; *)