From: Daniele Varrazzo Date: Mon, 13 Jun 2022 07:12:01 +0000 (+0200) Subject: build: cache libpq build X-Git-Tag: 3.1~57^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5fd893515fb1c0b7f3cd2a019730f7ee44dff61;p=thirdparty%2Fpsycopg.git build: cache libpq build --- diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index e14020862..f1c9f4b3b 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -93,6 +93,12 @@ jobs: - name: Set up QEMU for multi-arch build uses: docker/setup-qemu-action@v1 + - name: Cache libpq build + uses: actions/cache@v3 + with: + path: /tmp/libpq.build + key: libpq-14.3-${{ matrix.platform }}-${{ matrix.arch }}-1 + - name: Create the binary package source tree run: python3 ./tools/build/copy_to_binary.py @@ -118,6 +124,9 @@ jobs: PSYCOPG_IMPL=binary PSYCOPG_TEST_DSN='host=172.17.0.1 user=postgres' PGPASSWORD=password + LIBPQ_BUILD_PREFIX=/host/tmp/libpq.build + PATH="$LIBPQ_BUILD_PREFIX/bin:$PATH" + LD_LIBRARY_PATH="$LIBPQ_BUILD_PREFIX/lib" - uses: actions/upload-artifact@v2 with: diff --git a/tools/build/build_libpq.sh b/tools/build/build_libpq.sh index 5f3188150..e098ba7c0 100755 --- a/tools/build/build_libpq.sh +++ b/tools/build/build_libpq.sh @@ -5,10 +5,18 @@ set -euo pipefail set -x +# IMPORTANT! Change the cache key in packages.yml when upgrading libraries +postgres_version="14.3" openssl_version="1.1.1o" ldap_version="2.6.2" sasl_version="2.1.28" -postgres_version="14.3" + +export LIBPQ_BUILD_PREFIX=${LIBPQ_BUILD_PREFIX:-/tmp/libpq.build} + +if [[ -f "${LIBPQ_BUILD_PREFIX}/lib/libpq.so" ]]; then + echo "libpq already available: build skipped" >&2 + exit 0 +fi source /etc/os-release @@ -38,7 +46,7 @@ if [ "$ID" == "centos" ]; then cd "${openssl_dir}" - ./config --prefix=/usr/local/ --openssldir=/usr/local/ \ + ./config --prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \ zlib -fPIC shared make depend make @@ -69,7 +77,7 @@ if [ "$ID" == "centos" ]; then cd "${sasl_dir}" autoreconf -i - ./configure + ./configure --prefix=${LIBPQ_BUILD_PREFIX} make else cd "${sasl_dir}" @@ -96,7 +104,7 @@ if [ "$ID" == "centos" ]; then cd "${ldap_dir}" - ./configure --enable-backends=no --enable-null + ./configure --prefix=${LIBPQ_BUILD_PREFIX} --enable-backends=no --enable-null make depend make -C libraries/liblutil/ make -C libraries/liblber/ @@ -109,7 +117,7 @@ if [ "$ID" == "centos" ]; then make -C libraries/liblber/ install make -C libraries/libldap/ install make -C include/ install - chmod +x /usr/local/lib/{libldap,liblber}*.so* + chmod +x ${LIBPQ_BUILD_PREFIX}/lib/{libldap,liblber}*.so* cd .. fi @@ -131,13 +139,12 @@ if [ ! -d "${postgres_dir}" ]; then '|#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"|' \ src/include/pg_config_manual.h - # Without this, libpq ./configure fails on i686 - if [[ "$(uname -m)" != "x86_64" ]]; then - export LD_LIBRARY_PATH=/usr/local/lib - fi + # Often needed, but currently set by the workflow + # export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib" - ./configure --prefix=/usr/local --sysconfdir=/etc/postgresql-common \ - --without-readline --with-gssapi --with-openssl --with-pam --with-ldap + ./configure --prefix=${LIBPQ_BUILD_PREFIX} --sysconfdir=/etc/postgresql-common \ + --without-readline --with-gssapi --with-openssl --with-pam --with-ldap \ + CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib make -C src/interfaces/libpq make -C src/bin/pg_config make -C src/include @@ -151,4 +158,4 @@ make -C src/bin/pg_config install make -C src/include install cd .. -find /usr/local/ -name \*.so.\* -type f -exec strip --strip-unneeded {} \; +find ${LIBPQ_BUILD_PREFIX} -name \*.so.\* -type f -exec strip --strip-unneeded {} \;