summaryrefslogtreecommitdiffstats
path: root/debhelper
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:02:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:02:19 +0000
commite308bcff5a610d6a3bbe33b3769f03f6d4533b16 (patch)
tree6a8ed4eb26cd55f3a24165bc1d9b9a1f0ab62e8c /debhelper
parentInitial commit. (diff)
downloadpostgresql-common-e308bcff5a610d6a3bbe33b3769f03f6d4533b16.tar.xz
postgresql-common-e308bcff5a610d6a3bbe33b3769f03f6d4533b16.zip
Adding upstream version 248.upstream/248upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debhelper')
-rw-r--r--debhelper/Debian/Debhelper/Buildsystem/pgxs.pm58
-rw-r--r--debhelper/Debian/Debhelper/Buildsystem/pgxs_loop.pm33
-rw-r--r--debhelper/Debian/Debhelper/Sequence/pgxs.pm22
-rw-r--r--debhelper/Debian/Debhelper/Sequence/pgxs_loop.pm23
-rw-r--r--debhelper/Debian/Debhelper/pgxs.pm38
-rwxr-xr-xdebhelper/dh_pgxs_test11
-rw-r--r--debhelper/dh_pgxs_test.pod44
7 files changed, 229 insertions, 0 deletions
diff --git a/debhelper/Debian/Debhelper/Buildsystem/pgxs.pm b/debhelper/Debian/Debhelper/Buildsystem/pgxs.pm
new file mode 100644
index 0000000..f1270ea
--- /dev/null
+++ b/debhelper/Debian/Debhelper/Buildsystem/pgxs.pm
@@ -0,0 +1,58 @@
+# A debhelper build system class for building PostgreSQL extension modules using PGXS
+#
+# Per PostgreSQL major version, a `build-$version` subdirectory is created.
+#
+# Copyright: © 2020 Christoph Berg
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::pgxs;
+
+use strict;
+use warnings;
+use parent qw(Debian::Debhelper::Buildsystem);
+use Cwd;
+use Debian::Debhelper::Dh_Lib;
+use Debian::Debhelper::pgxs;
+
+sub DESCRIPTION {
+ "PGXS (PostgreSQL extensions), building in subdirectory per PostgreSQL version"
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ unless (-e $this->get_sourcepath("debian/pgversions")) {
+ error("debian/pgversions is required to build with PGXS");
+ }
+ return (-e $this->get_sourcepath("Makefile")) ? 1 : 0;
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ $this->enforce_in_source_building();
+ return $this;
+}
+
+sub build {
+ my $this=shift;
+ $this->doit_in_sourcedir(qw(pg_buildext build build-%v));
+}
+
+sub install {
+ my $this=shift;
+ my $pattern = package_pattern();
+ $this->doit_in_sourcedir(qw(pg_buildext install build-%v), $pattern);
+}
+
+sub test {
+ my $this=shift;
+ verbose_print("Postponing tests to install stage");
+}
+
+sub clean {
+ my $this=shift;
+ my $pattern = package_pattern();
+ $this->doit_in_sourcedir(qw(pg_buildext clean build-%v), $pattern);
+}
+
+1;
diff --git a/debhelper/Debian/Debhelper/Buildsystem/pgxs_loop.pm b/debhelper/Debian/Debhelper/Buildsystem/pgxs_loop.pm
new file mode 100644
index 0000000..716bcbf
--- /dev/null
+++ b/debhelper/Debian/Debhelper/Buildsystem/pgxs_loop.pm
@@ -0,0 +1,33 @@
+# A debhelper build system class for building PostgreSQL extension modules using PGXS
+#
+# For packages not supporting building in subdirectories, the pgxs_loop variant builds
+# for each PostgreSQL major version in turn in the top-level directory.
+#
+# Copyright: © 2020 Christoph Berg
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::pgxs_loop;
+
+use strict;
+use warnings;
+use parent qw(Debian::Debhelper::Buildsystem::pgxs);
+use Cwd;
+use Debian::Debhelper::Dh_Lib;
+use Debian::Debhelper::pgxs;
+
+sub DESCRIPTION {
+ "PGXS (PostgreSQL extensions), building for each PostgreSQL version in top level directory"
+}
+
+sub build {
+ my $this=shift;
+ verbose_print("Postponing build to install stage; if this package supports out-of-tree builds, replace --buildsystem=pgxs_loop by --buildsystem=pgxs to build in the build stage");
+}
+
+sub install {
+ my $this=shift;
+ my $pattern = package_pattern();
+ $this->doit_in_sourcedir(qw(pg_buildext loop), $pattern);
+}
+
+1;
diff --git a/debhelper/Debian/Debhelper/Sequence/pgxs.pm b/debhelper/Debian/Debhelper/Sequence/pgxs.pm
new file mode 100644
index 0000000..45a1ff1
--- /dev/null
+++ b/debhelper/Debian/Debhelper/Sequence/pgxs.pm
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+# check if debian/control needs updating from debian/control.in
+insert_after("dh_clean", "pg_buildext");
+add_command_options("pg_buildext", "checkcontrol");
+
+# use PGXS for clean, build, and install
+add_command_options("dh_auto_clean", "--buildsystem=pgxs");
+add_command_options("dh_auto_build", "--buildsystem=pgxs");
+add_command_options("dh_auto_install", "--buildsystem=pgxs");
+
+# move tests from dh_auto_test to dh_pgxs_test
+remove_command("dh_auto_test");
+if (! get_buildoption("nocheck")) {
+ insert_after("dh_link", "dh_pgxs_test");
+}
+
+1;
diff --git a/debhelper/Debian/Debhelper/Sequence/pgxs_loop.pm b/debhelper/Debian/Debhelper/Sequence/pgxs_loop.pm
new file mode 100644
index 0000000..314085b
--- /dev/null
+++ b/debhelper/Debian/Debhelper/Sequence/pgxs_loop.pm
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+# check if debian/control needs updating from debian/control.in
+insert_after("dh_clean", "pg_buildext");
+add_command_options("pg_buildext", "checkcontrol");
+
+# use PGXS for clean, build, and install
+add_command_options("dh_auto_clean", "--buildsystem=pgxs_loop");
+add_command_options("dh_auto_build", "--buildsystem=pgxs_loop");
+add_command_options("dh_auto_install", "--buildsystem=pgxs_loop");
+
+# move tests from dh_auto_test to dh_pgxs_test
+remove_command("dh_auto_test");
+if (! get_buildoption("nocheck")) {
+ insert_after("dh_link", "dh_pgxs_test");
+ add_command_options("dh_pgxs_test", "loop");
+}
+
+1;
diff --git a/debhelper/Debian/Debhelper/pgxs.pm b/debhelper/Debian/Debhelper/pgxs.pm
new file mode 100644
index 0000000..e3d86b2
--- /dev/null
+++ b/debhelper/Debian/Debhelper/pgxs.pm
@@ -0,0 +1,38 @@
+# A debhelper build system class for building PostgreSQL extension modules using PGXS
+#
+# Copyright: © 2020 Christoph Berg
+# License: GPL-2+
+
+package Debian::Debhelper::pgxs;
+
+use strict;
+use warnings;
+use Exporter 'import';
+our @EXPORT = qw(package_pattern);
+
+=head1 package_pattern()
+
+From C<debian/control.in>, look for the package name containing the
+B<PGVERSION> placeholder, and return it in the format suitable for passing to
+B<pg_buildext>, i.e. with B<PGVERSION> replaced by B<%v>.
+
+For B<Package: postgresql-PGVERSION-unit> it will return B<postgresql-%v-unit>.
+
+Errors out if more than one package with the B<PGVERSION> placeholder is found.
+
+=cut
+
+sub package_pattern () {
+ open F, "debian/control.in" or die "debian/control.in: $!";
+ my $pattern;
+ while (<F>) {
+ if (/^Package: (.*)PGVERSION(.*)/) {
+ die "More than one Package with PGVERSION placeholder found in debian/control.in, cannot build with dh --buildsystem=pgxs. Use pg_buildext manually." if ($pattern);
+ $pattern = "$1%v$2";
+ }
+ }
+ close F;
+ return $pattern;
+}
+
+1;
diff --git a/debhelper/dh_pgxs_test b/debhelper/dh_pgxs_test
new file mode 100755
index 0000000..c12bacd
--- /dev/null
+++ b/debhelper/dh_pgxs_test
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+use Debian::Debhelper::pgxs;
+
+my $target = (@ARGV and $ARGV[0] eq 'loop') ? "." : "build-%v";
+my $pattern = package_pattern();
+
+print_and_doit(qw(pg_buildext installcheck .), $target, $pattern);
diff --git a/debhelper/dh_pgxs_test.pod b/debhelper/dh_pgxs_test.pod
new file mode 100644
index 0000000..5b24e4b
--- /dev/null
+++ b/debhelper/dh_pgxs_test.pod
@@ -0,0 +1,44 @@
+=head1 NAME
+
+dh_pgxs_test - Run testsuite during a PGXS PostgreSQL extension build
+
+=head1 SYNOPSIS
+
+B<dh_pgxs_test> [B<loop>]
+
+=head1 DESCRIPTION
+
+B<PostgreSQL> extensions need to be installed before they can be tested and
+hence the usual B<debhelper> way of invoking tests from dh_auto_test(1) does
+not work.
+
+B<dh_pgxs_test> is a dh(1) sequence point created by the B<pgxs> and
+B<pgxs_loop> B<debhelper> extensions that is executed after dh_auto_install(1).
+It calls B<pg_buildext installcheck> after a B<PostgreSQL> extension module has
+been built and installed into the C<debian/>I<packagename/> directory.
+
+Users wishing to change the action called by B<dh_pgxs_test> should call
+B<pg_buildext> or similar commands.
+
+ override_dh_pgxs_test:
+ echo "CREATE EXTENSION foo" | pg_buildext psql . . postgresql-%v-foo
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<loop>
+
+B<dh --with pgxs> builds packages in C<build-%v> subdirectories. The B<loop>
+options corresponds to B<dh --with pgxs_loop> and builds in the top-level
+directory.
+
+=back
+
+=head1 SEE ALSO
+
+debhelper(7), dh(1), dh_make_pgxs(1), pg_buildext(1).
+
+=head1 AUTHOR
+
+Christoph Berg L<E<lt>myon@debian.orgE<gt>>