Search code examples
postgresqlmockingrpmpostgresql-11fedora-27

Specify RPM build order in mock


TLDR: Ensure to keep system OS up-to-date to help ensure consistency with current spec files.

Symptom

When rebuilding PostgreSQL 11.1 SRPM using mock, the build fails with:

BUILDSTDERR: /builddir/build/BUILD/postgresql-11.1/src/bin/psql/command.c:1814 undefined reference to `PQencryptPasswordConn`

NB: PQencryptPasswordConn is a libpq.so function (provided by postgresql-devel-10.3-5.fc27.x86_64 on my system...outside the mock chroot environment). Unless I'm mistaken, the Postgresql SRPM builds the postgresql-devel RPM along with others.

Steps to reproduce

I ran the following to rebuild the SRPM before attempting to apply any patches not already present in the SRPM:

# Obtain SRPM source
git clone https://src.fedoraproject.org/rpms/postgresql.git
cd postgresql

# Download local copies of SRPM sources
wget $(spectool -S *.spec | awk '/^Source.*:\/\//{IFS=" "; print $2}')
# ...check SHAs of downloaded sources...

# Run SRPM-specific prep scripts
./generate-pdf.sh
./generate-sources.sh

# Generate the SRPM
mock --root=fedora-27-x86_64 --resultdir="./SRPMS" --buildsrpm --spec postgresql.spec --sources .

# >>> Everything seems to work fine up to this point <<<

# Build the RPM inside mock chroot
mock --root=fedora-27-x86_64 --rebuild ./SRPMS/postgresql-11.1-4.fc27.src.rpm

# !!! Fail here (with symptom above) !!!

The Problem

I have so far been unable to have mock load the appropriate libpq library headers into the chroot environment to make sure rpmbuild builds against the libpq that contains the PQencryptPasswordConn header (which appears to exist on my system outside the build environment):

grep -lr "PQencryptPasswordConn" /usr/include
# /usr/include/libpq-fe.h

grep -lr "PQencryptPasswordConn" /var/lib/mock/fedora-27-x86_64/root/usr/include
# (Nothing returned)

When reviewing mock's installed_pkgs.log, the following were installed (the latter of which I expect would provide a version of libpq headers):

postgresql-libs-9.6.10-3.fc27.x86_64
postgresql-devel-9.6.10-3.fc27.x86_64

However, I cannot find a way to install the postgresql-* packages into the chroot environment that contain the updated library headers.

The Ask

Since postgresql SRPM is supposed to build postgresql-devel RPM, I think that mock will need to build and install the postgresql-devel RPM in the chroot before rpmbuild attempts to compile psql/command.c so that the latter compilation finds the appropriate library headers (unless the build process is intelligent enough to identify new libraries currently under build).

How can I best accomplish this (would prefer to avoid multiple mock calls for each RPM package built from the SRPM unless that's the only way to go)?

Please note that the build process on my system spawns multiple processes to parallel compilations.

I have also tried to use mockchain —recurse without success.

System Info

Linux 4.16.6-202.fc27.x86_64

Solution

  • First hint, you use the latest postgresql.spec version, but you try to build it against rather old (in fact unsupported nowadays) version 27 of Fedora distribution. I'd encourage you to migrate to a newer version of Fedora, or at least checkout the branch f27 in the same RPM git repository.

    Second hint, we changed the layout of PostgreSQL packaging in Fedora 30+. We've cut out the library (libpq.so) into separate package, per announcement.

    How to continue; always checkout appropriate branch based on what Fedora you build against, and adjust the spec file appropriately (checkout f27 and update to PostgreSQL 11.1 in this case).

    JFTR (might help), there already is a testing modular build of PostgreSQL 11 against Fedora 28+, and the build scripts are maintained in separate branch stream-postgresql-11. With a bit of luck, you would be able to build that branch against old Fedora 27, too. Note that this version of postgresql.spec file is a little bit complicated (it needs to be because we build it against different versions of Fedora).