From e31ee4eb6ddb76baf20b6f656c6948b3c4511c55 Mon Sep 17 00:00:00 2001 From: Alexander Baldeck Date: Tue, 23 Apr 2019 22:59:50 +0000 Subject: [PATCH] * update postgresql to 11.2 --- postgresql/PKGBUILD | 48 ++++++++++++++++++----------- postgresql/postgresql-check-db-dir | 49 ++++++++++++++++++++++++++++++ postgresql/postgresql.logrotate | 4 +++ postgresql/postgresql.pam | 3 ++ postgresql/postgresql.service | 35 +++++++++++++++++++++ postgresql/postgresql.sysusers | 1 + postgresql/postgresql.tmpfiles | 1 + 7 files changed, 123 insertions(+), 18 deletions(-) create mode 100755 postgresql/postgresql-check-db-dir create mode 100644 postgresql/postgresql.logrotate create mode 100644 postgresql/postgresql.pam create mode 100644 postgresql/postgresql.service create mode 100644 postgresql/postgresql.sysusers create mode 100644 postgresql/postgresql.tmpfiles diff --git a/postgresql/PKGBUILD b/postgresql/PKGBUILD index abb15da5fa..756973f159 100644 --- a/postgresql/PKGBUILD +++ b/postgresql/PKGBUILD @@ -4,35 +4,42 @@ pkgbase=postgresql pkgname=('postgresql-libs' 'postgresql-docs' 'postgresql') -pkgver=11.1 +pkgver=11.2 _majorver=${pkgver%.*} pkgrel=3 pkgdesc='Sophisticated object-relational DBMS' url='https://www.postgresql.org/' -arch=('x86_64' 'powerpc64le') +arch=(x86_64 powerpc64le) license=('custom:PostgreSQL') -makedepends=('krb5' 'libxml2' 'python' 'python2' 'perl' 'tcl>=8.6.0' 'openssl>=1.0.0' 'pam' 'zlib' 'icu' 'systemd' 'libldap') +makedepends=('krb5' 'libxml2' 'python' 'python2' 'perl' 'tcl>=8.6.0' 'openssl>=1.0.0' + 'pam' 'zlib' 'icu' 'systemd' 'libldap' 'llvm' 'clang') source=(https://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2 postgresql-run-socket.patch postgresql-perl-rpath.patch postgresql.pam postgresql.logrotate postgresql.service - postgresql-check-db-dir) -sha256sums=('90815e812874831e9a4bf6e1136bf73bc2c5a0464ef142e2dfea40cda206db08' + postgresql-check-db-dir + postgresql.sysusers + postgresql.tmpfiles) +sha256sums=('2676b9ce09c21978032070b6794696e0aa5a476e3d21d60afc036dc0a9c09405' '8538619cb8bea51078b605ad64fe22abd6050373c7ae3ad6595178da52f6a7d9' '5f73b54ca6206bd2c469c507830261ebd167baca074698d8889d769c33f98a31' '57dfd072fd7ef0018c6b0a798367aac1abb5979060ff3f9df22d1048bb71c0d5' '6abb842764bbed74ea4a269d24f1e73d1c0b1d8ecd6e2e6fb5fb10590298605e' 'ad025a5fb623b1a1e9dff0cc62cc63f66244bb27d81370a6251aa29e8574be94' - '2bbd8c4e51b70223d274fef3a167af096f44af3d3c41ae505ad11c606674e7c5') -sha512sums=('35d00984e9f5f063a5b96e97aa1b40381ab76d07b2336bda5981fd80bef1324f56eefca5069ae78770ecd6ece5df85264e599fdb3478ecb71d4fdd0d7b6becca' + '2bbd8c4e51b70223d274fef3a167af096f44af3d3c41ae505ad11c606674e7c5' + '7fa8f0ef3f9d40abd4749cc327c2f52478cb6dfb6e2405bd0279c95e9ff99f12' + 'ff7c84f78f73b87ade8e2d91d2958808be5a9af79c8b13430238ae953c7fe853') +sha512sums=('dae00a543fdeed36bc338abd4ccfd9fe9a8b6b2b7eaa00b1078e4f27802de75a461c27da2800bc9dd64e658681e5787bd03764bde79940656cae1e8c8716f011' '031efe12d18ce386989062327cdbbe611c5ef1f94e4e1bead502304cb3e2d410af533d3c7f1109d24f9da9708214fe32f9a10ba373a3ca8d507bdb521fbb75f7' '38302242b30c01c7981574ed28d9cbd9dc73bf6b56ba3a032afb5d0885ae83e5aa72ce578bf2422214dfa6c46f09d0bdd7cccaeb3c25d58754eb1a34f8bf5615' '1e6183ab0eb812b3ef687ac2c26ce78f7cb30540f606d20023669ac00ba04075487fb72e4dc89cc05dab0269ff6aca98fc1167cc75669c225b88b592482fbf67' '9ab4da01337ffbab8faec0e220aaa2a642dbfeccf7232ef2645bdc2177a953f17ee3cc14a4d8f8ebd064e1dae8b3dba6029adbffb8afaabea383963213941ba8' 'acd60166ff513b16778705e824944945cd0a98abc519fa5f0232252e0e9c85460c6f8b85459d9692d1f3df1caaaf8909c3e7f785be99c2d3fb98a10b2641a795' - '73af1cd31638791f81aa2623d51188364107a57b55e4deba6691cd99e96ae5ea0dd94b25a0e95d9e21ac64f36f71919a05cd31233c754bde025215a5a02e055c') + '73af1cd31638791f81aa2623d51188364107a57b55e4deba6691cd99e96ae5ea0dd94b25a0e95d9e21ac64f36f71919a05cd31233c754bde025215a5a02e055c' + '36f7a5d38370fdc4d4267fd5a8a8330f152a1077bf0f065b89d4a7b8112ccd42be2c46c863791b77de02013f28275a42219f4236e7cb837c3f8cfd5fcc7d3373' + '27094b07fd57a077da9cb31e1970998766e7aff5bd7a2c4545fe3a5a96e84ecc6e5c541f418b2f395c06404fa29a17d9f88db0f4efdd392a02ac029662697619') prepare() { cd postgresql-${pkgver} @@ -59,6 +66,7 @@ build() { --with-icu --with-systemd --with-ldap + --with-llvm --enable-nls --enable-thread-safety --disable-rpath @@ -157,14 +165,14 @@ package_postgresql-docs() { package_postgresql() { pkgdesc='Sophisticated object-relational DBMS' backup=('etc/pam.d/postgresql' 'etc/logrotate.d/postgresql') - depends=("postgresql-libs>=${pkgver}" 'krb5' 'libxml2' 'readline>=6.0' 'openssl>=1.0.0' 'pam' 'icu' 'libsystemd' 'libldap') + depends=("postgresql-libs>=${pkgver}" 'krb5' 'libxml2' 'readline>=6.0' 'openssl>=1.0.0' 'pam' 'icu' 'systemd-libs' 'libldap') optdepends=('python2: for PL/Python 2 support' 'python: for PL/Python 3 support' 'perl: for PL/Perl support' 'tcl: for PL/Tcl support' + 'llvm: for JIT compilation support' 'postgresql-old-upgrade: upgrade from previous major version using pg_upgrade') options=('staticlibs') - install=postgresql.install cd postgresql-${pkgver} @@ -190,19 +198,23 @@ package_postgresql() { rm "${pkgdir}"/usr/share/man/man1/${util}.1 done + install -Dm 644 COPYRIGHT -t "${pkgdir}/usr/share/licenses/${pkgname}" + + cd "${srcdir}" + install -Dm 755 postgresql-check-db-dir -t "${pkgdir}/usr/bin" + + install -Dm 644 ${pkgname}.pam "${pkgdir}/etc/pam.d/${pkgname}" + install -Dm 644 ${pkgname}.logrotate "${pkgdir}/etc/logrotate.d/${pkgname}" + + install -Dm 644 ${pkgname}.service -t "${pkgdir}/usr/lib/systemd/system" + install -Dm 644 ${pkgname}.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf" + install -Dm 644 ${pkgname}.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf" + # 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 {} + rmdir "${pkgdir}/usr/share/doc/postgresql/html" - - install -Dm 644 "${srcdir}/postgresql.service" -t "${pkgdir}/usr/lib/systemd/system" - install -Dm 755 "${srcdir}/postgresql-check-db-dir" -t "${pkgdir}/usr/bin" - - install -Dm 644 "${srcdir}/postgresql.pam" "${pkgdir}/etc/pam.d/postgresql" - install -Dm 644 "${srcdir}/postgresql.logrotate" "${pkgdir}/etc/logrotate.d/postgresql" - - install -Dm 644 COPYRIGHT -t "${pkgdir}/usr/share/licenses/${pkgname}" } # vim: ts=2 sw=2 et: diff --git a/postgresql/postgresql-check-db-dir b/postgresql/postgresql-check-db-dir new file mode 100755 index 0000000000..fabca97e2c --- /dev/null +++ b/postgresql/postgresql-check-db-dir @@ -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=11 +# PREVMAJORVERSION is the previous major version +PREVMAJORVERSION=10 + +# 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 diff --git a/postgresql/postgresql.logrotate b/postgresql/postgresql.logrotate new file mode 100644 index 0000000000..9c36918be5 --- /dev/null +++ b/postgresql/postgresql.logrotate @@ -0,0 +1,4 @@ +/var/log/postgresql.log { + copytruncate + missingok +} diff --git a/postgresql/postgresql.pam b/postgresql/postgresql.pam new file mode 100644 index 0000000000..53724d1f86 --- /dev/null +++ b/postgresql/postgresql.pam @@ -0,0 +1,3 @@ +auth required pam_unix.so +account required pam_unix.so +session required pam_unix.so diff --git a/postgresql/postgresql.service b/postgresql/postgresql.service new file mode 100644 index 0000000000..3981058622 --- /dev/null +++ b/postgresql/postgresql.service @@ -0,0 +1,35 @@ +[Unit] +Description=PostgreSQL database server +After=network.target + +[Service] +Type=notify +TimeoutSec=120 +User=postgres +Group=postgres + +Environment=PGROOT=/var/lib/postgres + +SyslogIdentifier=postgres +PIDFile=/var/lib/postgres/data/postmaster.pid +RuntimeDirectory=postgresql +RuntimeDirectoryMode=755 + +ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data +ExecStart=/usr/bin/postgres -D ${PGROOT}/data +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 + +[Install] +WantedBy=multi-user.target diff --git a/postgresql/postgresql.sysusers b/postgresql/postgresql.sysusers new file mode 100644 index 0000000000..a1711b1cc3 --- /dev/null +++ b/postgresql/postgresql.sysusers @@ -0,0 +1 @@ +u postgres - "PostgreSQL user" /var/lib/postgres /bin/bash diff --git a/postgresql/postgresql.tmpfiles b/postgresql/postgresql.tmpfiles new file mode 100644 index 0000000000..1d8b2d110c --- /dev/null +++ b/postgresql/postgresql.tmpfiles @@ -0,0 +1 @@ +d /var/lib/postgres/data 700 postgres postgres