Even though there is a wide range of RPMs for PostgreSQL and related projects in the repositories, some people don't want to use prebuilt options, or may apply some extra specific patches. Also, some companies prefer to build their packages from srpms, per their IT policy -- so they maintain their own packages.

This is very easy if you use the PostgreSQL RPM Repository infrastructure. Now, I will go over the details for it.
There are not much prerequisites for setting up RPM build environment. The most notable one is fedora-packager rpm. It is available in Fedora repository. RHEL / Rocky users can download it from EPEL repository. Rocky users can run

dnf install epel-release

to install EPEL repo. RHEL 8/9 users can download the repo RPM from their website:





Details for EPEL repository can be found here.

PostgreSQL RPM Repository has a public GIT repository, and everyone has read-only access to it. First, checkout the repository:

git clone https://git.postgresql.org/git/pgrpms.git

This fetches RPM related stuff from the repository.

Directory layout is


For example:




Here is the list of all distros and their abbreviations in the repository:

F-{$VERSION} : Fedora {$VERSION})
EL-9 : RHEL/Rocky Linux 9

EL-8 : RHEL/Rocky Linux 8
EL-7 : RHEL/CentOS/SL/OL {7}

Now, cd to the directory that you want to build package of. For example, if you want to build postgis32 package against PostgreSQL 13 on RHEL 8:

cd 13/postgis32/EL-8
make rpm13

That's all (no kidding). make rpm13 will warn you if there are missing development RPMs in your server. make rpm first runs an git pull, then fetches all sources, and then builds packages. make rpm13 is able to detect architecture, so you don't need to worry about it. RPMs will be written in the current directory, under $ARCH directory (x86_64/ppc64le/aarch64 depending on distro)

If you want to sign the packages, you can use

make build13

target. However, please note that this requires extra settings in .rpmmacros file, and it is not the topic for this article.

If you have any questions/comments, feel free to send an email to pgsql - pkg - yum @ postgresql . org or create an issue here.

No comments

The author does not allow comments to this entry