From 30dcd6b5b8167db5d9367830bcccfff32ec262ee Mon Sep 17 00:00:00 2001 From: Shuai Tian Date: Thu, 16 Jan 2025 05:04:37 +0000 Subject: [PATCH] Merged PR 1533455: [oss] Declare and use fixed version of packages ### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description In oss, we noticed frequently sql test result difference introduced by newer package minor versions (postgres, pgvector, postgis, etc). To make oss CI integration stable and to make test result consistent in oss and pgmongo, we should specify fixed versions for packages in oss, and align with pgmongo. Will depend on manual package version update after verifying the compatibility and meanwhile update test results. ---- #### AI description (iteration 1) #### PR Classification Code cleanup and enhancement. #### PR Summary This pull request declares and uses fixed versions of various packages to ensure consistency and reliability in the build environment. - Updated `/oss/.devcontainer/Dockerfile` to declare and use fixed versions for multiple dependencies including PostgreSQL, Citus, libbson, PG_CRON, PG_VECTOR, Intel Decimal Math Library, PCRE2, and PostGIS. - Modified `/.devcontainer/Dockerfile` to align with the fixed versioning approach and added necessary environment variables. - Added `GetPostgresSourceRef` function in `oss/scripts/utils.sh` to map PostgreSQL versions to specific source references. - Updated `oss/scripts/install_setup_intel_decimal_math_lib.sh` and `oss/scripts/install_setup_pcre2.sh` to accept version parameters. - Moved several scripts from `/scripts` to `/oss/scripts` for better organization. Related work items: #3571853 --- .devcontainer/Dockerfile | 109 +++++++++++++----- scripts/install_setup_citus_core_oss.sh | 55 +++++++++ .../install_setup_intel_decimal_math_lib.sh | 22 +++- scripts/install_setup_libbson.sh | 14 ++- scripts/install_setup_pcre2.sh | 22 +++- scripts/install_setup_pg_cron.sh | 49 ++++++++ scripts/install_setup_pgvector.sh | 52 +++++++++ scripts/install_setup_postgis.sh | 67 +++++++++++ scripts/install_setup_postgres.sh | 96 +++++++++++++++ scripts/install_setup_rum_oss.sh | 54 +++++++++ scripts/install_setup_system_rows.sh | 49 ++++++++ scripts/setup_versions.sh | 85 ++++++++++++++ scripts/utils.sh | 17 +++ 13 files changed, 654 insertions(+), 37 deletions(-) create mode 100755 scripts/install_setup_citus_core_oss.sh create mode 100755 scripts/install_setup_pg_cron.sh create mode 100755 scripts/install_setup_pgvector.sh create mode 100755 scripts/install_setup_postgis.sh create mode 100755 scripts/install_setup_postgres.sh create mode 100755 scripts/install_setup_rum_oss.sh create mode 100755 scripts/install_setup_system_rows.sh create mode 100755 scripts/setup_versions.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a2560e10..6dd4db00 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,13 +5,9 @@ ARG CITUS_VERSION= # declare installed PG version and Citus version ENV PG_VERSION=16 -ENV CITUS_VERSION=12.1 - -ENV LC_ALL=en_US.UTF-8 -ENV LANGUAGE=en_US -ENV LC_COLLATE=en_US.UTF-8 -ENV LC_CTYPE=en_US.UTF-8 +ENV CITUS_VERSION=12 +# Install build essentials - Compiler, debugger, make, etc. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get install -qy \ wget \ @@ -24,6 +20,21 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ pkg-config \ cmake \ git \ + locales \ + gcc \ + gdb \ + libipc-run-perl \ + unzip \ + apt-transport-https \ + bison \ + flex \ + libreadline-dev \ + zlib1g-dev \ + libkrb5-dev \ + software-properties-common \ + libtool \ + libicu-dev \ + libssl-dev \ && rm -rf /var/lib/apt/lists/* # Add pgdg repo @@ -32,36 +43,78 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg m apt-get update && \ rm -rf /var/lib/apt/lists/* -RUN curl -4sSf https://packagecloud.io/install/repositories/citusdata/community/script.deb.sh | bash - -RUN apt-get update && DEBIAN_FRONTEND=noninteractive \ - && apt-get install -y \ - postgresql-${PG_VERSION} \ - postgresql-server-dev-${PG_VERSION} \ - libpq-dev \ - libicu-dev \ - libkrb5-dev \ - postgresql-${PG_VERSION}-cron \ - postgresql-${PG_VERSION}-pgvector \ - postgresql-${PG_VERSION}-postgis-3 \ - postgresql-${PG_VERSION}-rum \ - postgresql-${PG_VERSION}-citus-${CITUS_VERSION} \ - && rm -rf /var/lib/apt/lists/* - -# Install Libbson, decimal128, pcre +# Prepare for running install scripts ENV CLEANUP_SETUP=1 ENV INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup RUN mkdir -p /tmp/install_setup -COPY scripts/ /tmp/install_setup -RUN MAKE_PROGRAM=cmake /tmp/install_setup/install_setup_libbson.sh -RUN /tmp/install_setup/install_setup_pcre2.sh -RUN /tmp/install_setup/install_setup_intel_decimal_math_lib.sh -RUN /tmp/install_setup/install_citus_indent.sh +# Copy setup_versions.sh which decides versions of the dependencies to install. +COPY scripts/setup_versions.sh /tmp/install_setup/ +# Install libbson +COPY scripts/install_setup_libbson.sh /tmp/install_setup +RUN [ "bin/bash", "-c", "export MAKE_PROGRAM=cmake && /tmp/install_setup/install_setup_libbson.sh" ] + +# Copy utils.sh +COPY scripts/utils.sh /tmp/install_setup/ + +# Install postgres +COPY scripts/install_setup_postgres.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "/tmp/install_setup/install_setup_postgres.sh -d \"/usr/lib/postgresql/${PG_VERSION}\" $POSTGRES_INSTALL_ARG -v ${PG_VERSION}" ] + +# Install RUM from source +COPY scripts/install_setup_rum_oss.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_rum_oss.sh" ] + +# Install citus +COPY scripts/install_setup_citus_core_oss.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_citus_core_oss.sh ${CITUS_VERSION}" ] + +# Install citus-indent +COPY scripts/install_citus_indent.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "/tmp/install_setup/install_citus_indent.sh" ] + +# Install SYSTEM_ROWS +COPY scripts/install_setup_system_rows.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_system_rows.sh" ] + +# Install PG_CRON +COPY scripts/install_setup_pg_cron.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_pg_cron.sh" ] + +# Download Decimal128 Intel library +COPY scripts/install_setup_intel_decimal_math_lib.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "/tmp/install_setup/install_setup_intel_decimal_math_lib.sh" ] + +# Download PCRE2 library +COPY scripts/install_setup_pcre2.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "/tmp/install_setup/install_setup_pcre2.sh" ] + +# Install PG_VECTOR +COPY scripts/install_setup_pgvector.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_pgvector.sh" ] + +# Install PostGIS from source +RUN add-apt-repository -y ppa:ubuntugis/ppa && apt-get update && \ + apt-get install -qy \ + libproj-dev \ + libxml2-dev \ + libjson-c-dev \ + libgeos++-dev libgeos-3.9.1 libgeos-c1v5 libgeos-dev \ + && rm -rf /var/lib/apt/lists/* +COPY scripts/install_setup_postgis.sh /tmp/install_setup/ +RUN [ "bin/bash", "-c", "PGVERSION=$PG_VERSION /tmp/install_setup/install_setup_postgis.sh" ] + +# Add postgre path to the PATH +ENV PATH=/usr/lib/postgresql/$PG_VERSION/bin:$PATH + +# locale RUN rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +# Create heliodb user RUN useradd -ms /bin/bash heliodb -G sudo RUN echo "%sudo ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/no-pass-ask diff --git a/scripts/install_setup_citus_core_oss.sh b/scripts/install_setup_citus_core_oss.sh new file mode 100755 index 00000000..bacc9333 --- /dev/null +++ b/scripts/install_setup_citus_core_oss.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +citusVersion=$1 + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptDir/setup_versions.sh +CITUS_REF=$(GetCitusVersion $citusVersion) + +. $scriptDir/utils.sh +if [ "${PGVERSION:-}" != "" ]; then + pgPath=$(GetPostgresPath $PGVERSION) + PATH=$pgPath:$PATH +fi + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf citus-repo +mkdir citus-repo +cd citus-repo + +git init +git remote add origin https://github.com/citusdata/citus.git + +git fetch --depth 1 origin "$CITUS_REF" +git checkout FETCH_HEAD + +echo "building and installing citus extension ..." +./configure --without-lz4 --without-zstd --without-libcurl +make PATH=$PATH clean + +if [ "${DESTINSTALLDIR:-}" == "" ]; then +make PATH=$PATH -j$(cat /proc/cpuinfo | grep "core id" | wc -l) install +else +make PATH=$PATH DESTDIR=$DESTINSTALLDIR -j$(cat /proc/cpuinfo | grep "core id" | wc -l) install +fi +popd + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/citus-repo +fi diff --git a/scripts/install_setup_intel_decimal_math_lib.sh b/scripts/install_setup_intel_decimal_math_lib.sh index 5c0d8989..68fedffa 100755 --- a/scripts/install_setup_intel_decimal_math_lib.sh +++ b/scripts/install_setup_intel_decimal_math_lib.sh @@ -1,11 +1,28 @@ #!/bin/bash # fail if trying to reference a variable that is not set. -set -u / set -o nounset +set -u # exit immediately if a command exits with a non-zero status set -e +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +echo "scriptDir: $scriptDir" + +. $scriptDir/setup_versions.sh +MATH_LIB_VERSION=$(GetIntelDecimalMathLibVersion) + +MATH_LIB_WITH_VERSION="IntelRDFPMathLib"$MATH_LIB_VERSION + pushd $INSTALL_DEPENDENCIES_ROOT # If not set only then set below variables @@ -29,9 +46,6 @@ if [ -z ${PKG_CONFIG_INSTALL_PATH+x} ]; then exit 1; fi -MATH_LIB_VERSION="20U2" -MATH_LIB_WITH_VERSION="IntelRDFPMathLib"$MATH_LIB_VERSION - # Create the folders and download Intel RDF MathLib rm -rf $MATH_LIB_WITH_VERSION mkdir -p $MATH_LIB_WITH_VERSION/lib/intelmathlib diff --git a/scripts/install_setup_libbson.sh b/scripts/install_setup_libbson.sh index e27b6422..f79a99d5 100755 --- a/scripts/install_setup_libbson.sh +++ b/scripts/install_setup_libbson.sh @@ -4,8 +4,20 @@ set -u # exit immediately if a command exits with a non-zero status set -e +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" -MONGO_DRIVER_VERSION="1.28.0" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +echo "scriptDir: $scriptDir" + +. $scriptDir/setup_versions.sh +MONGO_DRIVER_VERSION=$(GetLibbsonVersion) if [ "${INSTALLDESTDIR:-""}" == "" ]; then INSTALLDESTDIR="/usr"; diff --git a/scripts/install_setup_pcre2.sh b/scripts/install_setup_pcre2.sh index bb972eea..814bd9ad 100755 --- a/scripts/install_setup_pcre2.sh +++ b/scripts/install_setup_pcre2.sh @@ -1,11 +1,28 @@ #!/bin/bash # fail if trying to reference a variable that is not set. -set -u / set -o nounset +set -u # exit immediately if a command exits with a non-zero status set -e +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +echo "scriptDir: $scriptDir" + +. $scriptDir/setup_versions.sh +PCRE_LIB_VERSION=$(GetPcre2Version) + +PCRE_LIB_WITH_VERSION="pcre2-"$PCRE_LIB_VERSION + pushd $INSTALL_DEPENDENCIES_ROOT # If not set only then set below variables @@ -24,9 +41,6 @@ if [ -z ${PKG_CONFIG_INSTALL_PATH+x} ]; then PKG_CONFIG_INSTALL_PATH=${PkgConfigInstallDirectories%%:*} fi -PCRE_LIB_VERSION="10.40" -PCRE_LIB_WITH_VERSION="pcre2-"$PCRE_LIB_VERSION - # Create the folders and download PCRE2 lib rm -rf $PCRE_LIB_WITH_VERSION diff --git a/scripts/install_setup_pg_cron.sh b/scripts/install_setup_pg_cron.sh new file mode 100755 index 00000000..45bc3a72 --- /dev/null +++ b/scripts/install_setup_pg_cron.sh @@ -0,0 +1,49 @@ + +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptDir/setup_versions.sh +CITUS_PG_CRON_REF=$(GetPgCronVersion) + +. $scriptDir/utils.sh +pgBinDir=$(GetPostgresPath $PGVERSION) +PATH=$pgBinDir:$PATH; + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf citus-pg_cron-repo +mkdir citus-pg_cron-repo +cd citus-pg_cron-repo + +git init +git remote add origin https://github.com/citusdata/pg_cron.git + +# checkout to the commit specified in the cgmanifest.json +git fetch --depth 1 origin "$CITUS_PG_CRON_REF" +git checkout FETCH_HEAD + +echo "building and installing pg_cron extension with pg path $pgBinDir..." +if [ "${DESTINSTALLDIR:-""}" == "" ]; then + sudo PATH=$PATH -E make USE_PGXS=1 clean + sudo PATH=$PATH -E make USE_PGXS=1 install +else + make DESTDIR=$DESTINSTALLDIR USE_PGXS=1 install +fi +popd + +rm -rf $INSTALL_DEPENDENCIES_ROOT/citus-pg_cron-repo \ No newline at end of file diff --git a/scripts/install_setup_pgvector.sh b/scripts/install_setup_pgvector.sh new file mode 100755 index 00000000..629336a4 --- /dev/null +++ b/scripts/install_setup_pgvector.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +echo "scriptDir: $scriptDir" + +. $scriptDir/utils.sh +pgBinDir=$(GetPostgresPath $PGVERSION) +PATH=$pgBinDir:$PATH; + +. $scriptDir/setup_versions.sh +PG_VECTOR_REF=$(GetPgVectorVersion) + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf pg_vector-repo +mkdir pg_vector-repo +cd pg_vector-repo + +git init +git remote add origin https://github.com/pgvector/pgvector.git + +git fetch --depth 1 origin "$PG_VECTOR_REF" +git checkout FETCH_HEAD + +echo "building and installing pg_vector extension ..." +if [ "${DESTINSTALLDIR:-""}" == "" ]; then + sudo PATH=$PATH -E make clean + sudo PATH=$PATH -E make -j OPTFLAGS="" + sudo PATH=$PATH -E make install +else + make -j + make DESTDIR=$DESTINSTALLDIR install +fi +popd + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/pg_vector-repo +fi \ No newline at end of file diff --git a/scripts/install_setup_postgis.sh b/scripts/install_setup_postgis.sh new file mode 100755 index 00000000..f69cf335 --- /dev/null +++ b/scripts/install_setup_postgis.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +pushd $INSTALL_DEPENDENCIES_ROOT + +# If not set only then set below variables +if [ -z ${DESTINSTALLDIR+x} ]; then + DESTINSTALLDIR="/usr" +fi + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptDir/setup_versions.sh +POSTGIS_REF=$(GetPostgisVersion) + +. $scriptDir/utils.sh +pgBinDir=$(GetPostgresPath $PGVERSION) + +POSTGIS_REPO=postgis-repo +rm -rf $POSTGIS_REPO +mkdir $POSTGIS_REPO +cd $POSTGIS_REPO + +curl https://download.osgeo.org/postgis/source/postgis-$POSTGIS_REF.tar.gz -o ./postgis-$POSTGIS_REF.tar.gz +tar -xf ./postgis-$POSTGIS_REF.tar.gz --strip-components 1 + +# Remove the tar file +rm -rf postgis-$POSTGIS_REF.tar.gz + +echo "building and installing postgis extension with pg_path $pgBinDir ..." +# Build postgis without protobuf, raster and topology support +CONFIGURE_OPTIONS="--without-protobuf --without-raster --without-topology --with-pgconfig=$pgBinDir/pg_config" + +# If not set, assume it is available in the path +if [ ! -z ${GEOS_BIN_DIR+x} ]; then + echo "GEOS config used $GEOS_BIN_DIR/geos-config..." + CONFIGURE_OPTIONS+=" --with-geosconfig=$GEOS_BIN_DIR/geos-config" +fi + +# If not set, assume it is available in the path +if [ ! -z ${PROJ_DIR+x} ]; then + echo "PROJ dir used $PROJ_DIR..." + CONFIGURE_OPTIONS+=" --with-projdir=$PROJ_DIR" +fi +echo "Configure options for PostGIS $CONFIGURE_OPTIONS" +./configure $CONFIGURE_OPTIONS +make PATH=$PATH -j +make PATH=$PATH install + +popd + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/$POSTGIS_REPO +fi diff --git a/scripts/install_setup_postgres.sh b/scripts/install_setup_postgres.sh new file mode 100755 index 00000000..e0d47da6 --- /dev/null +++ b/scripts/install_setup_postgres.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# exit immediately if a command exits with a non-zero status +set -e +# fail if trying to reference a variable that is not set. +set -u + +postgresqlInstallDir="" +debug="false" +cassert="false" +help="false"; +pgVersion="" +while getopts "d:hxcv:" opt; do + case $opt in + d) postgresqlInstallDir="$OPTARG" + ;; + x) debug="true" + ;; + c) cassert="true" + ;; + h) help="true" + ;; + v) pgVersion="$OPTARG" + ;; + esac + + # Assume empty string if it's unset since we cannot reference to + # an unset variabled due to "set -u". + case ${OPTARG:-""} in + -*) echo "Option $opt needs a valid argument" + exit 1 + ;; + esac +done + +if [ "$help" == "true" ]; then + echo "downloads postgresql-14.2 sources, build and install it." + echo "[-d] the directory to install postgresql to. Default: /usr/lib/postgresql/14" + echo "[-x] build with debug symbols." + exit 1; +fi + +if [ -z $postgresqlInstallDir ]; then + echo "Postgres Install Directory must be specified." + exit 1; +fi + +if [ -z $pgVersion ]; then + echo "PG Version must be specified"; + exit 1; +fi + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptDir/setup_versions.sh +POSTGRESQL_REF=$(GetPostgresSourceRef $pgVersion) + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf postgres-repo/$pgVersion +mkdir -p postgres-repo/$pgVersion +cd postgres-repo/$pgVersion + +git init +git remote add origin https://github.com/postgres/postgres + +# checkout to the commit specified in the cgmanifest.json +git fetch --depth 1 origin "$POSTGRESQL_REF" +git checkout FETCH_HEAD + +echo "building and installing postgresql ref $POSTGRESQL_REF and installing to $postgresqlInstallDir..." + +if [ "$debug" == "true" ]; then + ./configure --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" --with-openssl --prefix="$postgresqlInstallDir" --with-icu +elif [ "$cassert" == "true" ]; then + ./configure --enable-debug --enable-cassert --enable-tap-tests --with-openssl --prefix="$postgresqlInstallDir" --with-icu +else + ./configure --enable-debug --enable-tap-tests --with-openssl --prefix="$postgresqlInstallDir" --with-icu +fi + +make clean && make -sj$(cat /proc/cpuinfo | grep "core id" | wc -l) install + +popd + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/postgres-repo +fi diff --git a/scripts/install_setup_rum_oss.sh b/scripts/install_setup_rum_oss.sh new file mode 100755 index 00000000..49146670 --- /dev/null +++ b/scripts/install_setup_rum_oss.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +echo "scriptDir: $scriptDir" + +. $scriptDir/setup_versions.sh +RUM_REF=$(GetRumVersion) + +. $scriptDir/utils.sh +if [ "${PGVERSION:-}" != "" ]; then + pgPath=$(GetPostgresPath $PGVERSION) + PATH=$pgPath:$PATH +fi + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf rum-repo +mkdir rum-repo +cd rum-repo + +git init +git remote add origin https://github.com/postgrespro/rum.git + +git fetch --depth 1 origin "$RUM_REF" +git checkout FETCH_HEAD + +echo "building and installing rum extension ..." +echo $PATH +if [ "${DESTINSTALLDIR:-""}" == "" ]; then + sudo PATH=$PATH -E make USE_PGXS=1 + sudo PATH=$PATH -E make install USE_PGXS=1 +else + make USE_PGXS=1 + make DESTDIR=$DESTINSTALLDIR install +fi +popd + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/rum-repo +fi \ No newline at end of file diff --git a/scripts/install_setup_system_rows.sh b/scripts/install_setup_system_rows.sh new file mode 100755 index 00000000..3282401c --- /dev/null +++ b/scripts/install_setup_system_rows.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +source="${BASH_SOURCE[0]}" +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptDir="$( cd -P "$( dirname "$source" )" && pwd )" +. $scriptDir/utils.sh +. $scriptDir/setup_versions.sh +POSTGRESQL_REF=$(GetPostgresSourceRef $PGVERSION) + +pushd $INSTALL_DEPENDENCIES_ROOT + +rm -rf postgres-repo-for-system-rows +mkdir postgres-repo-for-system-rows +cd postgres-repo-for-system-rows + +git init +git remote add origin https://github.com/postgres/postgres + +# checkout to the commit specified in the cgmanifest.json +git fetch --depth 1 origin "$POSTGRESQL_REF" +git checkout FETCH_HEAD + +pgBinDir=$(GetPostgresPath $PGVERSION) +PATH=$pgBinDir:$PATH; + +echo "building and installing tsm_system_rows extension with pg path $pgBinDir ..." + +cd contrib/tsm_system_rows +if [ "${DESTINSTALLDIR:-""}" == "" ]; then + sudo PATH=$PATH -E make USE_PGXS=1 clean + sudo PATH=$PATH -E make USE_PGXS=1 install +else + make DESTDIR=$DESTINSTALLDIR USE_PGXS=1 install +fi +popd + +rm -rf $INSTALL_DEPENDENCIES_ROOT/postgres-repo-for-system-rows \ No newline at end of file diff --git a/scripts/setup_versions.sh b/scripts/setup_versions.sh new file mode 100755 index 00000000..bccab829 --- /dev/null +++ b/scripts/setup_versions.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +# declare all the versions of dependencies +LIBBSON_VERSION=1.28.0 +# This maps to REL_16_2:b78fa8547d02fc72ace679fb4d5289dccdbfc781 +POSTGRE_16_REF="REL_16_2" +# This maps to REL15_3:8382864eb5c9f9ebe962ac20b3392be5ae304d23 +POSTGRE_15_REF="REL_15_3" +# This is commit c44682a7d0641748c7fb3427fdb90ea2ae465a47 +CITUS_VERSION=v12.1.6 +# This is commit e6facb10caa1fb41faa8139f2116c282a6dfdde9 +RUM_VERSION=1.3.13 +# This is commit 9d0576c64edd90fb3d8ac30763296a8106315638 +PG_CRON_VERSION=v1.6.3 +# This is commit 2627c5ff775ae6d7aef0c430121ccf857842d2f2 +PGVECTOR_VERSION=v0.8.0 + +POSTGIS_VERSION=3.4.3 +INTEL_DECIMAL_MATH_LIB_VERSION=20U2 +PCRE2_VERSION=10.40 + +function GetPostgresSourceRef() +{ + local pgVersion=$1 + if [ "$pgVersion" == "16" ]; then + echo $POSTGRE_16_REF + elif [ "$pgVersion" == "15" ]; then + echo $POSTGRE_15_REF + else + echo "Invalid PG Version specified $pgVersion"; + exit 1; + fi +} + +function GetCitusVersion() +{ + local citusVersion=$1 + # allow the caller to specify the version as 12 or v12.1 or v12.1.6 + if [ "$citusVersion" == "12" ] || [ "$citusVersion" == "v12.1" ] || [ "$citusVersion" == "$CITUS_VERSION" ]; then + echo $CITUS_VERSION + else + echo "Invalid Citus version specified $citusVersion. Please use $CITUS_VERSION'." + exit 1 + fi +} + +function GetRumVersion() +{ + echo $RUM_VERSION +} + +function GetLibbsonVersion() +{ + echo $LIBBSON_VERSION +} + +function GetPgCronVersion() +{ + echo $PG_CRON_VERSION +} + +function GetPgVectorVersion() +{ + echo $PGVECTOR_VERSION +} + +function GetIntelDecimalMathLibVersion() +{ + echo $INTEL_DECIMAL_MATH_LIB_VERSION +} + +function GetPcre2Version() +{ + echo $PCRE2_VERSION +} + +function GetPostgisVersion() +{ + echo $POSTGIS_VERSION +} diff --git a/scripts/utils.sh b/scripts/utils.sh index 51f5411e..86d03335 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -31,6 +31,23 @@ function GetPostgresPath() fi } +function GetPostgresSourceRef() +{ + local pgVersion=$1 + if [ "$pgVersion" == "16" ]; then + # This maps to REL_16_2:b78fa8547d02fc72ace679fb4d5289dccdbfc781 + POSTGRESQL_REF="REL_16_2" + elif [ "$pgVersion" == "15" ]; then + # This maps to REL15_3:8382864eb5c9f9ebe962ac20b3392be5ae304d23 + POSTGRESQL_REF="REL_15_3" + else + echo "Invalid PG Version specified $pgVersion"; + exit 1; + fi + + echo $POSTGRESQL_REF +} + function GetPGCTL() { local pgVersion=${PG_VERSION:-16}