1

What is the minimal-effort way to package a PostgreSQL extension into a .deb file for Ubuntu (as of 18.04)?

I did some search but find many different suggestions (some outdated).

Suppose I want to package a simple postgres extension such as the first and last aggregate functions.

This StackOverflow answer suggests that one should fist make a directory structure manually as follows:

ProgramName-Version/
ProgramName-Version/DEBIAN
ProgramName-Version/DEBIAN/control
ProgramName-Version/usr/
ProgramName-Version/usr/bin/
ProgramName-Version/usr/bin/your_script

and then dpkg -b /path/to/the/ProgramName-Version after setting the right file permissions.

Others suggest using dh-make, and the Ubuntu Packaging Guid suggests a work flow that uses some toolchain based on bzr.

But I think PostgreSQL has its own build infrastructure for extensions called PGXS (as of PostgreSQL 12.x). I found PGXS quite easy to use, because I don't have to worry the folder structure myself and make install will copy files to the right system directories regardless of the PostgreSQL version.

Is there a way to combine the manual approach above and the PGXS approach to automatically create a PostgreSQL extension as a .deb file?

1 Answer 1

1

Is there a way to combine the manual approach above and the PGXS approach to automatically create a PostgreSQL extension as a .deb file?

Sure. First you need to create a debian/ directory with a control and rules files copied from other extensions. There are many examples in the PGDG Apt repository. Add the following line in your APT sources (bionic is the codename for Ubuntu 18.04) if you don't have it already:

deb-src http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

To see the list of packages: apt search 'postgresql-*'

To download the sources: apt source name-of-package

Once your debian directory is good and the dependencies are installed, basically you build the package for the extension with dpkg-buildpackage -rfakeroot -b like any other Debian package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.