Skip to content

Instantly share code, notes, and snippets.

@bbedward
Created March 17, 2023 00:01
Show Gist options
  • Save bbedward/839801372862c67fb894f98db80f59d1 to your computer and use it in GitHub Desktop.
Save bbedward/839801372862c67fb894f98db80f59d1 to your computer and use it in GitHub Desktop.
spilo pgjwt
git clone https://github.com/michelp/pgjwt.git /pgjwt
# forbid creation of a main cluster when package is installed
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf
for version in $DEB_PG_SUPPORTED_VERSIONS; do
sed -i "s/ main.*$/ main $version/g" /etc/apt/sources.list.d/pgdg.list
apt-get update
if [ "$DEMO" != "true" ]; then
EXTRAS=("postgresql-pltcl-${version}"
"postgresql-${version}-dirtyread"
"postgresql-${version}-extra-window-functions"
"postgresql-${version}-first-last-agg"
"postgresql-${version}-hll"
"postgresql-${version}-hypopg"
"postgresql-${version}-plproxy"
"postgresql-${version}-partman"
"postgresql-${version}-pgaudit"
"postgresql-${version}-pldebugger"
"postgresql-${version}-pglogical"
"postgresql-${version}-pglogical-ticker"
"postgresql-${version}-plpgsql-check"
"postgresql-${version}-pg-checksums"
"postgresql-${version}-pgl-ddl-deploy"
"postgresql-${version}-pgq-node"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}-scripts"
"postgresql-${version}-repack"
"postgresql-${version}-wal2json")
if [ "$version" != "15" ]; then
# not yet present for pg15
EXTRAS+=("postgresql-${version}-pllua")
fi
if [ "$WITH_PERL" = "true" ]; then
EXTRAS+=("postgresql-plperl-${version}")
fi
if [ "${version%.*}" -ge 10 ]; then
EXTRAS+=("postgresql-${version}-decoderbufs")
fi
if [ "${version%.*}" -lt 11 ]; then
EXTRAS+=("postgresql-${version}-amcheck")
fi
fi
# Install PostgreSQL binaries, contrib, plproxy and multiple pl's
apt-get install --allow-downgrades -y \
"postgresql-${version}-cron" \
"postgresql-contrib-${version}" \
"postgresql-${version}-pgextwlist" \
"postgresql-plpython3-${version}" \
"postgresql-server-dev-${version}" \
"postgresql-${version}-pgq3" \
"postgresql-${version}-pg-stat-kcache" \
"${EXTRAS[@]}"
# Install 3rd party stuff
# use subshell to avoid having to cd back (SC2103)
(
cd timescaledb
for v in $TIMESCALEDB; do
git checkout "$v"
sed -i "s/VERSION 3.11/VERSION 3.10/" CMakeLists.txt
if BUILD_FORCE_REMOVE=true ./bootstrap -DREGRESS_CHECKS=OFF -DWARNINGS_AS_ERRORS=OFF \
-DTAP_CHECKS=OFF -DPG_CONFIG="/usr/lib/postgresql/$version/bin/pg_config" \
-DAPACHE_ONLY="$TIMESCALEDB_APACHE_ONLY" -DSEND_TELEMETRY_DEFAULT=NO; then
make -C build install
strip /usr/lib/postgresql/"$version"/lib/timescaledb*.so
fi
git reset --hard
git clean -f -d
done
)
if [ "${TIMESCALEDB_APACHE_ONLY}" != "true" ] && [ "${TIMESCALEDB_TOOLKIT}" = "true" ]; then
__versionCodename=$(sed </etc/os-release -ne 's/^VERSION_CODENAME=//p')
echo "deb [signed-by=/usr/share/keyrings/timescale_E7391C94080429FF.gpg] https://packagecloud.io/timescale/timescaledb/ubuntu/ ${__versionCodename} main" | tee /etc/apt/sources.list.d/timescaledb.list
curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor > /usr/share/keyrings/timescale_E7391C94080429FF.gpg
apt-get update
if [ "$(apt-cache search --names-only "^timescaledb-toolkit-postgresql-${version}$" | wc -l)" -eq 1 ]; then
apt-get install "timescaledb-toolkit-postgresql-$version"
else
echo "Skipping timescaledb-toolkit-postgresql-$version as it's not found in the repository"
fi
rm /etc/apt/sources.list.d/timescaledb.list
rm /usr/share/keyrings/timescale_E7391C94080429FF.gpg
fi
if [ "$DEMO" != "true" ]; then
EXTRA_EXTENSIONS=("plantuner-${PLANTUNER_COMMIT}" plprofiler)
if [ "${version%.*}" -ge 10 ]; then
EXTRA_EXTENSIONS+=("pg_mon-${PG_MON_COMMIT}")
fi
else
EXTRA_EXTENSIONS=()
fi
for n in bg_mon-${BG_MON_COMMIT} \
pg_auth_mon-${PG_AUTH_MON_COMMIT} \
set_user \
pg_permissions-${PG_PERMISSIONS_COMMIT} \
pg_tm_aux-${PG_TM_AUX_COMMIT} \
pg_profile-${PG_PROFILE} \
"${EXTRA_EXTENSIONS[@]}"; do
make -C "$n" USE_PGXS=1 clean install-strip
done
cp /pgjwt/*.sql /pgjwt/*.control /usr/share/postgresql/${version}/extension/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment