initial import

This commit is contained in:
2025-06-22 20:39:04 -05:00
commit f8a70886f0
3428 changed files with 302546 additions and 0 deletions

218
postgresql/PKGBUILD Normal file
View File

@@ -0,0 +1,218 @@
# Maintainer: Jesus E. <heckyel@riseup.net>
pkgbase=postgresql
pkgname=('postgresql-libs' 'postgresql')
pkgver=12.4
_debver=$pkgver
_debrel=1
_majorver=${pkgver%.*}
pkgrel=3
url="https://www.postgresql.org/"
arch=('i686' 'x86_64')
license=('custom:PostgreSQL')
makedepends=('krb5' 'libxml2' 'python' 'tauthon' 'perl' 'tcl>=8.6.0' 'libressl' 'zlib' 'icu' 'libldap' 'quilt')
source=(https://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2
https://repo.hyperbola.info:50000/sources/${pkgbase}/postgresql-12_${_debver}-${_debrel}.debian.tar.xz{,.sig}
postgresql-run-socket.patch
postgresql-perl-rpath.patch
postgresql.logrotate
postgresql-check-db-dir
postgresql.confd
postgresql.initd
postgresql.conf
postgresql.run
postgresql_log.run)
sha512sums=('36daf10878ca153370829178786dd6ee366ab4d4d6dc9c527536740fdb14b688ae4c33f850eb4243a7667d23f87e4bfd1ddee0755447ad4f3996e423e391c2f3'
'e53b2af1b8f904efcc28c6723d9752f97079959fb2306f01d777af02ed105967c4b3c89dfa6069daae37830ce77e2db3271bd3c5b75fb85bda76a9b52e2394c3'
'SKIP'
'031efe12d18ce386989062327cdbbe611c5ef1f94e4e1bead502304cb3e2d410af533d3c7f1109d24f9da9708214fe32f9a10ba373a3ca8d507bdb521fbb75f7'
'38302242b30c01c7981574ed28d9cbd9dc73bf6b56ba3a032afb5d0885ae83e5aa72ce578bf2422214dfa6c46f09d0bdd7cccaeb3c25d58754eb1a34f8bf5615'
'9ab4da01337ffbab8faec0e220aaa2a642dbfeccf7232ef2645bdc2177a953f17ee3cc14a4d8f8ebd064e1dae8b3dba6029adbffb8afaabea383963213941ba8'
'eaaccae8dabad67d2bc54f74ec8d3ddb46257369b90080a2860b65d500053db6ace608be4c1b6baaeab4a03245dcbb5215eb41e468acc2304c037f094c2e7819'
'839aa9714c8b968d19b1cbeb19a3c561d588d7e6572fc501895423e369ec004256720390760b29347c85de71dccc67596072060975f7af60239b8565068fa2bf'
'd901e05ac8c965c5f8d12e143b94a49b69e941d392a5210df88df6ef0b8fbb02c48e6fb6e68262b1286ef96c5fa0c6a36e0d26cd707475389495a9fc2a6be28d'
'7a0cb0f0caeba4f7def60581bdfcb1c852f06512dcd24f1a454e71d7e88596639c004cfe70bf362750715f3d49d3c7f1fb6e59d897eab75566d6e8652ad3c835'
'bb7c35db229d6f7133e8463ebc3fe4f43ddffd5ba0ed89aaecd50e0e28a6f168a0433c5dc3f6a3e22480090c9e304e234b8cad2a51d946533eb6bbfbc64c39fe'
'a0bda24ba021c0a351c8b109651b64b8542236d49b0a19693c0e61d7a33e3eff61297d50639663e212789d1bfeed026b0da3d0db35c89b871746d5ef76670357')
validpgpkeys=('C92BAA713B8D53D3CAE63FC9E6974752F9704456') # André Silva
prepare() {
cd postgresql-${pkgver}
if [[ ${pkgver%.*} = ${_debver%.*} ]]; then
# Debian patches
export QUILT_PATCHES=debian/patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
export QUILT_DIFF_ARGS='--no-timestamps'
mv "$srcdir"/debian .
# Doesn't apply
rm -v debian/patches/50-per-version-dirs.patch || true
rm -v debian/patches/51-default-sockets-in-var.patch || true
rm -v debian/patches/52-tutorial-README.patch || true
rm -v debian/patches/53-pg_service.conf_directory_doc.patch || true
rm -v debian/patches/54-debian-alternatives-for-external-tools.patch || true
rm -v debian/patches/70-history || true
rm -v debian/patches/initdb-startup-message || true
rm -v debian/patches/libpgport-pkglibdir || true
quilt push -av
fi
patch -Np1 < $srcdir/postgresql-run-socket.patch
patch -p1 < $srcdir/postgresql-perl-rpath.patch
}
build() {
cd postgresql-${pkgver}
local options=(
--prefix=/usr
--mandir=/usr/share/man
--datadir=/usr/share/postgresql
--sysconfdir=/etc
--with-gssapi
--with-libxml
--with-openssl
--with-perl
--with-python
--with-tcl
--without-pam
--with-system-tzdata=/usr/share/zoneinfo
--with-uuid=e2fs
--with-icu
--with-ldap
--enable-nls
--enable-thread-safety
--disable-rpath
)
# only build plpython3 for now
./configure ${options[@]} \
PYTHON=/usr/bin/python
make -C src/pl/plpython all
make -C contrib/hstore_plpython all
make -C contrib/ltree_plpython all
# save plpython3 build and Makefile.global
cp -a src/pl/plpython{,3}
cp -a contrib/hstore_plpython{,3}
cp -a contrib/ltree_plpython{,3}
cp -a src/Makefile.global{,.python3}
make distclean
# regular build with everything
./configure ${options[@]} \
PYTHON=/usr/bin/tauthon
make world
}
package_postgresql-libs() {
pkgdesc="Libraries for use with PostgreSQL"
depends=('krb5' 'libressl' 'readline>=6.0' 'zlib' 'libldap')
provides=('postgresql-client')
conflicts=('postgresql-client')
cd postgresql-${pkgver}
# install license
install -Dm 644 COPYRIGHT "${pkgdir}/usr/share/licenses/postgresql-libs/COPYRIGHT"
# install libs and non-server binaries
for dir in src/interfaces src/bin/pg_config src/bin/pg_dump src/bin/psql src/bin/scripts; do
make -C ${dir} DESTDIR="${pkgdir}" install
done
for util in pg_config pg_dump pg_dumpall pg_restore psql \
clusterdb createdb createuser dropdb dropuser pg_isready reindexdb vacuumdb; do
install -Dm 644 doc/src/sgml/man1/${util}.1 "${pkgdir}"/usr/share/man/man1/${util}.1
done
cd src/include
install -d "${pkgdir}"/usr/include/{libpq,postgresql/internal/libpq}
# these headers are needed by the public headers of the interfaces
install -m 644 pg_config.h "${pkgdir}/usr/include"
install -m 644 pg_config_os.h "${pkgdir}/usr/include"
install -m 644 pg_config_ext.h "${pkgdir}/usr/include"
install -m 644 postgres_ext.h "${pkgdir}/usr/include"
install -m 644 libpq/libpq-fs.h "${pkgdir}/usr/include/libpq"
install -m 644 pg_config_manual.h "${pkgdir}/usr/include"
# these he aders are needed by the not-so-public headers of the interfaces
install -m 644 c.h "${pkgdir}/usr/include/postgresql/internal"
install -m 644 port.h "${pkgdir}/usr/include/postgresql/internal"
install -m 644 postgres_fe.h "${pkgdir}/usr/include/postgresql/internal"
install -m 644 libpq/pqcomm.h "${pkgdir}/usr/include/postgresql/internal/libpq"
}
package_postgresql() {
pkgdesc="Sophisticated object-relational DBMS"
backup=('etc/logrotate.d/postgresql' 'etc/conf.d/postgresql' 'etc/sv/postgresql/conf')
depends=("postgresql-libs>=${pkgver}" 'krb5' 'libxml2' 'readline>=6.0' 'libressl' 'icu' 'libldap')
optdepends=('tauthon: for PL/Tauthon support'
'python: for PL/Python support'
'perl: for PL/Perl support'
'tcl: for PL/Tcl support'
'postgresql-old-upgrade: upgrade from previous major version using pg_upgrade'
'logger: message logging support')
options=('staticlibs')
install=postgresql.install
cd postgresql-${pkgver}
# install
make DESTDIR="${pkgdir}" install
make -C contrib DESTDIR="${pkgdir}" install
make -C doc/src/sgml DESTDIR="${pkgdir}" install-man
# install docs
make -C doc/src/sgml DESTDIR="${pkgdir}" install-html
chown -R root:root "${pkgdir}/usr/share/doc/postgresql/html"
# install plpython3
mv src/Makefile.global src/Makefile.global.save
cp src/Makefile.global.python3 src/Makefile.global
touch -r src/Makefile.global.save src/Makefile.global
make -C src/pl/plpython3 DESTDIR="${pkgdir}" install
make -C contrib/hstore_plpython3 DESTDIR="${pkgdir}" install
make -C contrib/ltree_plpython3 DESTDIR="${pkgdir}" install
# we don't want these, they are in the -libs package
for dir in src/interfaces src/bin/pg_config src/bin/pg_dump src/bin/psql src/bin/scripts; do
make -C ${dir} DESTDIR="${pkgdir}" uninstall
done
for util in pg_config pg_dump pg_dumpall pg_restore psql \
clusterdb createdb createuser dropdb dropuser pg_isready reindexdb vacuumdb; do
rm "${pkgdir}"/usr/share/man/man1/${util}.1
done
# install license
install -Dm 644 COPYRIGHT "${pkgdir}/usr/share/licenses/${pkgbase}/COPYRIGHT"
# clean up unneeded installed items
rm -rf "${pkgdir}/usr/include/postgresql/internal"
rm -rf "${pkgdir}/usr/include/libpq"
find "${pkgdir}/usr/include" -maxdepth 1 -type f -execdir rm {} +
install -Dm 755 "${srcdir}/postgresql-check-db-dir" \
"${pkgdir}/usr/bin/postgresql-check-db-dir"
install -Dm 644 "${srcdir}/postgresql.logrotate" \
"${pkgdir}/etc/logrotate.d/postgresql"
# install OpenRC files
install -Dm 644 "${srcdir}/postgresql.confd" \
"${pkgdir}/etc/conf.d/postgresql"
install -Dm 755 "${srcdir}/postgresql.initd" \
"${pkgdir}/etc/init.d/postgresql"
# install runit files
install -Dm 644 "${srcdir}/postgresql.conf" \
"${pkgdir}/etc/sv/postgresql/conf"
install -Dm 755 "${srcdir}/postgresql.run" \
"${pkgdir}/etc/sv/postgresql/run"
install -Dm 755 "${srcdir}/postgresql_log.run" \
"${pkgdir}/etc/sv/postgresql/log/run"
}

View File

@@ -0,0 +1,49 @@
#!/bin/sh
# This script verifies that the postgresql data directory has been correctly
# initialized. We do not want to automatically initdb it, because that has
# a risk of catastrophic failure (ie, overwriting a valuable database) in
# corner cases, such as a remotely mounted database on a volume that's a
# bit slow to mount. But we can at least emit a message advising newbies
# what to do.
PGDATA="$1"
if [ -z "$PGDATA" ]
then
echo "Usage: $0 database-path"
exit 1
fi
# PGMAJORVERSION is major version
PGMAJORVERSION=12
# PREVMAJORVERSION is the previous major version
PREVMAJORVERSION=11
# Check for the PGDATA structure
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
then
# Check version of existing PGDATA
if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
then
: A-OK
elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
then
echo $"An old version of the database format was found."
echo $"See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreSQL"
exit 1
else
echo $"An old version of the database format was found."
echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
echo $"See http://www.postgresql.org/docs/$PGMAJORVERSION/static/upgrading.html"
exit 1
fi
else
# No existing PGDATA! Warn the user to initdb it.
echo $"\"$PGDATA\" is missing or empty. Use a command like"
echo $" su - postgres -c \"initdb --locale en_US.UTF-8 -D '$PGDATA'\""
echo $"with relevant options, to initialize the database cluster."
exit 1
fi
exit 0

View File

@@ -0,0 +1,13 @@
diff -Naur postgresql-9.1.5.orig/src/pl/plperl/GNUmakefile postgresql-9.1.5/src/pl/plperl/GNUmakefile
--- postgresql-9.1.5.orig/src/pl/plperl/GNUmakefile 2012-08-14 18:41:04.000000000 -0400
+++ postgresql-9.1.5/src/pl/plperl/GNUmakefile 2012-08-17 11:15:09.457116708 -0400
@@ -43,6 +43,9 @@
SHLIB_LINK = $(perl_embed_ldflags)
+# Force rpath to be used even though we disable it everywhere else
+SHLIB_LINK += $(rpath)
+
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=plperl --load-extension=plperlu
REGRESS = plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array
# if Perl can support two interpreters in one backend,

View File

@@ -0,0 +1,12 @@
diff -Naur postgresql-9.2.0.sockets/src/include/pg_config_manual.h postgresql-9.2.0/src/include/pg_config_manual.h
--- postgresql-9.2.0.sockets/src/include/pg_config_manual.h 2012-09-06 17:26:17.000000000 -0400
+++ postgresql-9.2.0/src/include/pg_config_manual.h 2012-09-06 18:13:18.183092471 -0400
@@ -144,7 +144,7 @@
* here's where to twiddle it. You can also override this at runtime
* with the postmaster's -k switch.
*/
-#define DEFAULT_PGSOCKET_DIR "/tmp"
+#define DEFAULT_PGSOCKET_DIR "/run/postgresql"
/*
* The random() function is expected to yield values between 0 and

View File

@@ -0,0 +1,17 @@
# Configuration file for the PostgreSQL server.
# PostgreSQL's database directory
PGROOT="/var/lib/postgresql"
# PostgreSQL's log file.
PGLOG="/var/log/postgresql.log"
# Passed to initdb if necessary
INITOPTS="-A peer --auth-host=md5 --auth-local=peer --locale en_US.UTF-8"
# Extra options to run postmaster with, e.g.:
# -N is the maximal number of client connections
# -B is the number of shared buffers and has to be at least 2x the value for -N
# Please read the man-page to postmaster for more options. Many of these options
# can be set directly in the configuration-file.
#PGOPTS="-N 512 -B 1024"

View File

@@ -0,0 +1,58 @@
# Which port and socket to bind PostgreSQL
PGPORT="5432"
# How long to wait for server to start in seconds
START_TIMEOUT=10
# NICE_QUIT ignores new connections and wait for clients to disconnect from
# server before shutting down. NICE_TIMEOUT in seconds determines how long to
# wait for this to succeed.
NICE_TIMEOUT=60
# Forecfully disconnect clients from server and shut down. This is performed
# after NICE_QUIT. Terminated client connections have their open transactions
# rolled back.
# Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds.
RUDE_QUIT="YES"
RUDE_TIMEOUT=30
# If the server still fails to shutdown, you can force it to quit by setting
# this to YES and a recover-run will execute on the next startup.
# Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds.
FORCE_QUIT="NO"
FORCE_TIMEOUT=2
# Extra options to run postmaster with, e.g.:
# -N is the maximal number of client connections
# -B is the number of shared buffers and has to be at least 2x the value for -N
# Please read the man-page to postmaster for more options. Many of these
# options can be set directly in the configuration file.
#PGOPTS="-N 512 -B 1024"
# Pass extra environment variables. If you have to export environment variables
# for the database process, this can be done here.
# Don't forget to escape quotes.
#PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\""
##############################################################################
#
# The following values should not be arbitrarily changed.
#
# `emerge --config dev-db/postgresql:@SLOT@' uses these values to
# determine where to create the data directory, where to place the
# configuration files, and any additional options to pass to initdb.
#
# The initscript also uses these variables to inform PostgreSQL where to find
# its data directory and configuration files.
#
##############################################################################
# Location of configuration files
PGDATA="/var/lib/postgres/data/"
# Where the data directory is located/to be created
DATA_DIR="/var/lib/postgres/data"
# Additional options to pass to initdb.
# See `man initdb' for available options.
PG_INITDB_OPTS="--encoding=UTF8"

143
postgresql/postgresql.initd Normal file
View File

@@ -0,0 +1,143 @@
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Copyright 2019 Hyperbola Project
# Distributed under the terms of the GNU General Public License v2
extra_started_commands="reload"
get_config() {
[ -f ${PGDATA%/}/postgresql.conf ] || return 1
eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \
| awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
}
depend() {
use net
provide postgresql
if [ "$(get_config log_destination)" = "syslog" ]; then
use logger
fi
}
configured_port=$(get_config port)
: ${configured_port:=${PGPORT}}
socket_paths=$(get_config unix_socket_directories)
: ${socket_paths:=/run/postgresql}
checkconfig() {
# Check that DATA_DIR has been set
if [ -z ${DATA_DIR} ] ; then
eerror "DATA_DIR not set"
eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql"
return 1
fi
# Check that DATA_DIR exists
if [ ! -d ${DATA_DIR} ] ; then
eerror "Directory not found: ${DATA_DIR}"
eerror "HINT: Ensure that DATA_DIR points to the right path."
eerror "HINT: Or perhaps you need to create the database cluster:"
eerror " emerge --config dev-db/postgresql:@SLOT@"
return 1
fi
# Check for the existence of PostgreSQL's config files, and set the
# proper mode and ownership.
# Only three files should be checked as potentially other files
# may be in PGDATA that should not be touched.
local file
for file in postgresql pg_hba pg_ident ; do
file="${PGDATA%/}/${file}.conf"
if [ -f ${file} ] ; then
checkpath -f -m 0600 -o postgres:postgres ${file}
else
eerror "${file} not found"
eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
return 1
fi
done
# Set the proper permission for the socket paths and create it if
# it doesn't exist.
set -f; IFS=','
local s
for s in ${socket_paths}; do
checkpath -d -m 1775 -o postgres:postgres ${s}
if [ -e ${s%/}/.s.PGSQL.${configured_port} ] ; then
eerror "Socket conflict."
eerror "A server is already listening on:"
eerror " ${s%/}/.s.PGSQL.${configured_port}"
eerror "HINT: Change PGPORT to listen on a different socket."
return 1
fi
done
set +f; unset IFS
}
start() {
checkconfig || return 1
ebegin "Starting PostgreSQL"
rm -f ${DATA_DIR%/}/postmaster.pid
local extraenv
local x
for x in ${PG_EXTRA_ENV} ; do
extraenv="${extraenv} --env ${x}"
done
start-stop-daemon --start \
--user postgres \
--env "PGPORT=${configured_port}" \
${extraenv} \
--pidfile ${DATA_DIR%/}/postmaster.pid \
--exec /usr/bin/pg_ctl \
-- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \
-D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}"
local retval=$?
if [ $retval -ne 0 ] ; then
eerror "Check the log for a possible explanation of the above error. The log may be"
eerror " ${DATA_DIR%/}/postmaster.log"
eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent."
eend $retval
return $retval
fi
eend $retval
}
stop() {
local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)"
local retval
local retries=SIGTERM/${NICE_TIMEOUT}
if [ "${RUDE_QUIT}" != "NO" ] ; then
einfo "RUDE_QUIT enabled."
retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
fi
if [ "${FORCE_QUIT}" = "YES" ] ; then
einfo "FORCE_QUIT enabled."
ewarn "A recover-run might be executed on next startup."
retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
fi
# Loops through nice, rude, and force quit in one go.
start-stop-daemon --stop \
--exec /usr/bin/postgres \
--retry ${retries} \
--pidfile ${DATA_DIR%/}/postmaster.pid
eend
}
reload() {
ebegin "Reloading PostgreSQL configuration"
kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid)
eend $?
}

View File

@@ -0,0 +1,28 @@
post_install() {
if [ ! -d '/var/lib/postgres' ]; then
mkdir -p '/var/lib/postgres'
fi
if ! getent group postgres >/dev/null; then
groupadd -g 88 postgres
fi
if ! getent passwd postgres >/dev/null; then
useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres
passwd -l postgres >/dev/null
fi
if [ ! -d '/var/lib/postgres/data' ]; then
mkdir -p '/var/lib/postgres/data'
chown postgres:postgres '/var/lib/postgres/data'
fi
local datadir="/var/lib/postgres/data"
echo " ==> requires datadir $datadir"
echo " ==> run as user postgres: 'initdb -D $datadir'"
postgres_shell=$(getent passwd postgres | cut -d: -f7)
if [ "$postgres_shell" != '/bin/bash' ]; then
chsh -s /bin/bash postgres &>/dev/null
fi
}
post_upgrade() {
post_install $1
}

View File

@@ -0,0 +1,4 @@
/var/log/postgresql.log {
copytruncate
missingok
}

30
postgresql/postgresql.run Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
[ -r conf ] && . ./conf
: ${PGDATA:="$PGROOT/data"}
if [ "$PGROOT" != "/var/lib/postgresql" ]; then
echo "Creating symlink /var/lib/postgresql -> $PGROOT"
# Remove /var/lib/postgres if empty dir, but not if symlink
if [ ! -L /var/lib/postgres ] && [ -d /var/lib/postgres ]; then
rmdir /var/lib/postgres
fi
ln -sf "$PGROOT" /var/lib/postgresql
fi
if [ ! -d "$PGDATA" ]; then
echo "Initializing database in $PGDATA"
mkdir -p "$PGDATA"
chown -R postgres:postgres "$PGDATA"
chmod 0700 "$PGDATA"
su - postgres -m -c "/usr/bin/initdb $INITOPTS -D '$PGDATA'" >/dev/null
if [ -f /etc/postgresql/postgresql.conf ]; then
ln -sf /etc/postgresql/postgresql.conf "$PGDATA/postgresql.conf"
fi
fi
exec chpst -u postgres:postgres postgres -D "$PGDATA" $PGOPTS 2>&1

View File

@@ -0,0 +1,2 @@
#!/bin/sh
exec logger -p daemon.info -t postgres