gitlab-build-images/scripts/install-postgresql
Balasankar "Balu" C f28d358e24
Set default value for BUILD_ARCH in installation scripts
Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
2022-08-05 13:18:47 +05:30

47 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
POSTGRES_VERSION=${1:-12}
function build_debian() {
DEBIAN_VERSION=$(lsb_release -c -s)
export DEBIAN_FRONTEND=noninteractive
# Uninstall the system client so that we don't have multiple versions
apt purge -y postgresql-client postgresql-client-common
curl -sS -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION}-pgdg main" | tee /etc/apt/sources.list.d/postgresql.list
apt-get update
apt-get install -y postgresql-client-${POSTGRES_VERSION}
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
}
function build_ubi() {
UBI_VERSION=$(lsb_release -a | awk '/Release/ { print $2 }')
UBI_MAJOR_VERSION=${UBI_VERSION%.*} # strip last component
yum install -y "https://download.postgresql.org/pub/repos/yum/reporpms/EL-${UBI_MAJOR_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
yum update -y
yum install -y postgresql${POSTGRES_VERSION}
yum autoremove -y
yum clean -y all
}
BUILD_OS=${BUILD_OS:-debian}
BUILD_ARCH=${BUILD_ARCH:-amd64}
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi