#848 Clarify the use of path macros with respect to build dependencies
Opened 5 months ago by otaylor. Modified 3 months ago

Packages sometimes use %{_prefix} derived macros to refer to files in build dependencies - e.g., running %{_binddir}/scons instead of scons. This is generally not useful, and prevents using the path macros to rebuild a single package in a different location (we're doing this with prefix=/app to create Flatpaks from Fedora packages.)

Proposed guideline text (see https://pagure.io/packaging-committee/pull-request/847):

Note that the macros for paths such as %{_bindir} refer to the installation location of a package. Spec files must not use these macros to locate files from build dependencies, since build dependencies may have been built with a different %{_prefix}. (This happens when packages are being rebuilt with a prefix of /app to bundle with a Flatpak.) When possible,
build dependencies should be located using mechanisms that are robust against different installation locations, such as relying on $PATH lookup, using pkg-config, or using RPM macros provided by the build dependencies. If no such mechanism is available, and it's necessary to specify an absolute path to a file in a dependency, assume that the build dependency is installed with prefix=/usr. (/usr/%{_lib} may be used to handle the difference between /usr/lib and /usr/lib64.)

See also: https://lists.fedorahosted.org/archives/list/packaging@lists.fedoraproject.org/thread/BILZSHLQ7Y2GFIP3AMYNB6FFOFTLQNGM/

I'm +1 on the base thing, will comment wording in the PR.

Metadata Update from @tibbs:
- Issue tagged with: meeting

5 months ago

We discussed this ticket at this weeks meeting (https://meetbot-raw.fedoraproject.org/fedora-meeting-1/2019-02-14/fpc.2019-02-14-17.00.txt) :

Metadata Update from @james:
- Issue untagged with: meeting
- Issue tagged with: writeup

4 months ago

Sorry, but I don't like this proposal. We have been there with SCL. In SCL, you have to use constructs such as BuildRequires: %{?_root_bindir}%{!?_root_bindir:%{_bindir}}/cmake. I think that something similar should be used for Flatpak.

Or better, work with RPM guys to have something like _root_bindir vs _bindir or whatever else the names would be because this appears to be a more generic issue than just for Flatpak.

Also, if we prohibited %{_bindir}, then the next User Move will be much harder to do, that is the purpose of the macros, not building Flatpaks

Asking packagers to use SCL-like complicated constructs in their spec files is probably not something we want to do. %_root_bindir could be defined globally in Fedora macros but I think the incremental improvement is not worth the incompatibility with older versions of Fedora/EPEL.

We're not likely to rearrange the Fedora filesystem anytime soon in a way that would change /usr/bin:

%{_bindir} didn't help User Move - %{_bindir} was /usr/bin before and after - pre-user-move if a package wanted to install in /bin, that would have been manually specified. %{_libdir} might be the most likely thing to change in the future if we move away from /usr/lib64, but BuildRequires: %{_libdir}/... is wrong in any case because of architecture differences.

I've been packaging RPMs since before these macros were added (https://github.com/rpm-software-management/rpm/commit/10b88439eb63852e8a0d5cb1a32724529ee49c61) - but can't tell you what they are for. In the end, they are for whatever makes Fedora packaging work better.

Unfortunately, it is not possible to avoid the SCL construct or something similar (I was suggested there might be an alternative with rich dependencies) when there is used just single .spec file to build a package for both regular Fedora and for something changing prefix to /app. Now it looks that the problem is requiring something from /usr/bin when the prefix is modified, but soon you will have the problem that you have the same content in your /app as well as in /usr/bin and you will have to choose.

Now it looks that the problem is requiring something from /usr/bin when the prefix is modified, but soon you will have the problem that you have the same content in your /app as well as in /usr/bin and you will have to choose.

See https://pagure.io/packaging-committee/pull-request/847#comment-72582 - and also the next comment where I discuss how Flatpaks differ from SCL's.

  1. The proposed guidelines changes are based on artificial need.
  2. Suggested workarounds do not work or do not provide the convenience.
  3. It collides with current guidelines and used practices: https://docs.fedoraproject.org/en-US/packaging-guidelines/#_macros

Login to comment on this ticket.