summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Rechté2022-03-29 16:57:25 +0200
committerMarc Rechté2022-03-29 16:57:25 +0200
commit33266c18f08d0afa2654e4e104bdc57f141883fc (patch)
treecfcfed10c9eaac4fd9b71309193839274442b0b4
downloadaur-33266c18f08d0afa2654e4e104bdc57f141883fc.tar.gz
Initial.
-rw-r--r--.SRCINFO76
-rw-r--r--PKGBUILD212
-rwxr-xr-xpgenv.sh5
-rwxr-xr-xpostgresql-check-db-dir42
-rw-r--r--postgresql-command.patch11
-rw-r--r--postgresql-perl-rpath.patch13
-rw-r--r--postgresql-run-socket.patch12
-rw-r--r--postgresql.install7
-rw-r--r--postgresql.service46
-rw-r--r--postgresql.sysusers1
-rw-r--r--postgresql.tmpfiles2
11 files changed, 427 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..0fc473f69f2f
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,76 @@
+pkgbase = postgresql11
+ pkgdesc = Sophisticated object-relational DBMS
+ pkgver = 11.9
+ pkgrel = 1
+ url = https://www.postgresql.org/
+ arch = x86_64
+ license = custom:PostgreSQL
+ makedepends = krb5
+ makedepends = libxml2
+ makedepends = python
+ makedepends = python2
+ makedepends = perl
+ makedepends = tcl>=8.6.0
+ makedepends = openssl>=1.0.0
+ makedepends = pam
+ makedepends = zlib
+ makedepends = icu
+ makedepends = systemd
+ makedepends = libldap
+ makedepends = clang
+ source = https://ftp.postgresql.org/pub/source/v11.9/postgresql-11.9.tar.bz2
+ source = postgresql-run-socket.patch
+ source = postgresql-perl-rpath.patch
+ source = postgresql-command.patch
+ source = postgresql.service
+ source = postgresql-check-db-dir
+ source = postgresql.sysusers
+ source = postgresql.tmpfiles
+ source = pgenv.sh
+ md5sums = 2d20502cbce1c7531bb69e56f5c5c65a
+ md5sums = 92249e35353927d9f79df66a4101b3fa
+ md5sums = 7d899fe96b0044e120e49bab4205610d
+ md5sums = 2c74b38d3ca580733daaf60d7c564792
+ md5sums = 77f41e79ec546d40b24a46cd646e3c2f
+ md5sums = 848c7c58ac8831fb5323e3446be5afcf
+ md5sums = 2050d34e4dfa05f3c6fe4cd7615eaa4b
+ md5sums = 9f34d430c5ef0ddca8843b58f71c0b3d
+ md5sums = 37bbc58222c61b8e0533eab845ca94f5
+
+pkgname = postgresql11-libs
+ pkgdesc = Libraries for use with PostgreSQL
+ depends = krb5
+ depends = openssl>=1.0.0
+ depends = readline>=6.0
+ depends = zlib
+ depends = libldap
+ provides = postgresql11-client
+ provides = libpq.so
+ provides = libecpg.so
+ provides = libecpg_compat.so
+ provides = libpgtypes.so
+ conflicts = postgresql11-client
+
+pkgname = postgresql11-docs
+ pkgdesc = HTML documentation for PostgreSQL
+ options = docs
+
+pkgname = postgresql11
+ pkgdesc = Sophisticated object-relational DBMS
+ install = postgresql.install
+ depends = postgresql11-libs>=11.9
+ depends = krb5
+ depends = libxml2
+ depends = readline>=6.0
+ depends = openssl>=1.0.0
+ depends = pam
+ depends = icu
+ depends = systemd-libs
+ depends = libldap
+ depends = llvm-libs
+ depends = libxslt
+ optdepends = python2: for PL/Python 2 support
+ optdepends = python: for PL/Python 3 support
+ optdepends = perl: for PL/Perl support
+ optdepends = tcl: for PL/Tcl support
+ options = staticlibs
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..c596c12f3631
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,212 @@
+# Maintainer: Marc Rechté <marc4@rechte.fr>
+
+pkgbase=postgresql11
+pkgver=11.9
+_majorver=${pkgver%.*}
+pkgname=("${pkgbase}-libs" "${pkgbase}-docs" "${pkgbase}")
+pkgrel=1
+pkgdesc='Sophisticated object-relational DBMS'
+url='https://www.postgresql.org/'
+arch=('x86_64')
+license=('custom:PostgreSQL')
+makedepends=('krb5' 'libxml2' 'python' 'python2' 'perl' 'tcl>=8.6.0' 'openssl>=1.0.0'
+ 'pam' 'zlib' 'icu' 'systemd' 'libldap' 'clang' )
+source=(https://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2
+ postgresql-run-socket.patch
+ postgresql-perl-rpath.patch
+ postgresql-command.patch
+ postgresql.service
+ postgresql-check-db-dir
+ postgresql.sysusers
+ postgresql.tmpfiles
+ pgenv.sh)
+md5sums=('2d20502cbce1c7531bb69e56f5c5c65a'
+ '92249e35353927d9f79df66a4101b3fa'
+ '7d899fe96b0044e120e49bab4205610d'
+ '2c74b38d3ca580733daaf60d7c564792'
+ '77f41e79ec546d40b24a46cd646e3c2f'
+ '848c7c58ac8831fb5323e3446be5afcf'
+ '2050d34e4dfa05f3c6fe4cd7615eaa4b'
+ '9f34d430c5ef0ddca8843b58f71c0b3d'
+ '37bbc58222c61b8e0533eab845ca94f5')
+
+prepare() {
+ cd postgresql-${pkgver}
+ patch -p1 < ../postgresql-run-socket.patch
+ patch -p1 < ../postgresql-perl-rpath.patch
+ patch -p1 < ../postgresql-command.patch
+}
+
+build() {
+ cd postgresql-${pkgver}
+ # removed: --with-libxml, --with-ldap --with-llvm
+ local options=(
+ --prefix=/opt/${pkgbase}
+ --sysconfdir=/etc
+ --with-gssapi
+ --with-openssl
+ --with-perl
+ --with-python
+ --with-tcl
+ --with-pam
+ --with-system-tzdata=/usr/share/zoneinfo
+ --with-uuid=e2fs
+ --with-icu
+ --with-systemd
+ --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/python2
+ make world
+}
+
+_postgres_check() {
+ make "${1}" || (find . -name regression.diffs | \
+ while read -r line; do
+ echo "make ${1} failure: ${line}"
+ cat "${line}"
+ done; exit 1)
+}
+
+check() {
+ cd postgresql-${pkgver}
+ _postgres_check check
+ _postgres_check check-world
+}
+
+package_postgresql11-libs() {
+ pkgdesc="Libraries for use with PostgreSQL"
+ depends=('krb5' 'openssl>=1.0.0' 'readline>=6.0' 'zlib' 'libldap')
+ provides=("${pkgbase}-client" 'libpq.so' 'libecpg.so' 'libecpg_compat.so' 'libpgtypes.so')
+ conflicts=("${pkgbase}-client")
+
+ pushd postgresql-${pkgver}
+
+ # install license
+ install -Dm 644 COPYRIGHT -t "${pkgdir}/opt/${pkgbase}/share/licenses/${pkgname}"
+
+
+
+ # 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}"/opt/${pkgbase}/share/man/man1/${util}.1
+ done
+
+ cd src/include
+
+ install -d "${pkgdir}"/opt/${pkgbase}/include/{libpq,postgresql/internal/libpq}
+
+ # these headers are needed by the public headers of the interfaces
+ install -m 644 pg_config.h "${pkgdir}/opt/${pkgbase}/include"
+ install -m 644 pg_config_os.h "${pkgdir}/opt/${pkgbase}/include"
+ install -m 644 pg_config_ext.h "${pkgdir}/opt/${pkgbase}/include"
+ install -m 644 postgres_ext.h "${pkgdir}/opt/${pkgbase}/include"
+ install -m 644 libpq/libpq-fs.h "${pkgdir}/opt/${pkgbase}/include/libpq"
+ install -m 644 pg_config_manual.h "${pkgdir}/opt/${pkgbase}/include"
+
+ # these he aders are needed by the not-so-public headers of the interfaces
+ install -m 644 c.h "${pkgdir}/opt/${pkgbase}/include/postgresql/internal"
+ install -m 644 port.h "${pkgdir}/opt/${pkgbase}/include/postgresql/internal"
+ install -m 644 postgres_fe.h "${pkgdir}/opt/${pkgbase}/include/postgresql/internal"
+ install -m 644 libpq/pqcomm.h "${pkgdir}/opt/${pkgbase}/include/postgresql/internal/libpq"
+
+ # this utility is to be sourced in order to find proper libs and bins
+ popd
+ install -m 755 ../pgenv.sh "${pkgdir}/opt/${pkgbase}/bin"
+}
+
+package_postgresql11-docs() {
+ pkgdesc="HTML documentation for PostgreSQL"
+ options=('docs')
+
+ cd postgresql-${pkgver}
+
+ install -Dm 644 COPYRIGHT -t "${pkgdir}/opt/${pkgbase}/share/licenses/${pkgname}"
+
+ make -C doc/src/sgml DESTDIR="${pkgdir}" install-html
+ chown -R root:root "${pkgdir}/opt/${pkgbase}/share/doc/html"
+
+ # clean up
+ rmdir "${pkgdir}"/opt/${pkgbase}/share/man/man{1,3,7}
+ rmdir "${pkgdir}"/opt/${pkgbase}/share/man
+}
+
+package_postgresql11() {
+ pkgdesc='Sophisticated object-relational DBMS'
+ # backup=('etc/pam.d/postgresql' 'etc/logrotate.d/postgresql')
+ depends=("${pkgbase}-libs>=${pkgver}" 'krb5' 'libxml2' 'readline>=6.0'
+ 'openssl>=1.0.0' 'pam' 'icu' 'systemd-libs' 'libldap' 'llvm-libs' 'libxslt')
+ optdepends=('python2: for PL/Python 2 support'
+ 'python: for PL/Python 3 support'
+ 'perl: for PL/Perl support'
+ 'tcl: for PL/Tcl support')
+ options=('staticlibs')
+ install=postgresql.install
+
+ pushd postgresql-${pkgver}
+
+ # install
+ make DESTDIR="${pkgdir}" install
+ make -C contrib DESTDIR="${pkgdir}" install
+ make -C doc/src/sgml DESTDIR="${pkgdir}" install-man
+
+ # 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}"/opt/${pkgbase}/share/man/man1/${util}.1
+ done
+
+ install -Dm 644 COPYRIGHT -t "${pkgdir}/opt/${pkgbase}/share/licenses/${pkgname}"
+
+ popd
+ install -Dm 755 postgresql-check-db-dir -t "${pkgdir}/opt/${pkgbase}/bin"
+
+ #install -Dm 644 postgresql.pam "${pkgdir}/etc/pam.d/${pkgname}"
+
+ install -Dm 644 postgresql.service "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
+ install -Dm 644 postgresql.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
+ install -Dm 644 postgresql.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
+
+ # clean up unneeded installed items
+ rm -rf "${pkgdir}/opt/${pkgbase}/include/internal"
+ rm -rf "${pkgdir}/opt/${pkgbase}/include/informix"
+ rm -rf "${pkgdir}/opt/${pkgbase}/include/libpq"
+ find "${pkgdir}//opt/${pkgbase}/include" -maxdepth 1 -type f -execdir rm {} +
+ rmdir "${pkgdir}/opt/${pkgbase}/share/doc/html"
+}
+
+# vim: ts=2 sw=2 et:
diff --git a/pgenv.sh b/pgenv.sh
new file mode 100755
index 000000000000..49fa2a0d031c
--- /dev/null
+++ b/pgenv.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export PGDATA=/var/lib/postgres/data11
+export PATH=/opt/postgresql11/bin:$PATH
+export LD_LIBRARY_PATH=/opt/postgresql11/lib
diff --git a/postgresql-check-db-dir b/postgresql-check-db-dir
new file mode 100755
index 000000000000..8d4bac149218
--- /dev/null
+++ b/postgresql-check-db-dir
@@ -0,0 +1,42 @@
+#!/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=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
+ 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
diff --git a/postgresql-command.patch b/postgresql-command.patch
new file mode 100644
index 000000000000..ad832c25d79e
--- /dev/null
+++ b/postgresql-command.patch
@@ -0,0 +1,11 @@
+--- postgresql-11.9/src/backend/commands/collationcmds.c.ori 2020-08-10 23:17:40.000000000 +0200
++++ postgresql-11.9/src/backend/commands/collationcmds.c 2022-03-29 14:33:57.291063452 +0200
+@@ -444,7 +444,7 @@ get_icu_language_tag(const char *localen
+ UErrorCode status;
+
+ status = U_ZERO_ERROR;
+- uloc_toLanguageTag(localename, buf, sizeof(buf), TRUE, &status);
++ uloc_toLanguageTag(localename, buf, sizeof(buf), true, &status);
+ if (U_FAILURE(status))
+ ereport(ERROR,
+ (errmsg("could not convert locale name \"%s\" to language tag: %s",
diff --git a/postgresql-perl-rpath.patch b/postgresql-perl-rpath.patch
new file mode 100644
index 000000000000..cad6118d6d7e
--- /dev/null
+++ b/postgresql-perl-rpath.patch
@@ -0,0 +1,13 @@
+diff -upr postgresql-11.9/src/pl/plperl/GNUmakefile.orig postgresql-11.9/src/pl/plperl/GNUmakefile
+--- postgresql-11.9/src/pl/plperl/GNUmakefile.orig 2022-03-27 16:11:28.482361857 +0200
++++ postgresql-11.9/src/pl/plperl/GNUmakefile 2022-03-27 16:15:57.076855848 +0200
+@@ -55,6 +55,9 @@ endif # win32
+
+ 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 plperl_call plperl_transaction
+ # if Perl can support two interpreters in one backend,
diff --git a/postgresql-run-socket.patch b/postgresql-run-socket.patch
new file mode 100644
index 000000000000..cf191faae982
--- /dev/null
+++ b/postgresql-run-socket.patch
@@ -0,0 +1,12 @@
+diff -upr postgresql-11.9/src/include/pg_config_manual.h.orig postgresql-11.9/src/include/pg_config_manual.h
+--- postgresql-11.9/src/include/pg_config_manual.h.orig 2022-03-27 15:53:14.701448511 +0200
++++ postgresql-11.9/src/include/pg_config_manual.h 2022-03-27 16:04:25.334369068 +0200
+@@ -179,7 +179,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"
+
+ /*
+ * This is the default event source for Windows event log.
diff --git a/postgresql.install b/postgresql.install
new file mode 100644
index 000000000000..0edb9fbe3b61
--- /dev/null
+++ b/postgresql.install
@@ -0,0 +1,7 @@
+post_upgrade() {
+ # Prints the warning message if the database version on disk
+ # does not match the PostgreSQL major version.
+ if [ -d /var/lib/postgres/data11 ]; then
+ /opt/postgresql14/bin/postgresql-check-db-dir /var/lib/postgres/data || true
+ fi
+}
diff --git a/postgresql.service b/postgresql.service
new file mode 100644
index 000000000000..722f7ee4f9ce
--- /dev/null
+++ b/postgresql.service
@@ -0,0 +1,46 @@
+[Unit]
+Description=PostgreSQL 11 database server
+After=network.target
+
+[Service]
+Type=notify
+TimeoutSec=120
+User=postgres
+Group=postgres
+
+Environment=PGROOT=/var/lib/postgres
+Environment=PATH=/opt/postgresql11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+Environment=LD_LIBRARY_PATH=/opt/postgresql11/lib
+
+SyslogIdentifier=postgres
+PIDFile=/var/lib/postgres/data11/postmaster.pid
+RuntimeDirectory=postgresql
+RuntimeDirectoryMode=755
+
+ExecStartPre=/opt/postgresql11/bin/postgresql-check-db-dir ${PGROOT}/data11
+ExecStart=/opt/postgresql11/bin/postgres -D ${PGROOT}/data11
+ExecStartPost=/usr/bin/echo "Before using, source /opt/postgresql11/bin/pgenv.sh to set PostgreSQL environment"
+ExecReload=/bin/kill -HUP ${MAINPID}
+KillMode=mixed
+KillSignal=SIGINT
+
+# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
+# killing Postgres, so adjust it downward
+OOMScoreAdjust=-200
+
+# Additional security-related features
+PrivateTmp=true
+ProtectHome=true
+ProtectSystem=full
+NoNewPrivileges=true
+ProtectControlGroups=true
+ProtectKernelModules=true
+ProtectKernelTunables=true
+PrivateDevices=true
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=true
+RestrictRealtime=true
+SystemCallArchitectures=native
+
+[Install]
+WantedBy=multi-user.target
diff --git a/postgresql.sysusers b/postgresql.sysusers
new file mode 100644
index 000000000000..a1711b1cc3df
--- /dev/null
+++ b/postgresql.sysusers
@@ -0,0 +1 @@
+u postgres - "PostgreSQL user" /var/lib/postgres /bin/bash
diff --git a/postgresql.tmpfiles b/postgresql.tmpfiles
new file mode 100644
index 000000000000..f01dcc0e4e37
--- /dev/null
+++ b/postgresql.tmpfiles
@@ -0,0 +1,2 @@
+d /var/lib/postgres/data11 700 postgres postgres
+h /var/lib/postgres/data11 - - - - +C