]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
ci: more robust libpq build script
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 23 Jun 2024 21:46:24 +0000 (23:46 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 26 Jun 2024 13:02:00 +0000 (15:02 +0200)
tools/build/build_libpq.sh
tools/build/wheel_linux_before_all.sh

index 52bd0e1e42f750af0a4c57f660cb91979a286f12..2a14e23b4c5300f919efc319c6e310b2e40cca1f 100755 (executable)
@@ -46,32 +46,36 @@ case "$ID" in
 esac
 
 if [ "$ID" == "centos" ]; then
+  if [[ ! -f "${LIBPQ_BUILD_PREFIX}/openssl.cnf" ]]; then
 
     # Build openssl if needed
     openssl_tag="OpenSSL_${openssl_version//./_}"
     openssl_dir="openssl-${openssl_tag}"
-    if [ ! -d "${openssl_dir}" ]; then curl -sL \
+    if [ ! -d "${openssl_dir}" ]; then
+        curl -fsSL \
             https://github.com/openssl/openssl/archive/${openssl_tag}.tar.gz \
             | tar xzf -
 
-        cd "${openssl_dir}"
+        pushd "${openssl_dir}"
 
         ./config --prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \
             zlib -fPIC shared
         make depend
         make
     else
-        cd "${openssl_dir}"
+        pushd "${openssl_dir}"
     fi
 
     # Install openssl
     make install_sw
-    cd ..
+    popd
 
+  fi
 fi
 
 
 if [ "$ID" == "centos" ]; then
+  if [[ ! -f "${LIBPQ_BUILD_PREFIX}/lib/libsasl2.so" ]]; then
 
     # Build libsasl2 if needed
     # The system package (cyrus-sasl-devel) causes an amazing error on i686:
@@ -80,40 +84,42 @@ if [ "$ID" == "centos" ]; then
     sasl_tag="cyrus-sasl-${sasl_version}"
     sasl_dir="cyrus-sasl-${sasl_tag}"
     if [ ! -d "${sasl_dir}" ]; then
-        curl -sL \
+        curl -fsSL \
             https://github.com/cyrusimap/cyrus-sasl/archive/${sasl_tag}.tar.gz \
             | tar xzf -
 
-        cd "${sasl_dir}"
+        pushd "${sasl_dir}"
 
         autoreconf -i
         ./configure --prefix=${LIBPQ_BUILD_PREFIX} \
             CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
         make
     else
-        cd "${sasl_dir}"
+        pushd "${sasl_dir}"
     fi
 
     # Install libsasl2
     # requires missing nroff to build
     touch saslauthd/saslauthd.8
     make install
-    cd ..
+    popd
 
+  fi
 fi
 
 
 if [ "$ID" == "centos" ]; then
+  if [[ ! -f "${LIBPQ_BUILD_PREFIX}/lib/libldap.so" ]]; then
 
     # Build openldap if needed
     ldap_tag="${ldap_version}"
     ldap_dir="openldap-${ldap_tag}"
     if [ ! -d "${ldap_dir}" ]; then
-        curl -sL \
+        curl -fsSL \
             https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-${ldap_tag}.tgz \
             | tar xzf -
 
-        cd "${ldap_dir}"
+        pushd "${ldap_dir}"
 
         ./configure --prefix=${LIBPQ_BUILD_PREFIX} --enable-backends=no --enable-null \
             CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
@@ -123,7 +129,7 @@ if [ "$ID" == "centos" ]; then
         make -C libraries/liblber/
         make -C libraries/libldap/
     else
-        cd "${ldap_dir}"
+        pushd "${ldap_dir}"
     fi
 
     # Install openldap
@@ -131,8 +137,9 @@ if [ "$ID" == "centos" ]; then
     make -C libraries/libldap/ install
     make -C include/ install
     chmod +x ${LIBPQ_BUILD_PREFIX}/lib/{libldap,liblber}*.so*
-    cd ..
+    popd
 
+  fi
 fi
 
 
@@ -140,11 +147,11 @@ fi
 postgres_tag="REL_${postgres_version//./_}"
 postgres_dir="postgres-${postgres_tag}"
 if [ ! -d "${postgres_dir}" ]; then
-    curl -sL \
+    curl -fsSL \
         https://github.com/postgres/postgres/archive/${postgres_tag}.tar.gz \
         | tar xzf -
 
-    cd "${postgres_dir}"
+    pushd "${postgres_dir}"
 
     # Match the default unix socket dir default with what defined on Ubuntu and
     # Red Hat, which seems the most common location
@@ -163,13 +170,13 @@ if [ ! -d "${postgres_dir}" ]; then
     make -C src/bin/pg_config
     make -C src/include
 else
-    cd "${postgres_dir}"
+    pushd "${postgres_dir}"
 fi
 
 # Install libpq
 make -C src/interfaces/libpq install
 make -C src/bin/pg_config install
 make -C src/include install
-cd ..
+popd
 
 find ${LIBPQ_BUILD_PREFIX} -name \*.so.\* -type f -exec strip --strip-unneeded {} \;
index ac5469aae2a4a0da59ad313bc2634158014b7068..5fe6b07279df8bebe14015609e7079e9ad50d7b8 100755 (executable)
@@ -27,7 +27,7 @@ case "$ID" in
             # TODO: On 2021-11-09 curl fails on 'ppc64le' with:
             #   curl: (60) SSL certificate problem: certificate has expired
             # Test again later if -k can be removed.
-            curl -skf https://www.postgresql.org/media/keys/ACCC4CF8.asc \
+            curl -fsSLk https://www.postgresql.org/media/keys/ACCC4CF8.asc \
                 > /etc/apt/trusted.gpg.d/postgresql.asc
         fi