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:

RHEL 8:

https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

RHEL 9:

https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm


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

PostgreSQLMajorVersionNumber/PackageName/Distro

For example:

14/postgresql-14/EL-9

or

13/postgis32/EL-8

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 rpm


That's all (no kidding). make rpm 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 rpm 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 build

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

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA