From e308bcff5a610d6a3bbe33b3769f03f6d4533b16 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 18:02:19 +0200 Subject: Adding upstream version 248. Signed-off-by: Daniel Baumann --- pgdg/apt.postgresql.org.sh | 283 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100755 pgdg/apt.postgresql.org.sh (limited to 'pgdg/apt.postgresql.org.sh') diff --git a/pgdg/apt.postgresql.org.sh b/pgdg/apt.postgresql.org.sh new file mode 100755 index 0000000..20797f8 --- /dev/null +++ b/pgdg/apt.postgresql.org.sh @@ -0,0 +1,283 @@ +#!/bin/sh + +# script to add apt.postgresql.org to sources.list.d + +# Copyright (C) 2013-2022 Christoph Berg +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# The full text of the GPL is distributed as in +# /usr/share/common-licenses/GPL-2 on Debian systems. + +SOURCESLIST="/etc/apt/sources.list.d/pgdg.sources" +TYPES="deb" +COMPONENTS="main" +PGDG="pgdg" + +# variables imported from https://git.postgresql.org/gitweb/?p=pgapt.git;a=blob;f=pgapt.conf +# checked out in $HOME/apt.postgresql.org/; run "make" to update +PG_BETA_VERSION="" +PG_DEVEL_VERSION="16" +PG_REPOSITORY_DISTS="sid bookworm bullseye buster kinetic jammy focal bionic" +PG_ARCHIVE_DISTS="sid bookworm bullseye buster stretch jessie wheezy squeeze lenny etch kinetic jammy impish hirsute groovy focal eoan disco cosmic bionic zesty xenial wily utopic saucy precise lucid" + +while getopts "c:f:h:ipstv:y" opt ; do + case $opt in + c) COMPONENTS="main $OPTARG" ;; # make these extra components available + f) SOURCESLIST=$OPTARG ;; # sources.list filename to write to + h) HOST="$OPTARG" ;; # hostname to use in sources.list + i) INSTALL="yes" ;; # install packages for version given with -v + p) PURGE="yes" ;; # purge existing postgresql packages + s) TYPES="deb deb-src" ;; # include source repository as well + t) PGDG="pgdg-testing" ;; # use *-pgdg or *-pgdg-testing + v) PGVERSION="$OPTARG" ;; # set up sources.list to use this version (useful for beta/devel packages) + y) ;; # don't ask for confirmation + *) exit 5 ;; + esac + YES="yes" # don't ask for confirmation if any option is given +done +# shift away args +shift $((OPTIND - 1)) +# check options +if [ "$INSTALL" ] && [ -z "$PGVERSION" ]; then + echo "With -i, a version to install must be provided (-v)" + exit 1 +fi + +# codename from command line +CODENAME="$1" +# parse os-release +if [ -z "$CODENAME" ] && [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$VERSION_CODENAME" ]; then # added in buster/xenial + CODENAME="$VERSION_CODENAME" + else + # Debian: VERSION="7.0 (wheezy)" + # Ubuntu: VERSION="13.04, Raring Ringtail" + # VERSION="18.04.1 LTS (Bionic Beaver)" + CODENAME=$(echo $VERSION | sed -ne 's/.*(\(.*\)).*/\1/') # works on Debian only + fi +fi +# try lsb_release +if [ -z "$CODENAME" ] && command -v lsb_release >/dev/null; then + CODENAME=$(lsb_release -cs 2>/dev/null) +fi +# guess from sources.list +if [ -z "$CODENAME" ] && [ -f /etc/apt/sources.list ]; then + CODENAME=$(grep '^deb ' /etc/apt/sources.list | head -n1 | awk '{ print $3 }') +fi +# complain if no result yet +if [ -z "$CODENAME" ]; then + cat < $KEYRING < $SOURCESLIST <> $SOURCESLIST <