Many PostgreSQL extension packages require no special handling at build time and can use dh $@ --with pgxs or dh $@ --with pgxs_loop to automatically execute the steps outlined below.
As the set of binary packages depends on the target PostgreSQL versions,
debian/control
is generated from a template in
debian/control.in
when
pg_buildext updatecontrol is run.
Package sections that contain PGVERSION in the package name are replaced by
a list of sections, filling in the supported PostgreSQL versions.
Package sections that contain PGVERSION outside the package name have the
newest supported PostgreSQL version filled in (useful for meta packages).
Include
/usr/share/postgresql-common/pgxs_debian_control.mk
in
debian/rules
to
run a check at build time if updating debian/control is required.
As pg_buildext invokes make for the build, install, and clean
actions, invocations from
debian/rules
(which is a makefile) should be prefixed
with + so the sub-makes can talk with the make jobserver. Additional makefile
variables can be passed to make via the -m option.
Many extensions support make installcheck testing using pg_regress. As
this needs the package to be installed, it cannot be run at build time.
Instead, the tests should be run using autopkgtest from
debian/tests/*
.
If
debian/tests/control.in
exists, occurrences of package names containing
PGVERSION are replaced by lists of package names with the target PostgreSQL
versions filled in. (If no replacing is needed in
debian/tests/control
, it
is fine to provide the tests control file directly.)
Use this when building packages.
Use this when testing packages.
The dpkg substitution variable postgresql:Depends is set to depend on the required PostgreSQL server package. For compatibility with previous packaging standards, the dependency is also added to misc:Depends if postgresql:Depends is not used.
If package-pattern is given, options are passed to pg_virtualenv to set
up the temporary PostgreSQL instance to find extension files in
debian/package-directory/
.
Other than the other actions which run on the ``supported'' versions, if
debian/control.in
exists, this one
runs on the ``installed'' versions as reported by installed-versions (unless
package-pattern is provided, which means we are called during a build).
Sometimes it is desirable to run extra code per version before invoking the action, in that case the loop over supported versions needs to be in the calling script. To facilitate this mode, actions can also be called as action-version. See the installcheck example below.
For a version to be used, it must also be listed in the output of
/usr/share/postgresql-common/supported-versions
. See this file for how to
configure the list of supported versions on your system.
Source: postgresql-foobar Rules-Requires-Root: no Build-Depends: debhelper, postgresql-all <!nocheck>, postgresql-server-dev-all (>= 217~), Package: postgresql-PGVERSION-foobar Architecture: any Depends: ${misc:Depends}, ${postgresql:Depends}, ${shlibs:Depends},
all # alternatives: #9.6 #11+
#!/usr/bin/make -f override_dh_installdocs: dh_installdocs --all README.* %: dh $@ --with pgxs
#!/usr/bin/make -f %: dh $@ --with pgxs_loop
override_dh_pgxs_test:
#!/usr/bin/make -f include /usr/share/postgresql-common/pgxs_debian_control.mk # omit this if the package does not use autoconf override_dh_auto_configure: +pg_buildext configure build-%v "--libdir=/usr/lib/postgresql/%v/lib --datadir=/usr/share/postgresql-%v-foobar" override_dh_auto_build: +pg_buildext build build-%v override_dh_auto_test: # nothing to do here, see debian/tests/* instead override_dh_auto_install: +pg_buildext install build-%v postgresql-%v-foobar override_dh_installdocs: dh_installdocs --all README.* override_dh_auto_clean: +pg_buildext clean build-%v %: dh $@
Depends: @, postgresql-server-dev-all Tests: installcheck Restrictions: allow-stderr
Depends: @, postgresql-contrib-PGVERSION, postgresql-PGVERSION-bar Tests: installcheck Restrictions: allow-stderr
#!/bin/sh pg_buildext installcheck # alternatively: pg_buildext installcheck build-%v # Running extra code before invoking the actual action: set -e for v in $(pg_buildext installed-versions); do test -L build-$v/sql || ln -s ../sql build-$v/ test -L build-$v/expected || ln -s ../expected build-$v/ pg_buildext installcheck-$v build-$v done
override_dh_auto_build: +pg_buildext build $(CURDIR)/postgresql-module build-%v
The usage of ``all'' or ``NN+'' in debian/pgversions was introduced in postgresql-server-dev-all (>= 148~).
pg_buildext installcheck was introduced in postgresql-server-dev-all (>= 153~).
PG_VIRTUALENV_UNSHARE=-n was introduced in postgresql-common (>= 170~).
Handling of
debian/tests/control.in
with PGVERSION replacement was
introduced in postgresql-common (>= 171~).
The action installed-versions was introduced in postgresql-common (>= 208~). installcheck was switched to use it in the same version.
dh $@ --with pgxs and pgxs_loop, the corresponding --buildsystem, and the psql and virtualenv actions were introduced in postgresql-server-dev-all (>= 217~).