commit 905d2346b79d8cb0e6708afad85f781e9272550c Author: EnumDev Date: Tue Sep 30 20:55:34 2025 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e58e5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Exclude bpm archives +*.bpm \ No newline at end of file diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..4104c82 --- /dev/null +++ b/check-version.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Git repository +REPO="https://git.postgresql.org/git/postgresql.git" + +# Get tag name using 'git ls-remote' +TAG_NAME=$(git ls-remote --exit-code --refs --tags --sort='v:refname' "$REPO" | cut -d'/' -f3 | grep '^REL' | grep -v 'BETA\|RC' | tail -1) + +# Trim prefix +VERSION=${TAG_NAME//REL_/} + +# Replace '_' with '.' +VERSION=${VERSION//_/.} + +echo "$VERSION" diff --git a/pkg.info b/pkg.info new file mode 100644 index 0000000..b1e1c18 --- /dev/null +++ b/pkg.info @@ -0,0 +1,44 @@ +name: postgresql +description: A powerful, open source object-relational database system +version: "18.0" +revision: 1 +url: https://www.postgresql.org/ +license: PostgreSQL +architecture: any +type: source +depends: + - gcc-libs + - glibc + - icu + - krb5 + - openldap + - libxml2 + - libxslt + - llvm-libs + - lz4 + - openssl + - pam + - readline + - sysusers + - util-linux + - zlib + - zstd +optional_depends: + - perl + - python3 + - tcl +make_depends: + - clang + - docbook-xml + - docbook-xsl-nons + - llvm + - perl + - perl-ipc-run + - python3 + - tcl + - bzip2 +downloads: + - url: https://ftp.postgresql.org/pub/source/v${BPM_PKG_VERSION}/postgresql-${BPM_PKG_VERSION}.tar.bz2 + extract_to_bpm_source: true + extract_strip_components: 1 + checksum: 0d5b903b1e5fe361bca7aa9507519933773eb34266b1357c4e7780fdee6d6078 diff --git a/post_upgrade.sh b/post_upgrade.sh new file mode 100644 index 0000000..43b1bc3 --- /dev/null +++ b/post_upgrade.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -d /srv/pgsql/data ]; then + /usr/bin/postgresql-check-db-dir /srv/pgsql/data || true +fi diff --git a/source-files/postgresql.esv b/source-files/postgresql.esv new file mode 100644 index 0000000..62ffdde --- /dev/null +++ b/source-files/postgresql.esv @@ -0,0 +1,6 @@ +name: postgresql +description: Postgresql system daemon +type: background +start_cmd: /etc/esvm/scripts/postgresql.sh +exit_method: kill +restart: true diff --git a/source-files/postgresql.sh b/source-files/postgresql.sh new file mode 100644 index 0000000..f045e14 --- /dev/null +++ b/source-files/postgresql.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +PGROOT=/srv/postgresql +PGDATA="$PGROOT"/data + +[ -d /run/postgresql ] || install -d -o postgres -g postgres /run/postgresql + +[ "$PGROOT" != "/srv/postgresql" ] && ln -sf "$PGROOT" /srv/postgresql + +if [ ! -d "$PGDATA" ]; then + install -dm0700 -o postgres -g postgres "$PGDATA" + su - postgres -m -c "/usr/bin/initdb -D '$PGDATA'" + + [ -f /etc/postgresql/postgresql.conf ] && ln -sf /etc/postgresql/postgresql.conf "$PGDATA"/postgresql.conf +fi + +exec su - postgres -m -c "/usr/bin/postgres -D '$PGDATA'" diff --git a/source-files/sysusers b/source-files/sysusers new file mode 100644 index 0000000..4efe862 --- /dev/null +++ b/source-files/sysusers @@ -0,0 +1 @@ +u postgres 41 "PostgreSQL user" /srv/postgresql/ /bin/bash diff --git a/source.sh b/source.sh new file mode 100644 index 0000000..9849599 --- /dev/null +++ b/source.sh @@ -0,0 +1,60 @@ +# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package +# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE +# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT + +# The prepare function is executed in the root of the temp directory +# This function is used for putting downloaded files to the correct location or applying patches +prepare() { + # Fix typo in sgml file + sed -i -e 's/"app-pgchecksums "/"app-pgchecksums"/' "$BPM_SOURCE"/doc/src/sgml/ref/pg_combinebackup.sgml + + # Change server socket location from /tmp to /run/postgresql + sed -i -e '/DEFAULT_PGSOCKET_DIR/s@/tmp@/run/postgresql@' "$BPM_SOURCE"/src/include/pg_config_manual.h +} + +# The build function is executed in the source directory +# This function is used to compile the source code +build() { + ./configure --prefix=/usr \ + --sysconfdir=/etc \ + --mandir=/usr/share/man \ + --datadir=/usr/share/postgresql \ + --disable-rpath \ + --enable-nls \ + --enable-tap-tests \ + --with-gssapi \ + --with-icu \ + --with-ldap \ + --with-libxml \ + --with-libxslt \ + --with-llvm \ + --with-lz4 \ + --with-openssl \ + --with-pam \ + --with-perl \ + --with-python \ + --with-readline \ + --with-system-tzdata=/usr/share/zoneinfo \ + --without-systemd \ + --with-tcl \ + --with-uuid=e2fs \ + --with-zstd + make +} + +# The package function is executed in the source directory +# This function is used to move the compiled files into the output directory +package() { + make DESTDIR="$BPM_OUTPUT" install install-docs + make -C contrib DESTDIR="$BPM_OUTPUT" install + + # Install esvm service + install -Dm755 "$BPM_WORKDIR"/postgresql.sh "$BPM_OUTPUT"/etc/esvm/scripts/postgresql.sh + install -Dm644 "$BPM_WORKDIR"/postgresql.esv "$BPM_OUTPUT"/etc/esvm/services/postgresql.esv + + # Install sysusers file + install -Dm644 "$BPM_WORKDIR"/sysusers "$BPM_OUTPUT"/usr/lib/sysusers.d/postgresql.conf + + # Install package license + install -Dm644 "$BPM_SOURCE"/COPYRIGHT "$BPM_OUTPUT"/usr/share/licenses/postgresql/COPYRIGHT +}