Skip to contentSkip to conversation

postgresql: add PGXS extension support and pg_cron

PATCH New Babanpreet Singh 1 participant 4 messages Nov 11

lore
Share & tools
lore
#0 lore raw

cover postgresql: add PGXS extension support and pg_cron

PGXS extensions cannot be cross-built in OE today. Patch 1 makes the postgresql recipe support that, patch 2 adds a class for extension recipes and patch 3 adds pg_cron as the first one.

Built for qemux86-64 and qemuarm64 and run in a qemux86-64 image. I also built pgvector, pgaudit, pg_partman, orafce and hll through the class to check it is not specific to pg_cron.

Babanpreet Singh (3):
postgresql: make PGXS usable for cross-building extensions pgxs.bbclass: add class for PostgreSQL extensions
pg-cron: add recipe

 meta-oe/classes/pgxs.bbclass                  | 22 +++++++
 .../packagegroups/packagegroup-meta-oe.bb     |  1 +
 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb  | 13 ++++
 .../recipes-dbs/postgresql/files/pg_config    | 43 +++++++++++++
 meta-oe/recipes-dbs/postgresql/postgresql.inc | 62 +++++++++++++++++--
 5 files changed, 135 insertions(+), 6 deletions(-)
 create mode 100644 meta-oe/classes/pgxs.bbclass
 create mode 100644 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb
 create mode 100755 meta-oe/recipes-dbs/postgresql/files/pg_config
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 postgresql: make PGXS usable for cross-building extensions

Extensions built with PGXS need pg_config and Makefile.global, but pg_config is a target binary and the staged Makefile.global has its paths stripped.

Stage a shell pg_config in crossscripts and fix up the staged PGXS makefiles so extensions can be built against the sysroot.

---
 .../recipes-dbs/postgresql/files/pg_config    | 43 +++++++++++++
 meta-oe/recipes-dbs/postgresql/postgresql.inc | 62 +++++++++++++++++--
 2 files changed, 99 insertions(+), 6 deletions(-)
 create mode 100755 meta-oe/recipes-dbs/postgresql/files/pg_config
meta-oe/recipes-dbs/postgresql/files/pg_config new file +43 -0
new file mode 100755
index 0000000000..1fab031a90
@@ -0,0 +1,43 @@
+#!/bin/sh
+# pg_config for cross builds, the real one is a target binary.
+# Build paths are answered inside the sysroot, install paths as on the target.
+
+sysroot=$(cd "$(dirname "$0")" && pwd -P)
+sysroot=${sysroot%@CROSSSCRIPTS@}
+
+value() {
+	case $1 in
+	--bindir) echo "@BINDIR@" ;;
+	--docdir) echo "@DOCDIR@" ;;
+	--htmldir) echo "@DOCDIR@" ;;
+	--includedir) echo "$sysroot@INCLUDEDIR@" ;;
+	--pkgincludedir) echo "$sysroot@PKGINCLUDEDIR@" ;;
+	--includedir-server) echo "$sysroot@PKGINCLUDEDIR@/server" ;;
+	--libdir) echo "$sysroot@LIBDIR@" ;;
+	--pkglibdir) echo "@PKGLIBDIR@" ;;
+	--localedir) echo "@LOCALEDIR@" ;;
+	--mandir) echo "@MANDIR@" ;;
+	--sharedir) echo "@SHAREDIR@" ;;
+	--sysconfdir) echo "@SYSCONFDIR@" ;;
+	--pgxs) echo "$sysroot@PKGLIBDIR@/pgxs/src/makefiles/pgxs.mk" ;;
+	--version) echo "PostgreSQL @VERSION@" ;;
+	*)
+		echo "pg_config: $1 is not available in a cross build" >&2
+		exit 1
+		;;
+	esac
+}
+
+all="bindir docdir htmldir includedir pkgincludedir includedir-server \
+	libdir pkglibdir localedir mandir sharedir sysconfdir pgxs version"
+
+if [ $# -eq 0 ]; then
+	for opt in $all; do
+		printf '%s = %s\n' "$(echo "$opt" | tr a-z A-Z)" "$(value "--$opt")"
+	done
+	exit 0
+fi
+
+for arg; do
+	value "$arg"
+done
meta-oe/recipes-dbs/postgresql/postgresql.inc +56 -6

78 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 pgxs.bbclass: add class for PostgreSQL extensions

In reply to Babanpreet Singh

Extensions that build with PGXS need the same dependency, make arguments and FILES. Put them in a class so a recipe only has to inherit pgxs.

---
 meta-oe/classes/pgxs.bbclass | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 meta-oe/classes/pgxs.bbclass
meta-oe/classes/pgxs.bbclass new file +22 -0
new file mode 100644
index 0000000000..b1c7aca264
@@ -0,0 +1,22 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+# Class for PostgreSQL extensions that are built with PGXS
+
+DEPENDS += "postgresql"
+
+# USE_PGXS is for makefiles that can also build inside the PostgreSQL tree
+EXTRA_OEMAKE:append = " USE_PGXS=1 PG_CONFIG=pg_config"
+
+pgxs_do_install() {
+    oe_runmake install DESTDIR=${D}
+}
+
+EXPORT_FUNCTIONS do_install
+
+FILES:${PN} += "${libdir}/postgresql ${datadir}/postgresql"
+
+RDEPENDS:${PN} += "postgresql"
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 pg-cron: add recipe

In reply to Babanpreet Singh

pg_cron is a cron-based job scheduler that runs inside PostgreSQL.

---
 .../packagegroups/packagegroup-meta-oe.bb           |  1 +
 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb        | 13 +++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index ebd66425de..7fba0722b9 100644
@@ -214,6 +214,7 @@ RDEPENDS:packagegroup-meta-oe-dbs = "\
     libdbi \
     lmdb \
     mariadb \
+    pg-cron \
     postgresql \
     psqlodbc \
     rocksdb \
meta-oe/recipes-dbs/pg-cron/pg-cron_1.6.8.bb new file +13 -0
new file mode 100644
index 0000000000..9f9a59b398
@@ -0,0 +1,13 @@
+SUMMARY = "Run periodic jobs in PostgreSQL"
+DESCRIPTION = "pg_cron is a cron-based job scheduler that runs inside \
+PostgreSQL as an extension. Jobs are scheduled from SQL with the usual \
+cron syntax and run by a background worker in the server."
+HOMEPAGE = "https://github.com/citusdata/pg_cron"
+BUGTRACKER = "https://github.com/citusdata/pg_cron/issues"
+LICENSE = "PostgreSQL"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b70f68d78dbcc36c5654d795cee59b0d"
+
+SRC_URI = "git://github.com/citusdata/pg_cron.git;protocol=https;branch=main;tag=v${PV}"
+SRCREV = "2323864075a50f234235f98e567eb958f923b2b3"
+
+inherit pgxs
Signature · 1 line
2.43.0