rpm premable - order matters

Posted on Nov 26, 2025

The other day while working on pgrx based postgresql extensions, I saw a weird errors in the build log.

warning: line 29: Possible unexpanded macro in: Provides:       postgresql18-someextension-llvmjit = %{version}-%{release}
warning: line 29: Possible unexpanded macro in: Obsoletes:      postgresql18-someextension-llvmjit < %{version}-%{release}

This is odd. The Version and Release are set. So what is going on here:

%if "%{pg_name}" == ""
Name:           %{ext_name}
ExclusiveArch:  do_not_build
%else
Name:           %{pg_name}-%{ext_name}
BuildRequires:  %{pg_name}-pgrx
%pg_server_requires
%endif
Version:        1.0.0
Release:        0

The warning comes from %pg_server_requires, which then calls %pg_obsolete_llvm_subpackage. This preamble block was a slight deviation from the pattern I was usually following. I made the change because I saw “wait I can group up some stuff”

Name:           %{pg_name}-%{ext_name}
Version:        1.0.0
Release:        0
[snip]
BuildRequires:  %{pg_name}-server-devel
%pg_server_requires
%if "%{pg_name}" == ""
ExclusiveArch:  do_not_build
Name:           %{ext_name}
%endif

In this form everything was working fine. Now we have 2 options.

  1. go back to the old style
  2. Move the Version and Release fields.
Version:        1.0.0
Release:        0
%if "%{pg_name}" == ""
Name:           %{ext_name}
ExclusiveArch:  do_not_build
%else
Name:           %{pg_name}-%{ext_name}
BuildRequires:  %{pg_name}-pgrx
%pg_server_requires
%endif

Now the %{release} and %{version} variables are defined again. One could argue that moving the the BuildRequires and %pg_server_requires into the if was not necessary. Well for postgresql extensions packages, which really just ship an extension. This is kinda true. But for packages which ship both (like repmgr) it is actually nice to minimize the BuildRequires of the main package and extension package which is handled via multibuild.

In any case it was a nice learning opportunity.

Also did I mention already “WOOHOO pgrx is working within an rpm package!!!!”?