Skip to content
Planet PostgreSQL· Damien Clochard·· 15d ago

How to Build PostgreSQL Extension RPM and DEB Packages with PGRX 0.20

damien clochard: PGRX 0.20: Build your own RPM/DEB packages

Brief · Based on the source excerpt

With PGRX 0.20, cargo pgrx package builds PostgreSQL extension RPM and DEB packages directly on Linux without a spec file, debian/ directory, or extra tools. It supports Postgres 15–19 and adds cargo pgrx migrate to assemble upgrade scripts from SQL fragments.

Why It Matters

The comparison between generating a directory tree and building packages directly shows extension maintainers which manual steps they can skip when packaging for multiple distributions.

Technical Breakdown · Distilled from the original source

From a staging tree to installable packages

  • Previously, cargo pgrx package produced a directory tree and left maintainers to turn it into distribution packages. On Linux, PGRX 0.20 can produce RPM and DEB files directly, without an RPM spec file, a debian/ directory, or a separate packaging tool.
  • Direct packaging removes a build step, not the need for separate artifacts. Distribution, PostgreSQL major version, and CPU architecture still determine the packaging matrix. The author cites PostgreSQL Anonymizer as an example: it publishes 24 packages per release.

Compatibility changes when moving to PGRX 0.20

  • PGRX 0.20 supports PostgreSQL 15 through 19, dropping 13 and 14 and adding official support for 19. It now generates Rust versions of PostgreSQL C macros and static inline functions at build time. These replace the handwritten ports, so some extension code needs updating.
  • Fixes for several safe APIs that could lead to undefined behavior also change some signatures. Extensions and cargo-pgrx itself compile fewer crates, and installing cargo-pgrx on Linux no longer requires OpenSSL headers.

Split extension upgrades into SQL fragments

  • cargo pgrx migrate assembles extension upgrade scripts from small SQL fragments. Each change can be kept in its own file.
Source: Planet PostgreSQL· postgr.es

PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.

Read Official Source

Related PostgreSQL Reference