From f2d5682b8632a312fa06145b19879da676eb82d1 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 14:09:47 +0000 Subject: [PATCH 1/6] set correct rustup target for alpine Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 8 ++------ scripts/build-postgres-darwin.sh | 13 ++++++++++++- scripts/build-postgres-debian.sh | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index 514da270..e879348d 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -95,14 +95,10 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries readline-dev \ libxml2-utils \ ccache \ - zlib-dev \ - libxslt-dev \ g++ \ libgcrypt \ - openssl-dev \ musl-dev \ build-base \ - libressl-dev \ musl \ musl-dev \ \ @@ -194,12 +190,12 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ && . "$HOME/.cargo/env" \ && export PATH="/usr/local/pg-build/bin:${PATH}" \ - && rustup target add x86_64-unknown-linux-gnu \ + && rustup target add x86_64-unknown-linux-musl \ && cargo install --version "=0.10.2" --force cargo-pgrx \ && cargo pgrx init --$pgrx_flag pg_config \ && git clone https://github.com/timescale/timescaledb-toolkit && cd timescaledb-toolkit/extension \ && git checkout 1.18.0 \ - && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ + && cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ ; fi \ \ && cd /usr/local/pg-build \ diff --git a/scripts/build-postgres-darwin.sh b/scripts/build-postgres-darwin.sh index 5507745a..fc5df9c6 100755 --- a/scripts/build-postgres-darwin.sh +++ b/scripts/build-postgres-darwin.sh @@ -7,7 +7,7 @@ # not really understanding it. Just run it direcly and it should make # the .zip file for manual upload to github releases. -PG_VERSION=14.1 +PG_VERSION=16.4 TIMESCALE_VERSION=2.6.0 ARCH=$(uname -m) @@ -54,6 +54,17 @@ find $PREFIX/lib -type f -name "*.so" | \ cd $PREFIX +# install cargo, compile the toolkit +curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +. "$HOME/.cargo/env" +export PATH="${PREFIX}/bin:${PATH}" +rustup target add x86_64-unknown-linux-gnu +cargo install --version "=0.10.2" --force cargo-pgrx +cargo pgrx init --pg16 pg_config +git clone https://github.com/timescale/timescaledb-toolkit && cd timescaledb-toolkit/extension +git checkout 1.18.0 +RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release +cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config # Tar it up tar -cJvf ../embedded-postgres-binaries-darwin-${ARCH}-${PG_VERSION}.0.txz \ share/* \ diff --git a/scripts/build-postgres-debian.sh b/scripts/build-postgres-debian.sh index fd5c8ee2..f5f08eb6 100755 --- a/scripts/build-postgres-debian.sh +++ b/scripts/build-postgres-debian.sh @@ -184,7 +184,7 @@ $DOCKER_OPTS $IMG_NAME /bin/bash -ex -c 'echo "Starting building postgres binari && cargo pgrx init --$pgrx_flag pg_config \ && git clone https://github.com/timescale/timescaledb-toolkit && cd timescaledb-toolkit/extension \ && git checkout 1.18.0 \ - && cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ + && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ ; fi \ \ && cd /usr/local/pg-build \ From 78e12de1ad9bbdadb480bb6e894ec72bba5c9e8f Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 14:34:50 +0000 Subject: [PATCH 2/6] add rustflags required for musl Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index e879348d..0027a5f6 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -101,6 +101,9 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries build-base \ musl \ musl-dev \ + lld \ + libressl-dev \ + libffi-dev \ \ && if [ "$E2FS_ENABLED" = false ]; then \ wget -O uuid.tar.gz "https://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz" \ @@ -195,7 +198,7 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries && cargo pgrx init --$pgrx_flag pg_config \ && git clone https://github.com/timescale/timescaledb-toolkit && cd timescaledb-toolkit/extension \ && git checkout 1.18.0 \ - && cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ + && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ ; fi \ \ && cd /usr/local/pg-build \ From 0bb856f9c5396bcfc8b4a03501ca95b5673c4c6e Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 16:23:49 +0000 Subject: [PATCH 3/6] fix cargo build Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index 0027a5f6..455fb148 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -194,15 +194,17 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries && . "$HOME/.cargo/env" \ && export PATH="/usr/local/pg-build/bin:${PATH}" \ && rustup target add x86_64-unknown-linux-musl \ - && cargo install --version "=0.10.2" --force cargo-pgrx \ - && cargo pgrx init --$pgrx_flag pg_config \ + && RUSTFLAGS="-C target-feature=-crt-static" cargo install --version "=0.10.2" --force cargo-pgrx \ + && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx init --$pgrx_flag pg_config \ && git clone https://github.com/timescale/timescaledb-toolkit && cd timescaledb-toolkit/extension \ && git checkout 1.18.0 \ - && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release && cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ + && RUSTFLAGS="-C target-feature=-crt-static" cargo pgrx install --release && RUSTFLAGS="-C target-feature=-crt-static" cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config \ ; fi \ \ && cd /usr/local/pg-build \ - && cp /lib/libuuid.so.1 /lib/libz.so.1 /lib/libssl.so.1.0.0 /lib/libcrypto.so.1.0.0 /usr/lib/libxml2.so.2 /usr/lib/libxslt.so.1 ./lib \ + && cp /lib/libuuid.so.1 /lib/libz.so.1 /usr/lib/libxml2.so.2 /usr/lib/libxslt.so.1 ./lib \ + && [ -f "/lib/libssl.so.1.0.0" ] && cp /lib/libssl.so.1.0.0 ./lib \ + && [ -f "/lib/libcrypto.so.1.0.0" ] && cp /lib/libcrypto.so.1.0.0 ./lib \ && if [ "$ICU_ENABLED" = true ]; then cp --no-dereference /usr/lib/libicudata.so* /usr/lib/libicuuc.so* /usr/lib/libicui18n.so* /usr/lib/libstdc++.so* /usr/lib/libgcc_s.so* ./lib; fi \ && if [ -n "$POSTGIS_VERSION" ]; then cp --no-dereference /usr/lib/libjson-c.so* /usr/lib/libsqlite3.so* ./lib ; fi \ && find ./bin -type f \( -name "initdb" -o -name "pg_ctl" -o -name "postgres" \) -print0 | xargs -0 -n1 chrpath -r "\$ORIGIN/../lib" \ From 7e93a08d2c51adf25c712d1eea42d07e80fed19b Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 16:56:37 +0000 Subject: [PATCH 4/6] fix copying shared objects by removing them, add a tree + grep in case we find them Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index 455fb148..757d6f40 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -203,8 +203,16 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries \ && cd /usr/local/pg-build \ && cp /lib/libuuid.so.1 /lib/libz.so.1 /usr/lib/libxml2.so.2 /usr/lib/libxslt.so.1 ./lib \ - && [ -f "/lib/libssl.so.1.0.0" ] && cp /lib/libssl.so.1.0.0 ./lib \ - && [ -f "/lib/libcrypto.so.1.0.0" ] && cp /lib/libcrypto.so.1.0.0 ./lib \ + && tree /lib | grep libssl \ + && tree /lib | grep libcrypto \ + && if [ -f "/lib/libssl.so.1.0.0" ]; then \ + cp /lib/libssl.so.1.0.0 ./lib \ + ; fi \ + \ + && if [ -f "/lib/libcrypto.so.1.0.0" ]; then \ + cp /lib/libcrypto.so.1.0.0 ./lib \ + ; fi \ + \ && if [ "$ICU_ENABLED" = true ]; then cp --no-dereference /usr/lib/libicudata.so* /usr/lib/libicuuc.so* /usr/lib/libicui18n.so* /usr/lib/libstdc++.so* /usr/lib/libgcc_s.so* ./lib; fi \ && if [ -n "$POSTGIS_VERSION" ]; then cp --no-dereference /usr/lib/libjson-c.so* /usr/lib/libsqlite3.so* ./lib ; fi \ && find ./bin -type f \( -name "initdb" -o -name "pg_ctl" -o -name "postgres" \) -print0 | xargs -0 -n1 chrpath -r "\$ORIGIN/../lib" \ From 0474a0915719c25f03cc008c60e293e99dc18265 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 17:10:18 +0000 Subject: [PATCH 5/6] tree command missing Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index 757d6f40..ba08237f 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -104,6 +104,7 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries lld \ libressl-dev \ libffi-dev \ + tree \ \ && if [ "$E2FS_ENABLED" = false ]; then \ wget -O uuid.tar.gz "https://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz" \ From 6d92882ad2ca3cb1752fd6c331eb6d2f8c9801d6 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 30 Oct 2024 17:25:42 +0000 Subject: [PATCH 6/6] copy over the correct shared objects Signed-off-by: Elias Van Ootegem --- scripts/build-postgres-alpine.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/build-postgres-alpine.sh b/scripts/build-postgres-alpine.sh index ba08237f..aaf74a42 100755 --- a/scripts/build-postgres-alpine.sh +++ b/scripts/build-postgres-alpine.sh @@ -204,14 +204,12 @@ $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries \ && cd /usr/local/pg-build \ && cp /lib/libuuid.so.1 /lib/libz.so.1 /usr/lib/libxml2.so.2 /usr/lib/libxslt.so.1 ./lib \ - && tree /lib | grep libssl \ - && tree /lib | grep libcrypto \ - && if [ -f "/lib/libssl.so.1.0.0" ]; then \ - cp /lib/libssl.so.1.0.0 ./lib \ + && if [ -f "/lib/libssl.so.1.1" ]; then \ + cp /lib/libssl.so.1.1 ./lib \ ; fi \ \ - && if [ -f "/lib/libcrypto.so.1.0.0" ]; then \ - cp /lib/libcrypto.so.1.0.0 ./lib \ + && if [ -f "/lib/libcrypto.so.1.1" ]; then \ + cp /lib/libcrypto.so.1.1 ./lib \ ; fi \ \ && if [ "$ICU_ENABLED" = true ]; then cp --no-dereference /usr/lib/libicudata.so* /usr/lib/libicuuc.so* /usr/lib/libicui18n.so* /usr/lib/libstdc++.so* /usr/lib/libgcc_s.so* ./lib; fi \