Clarify distribution conditionals in spec files #1546
Labels
No labels
announce
bootstrap
Closed As
accepted
Closed As
duplicate
Closed As
exceptionexpired
Closed As
fixed
Closed As
invalid
Closed As
nothingtodo
Closed As
permanentexception
Closed As
rejected
Closed As
temporaryexception
Closed As
wontfix
cmake
committee
draftneeded
hasdraft
meeting
meson
needinfo
Priority
In Committee
Priority
Needs Review
Priority
Waiting For Reporter
rust
writeup
No milestone
No project
No assignees
9 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
packaging/guidelines#1546
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Packaging Guidelines currently say this, under Spec Legibility:
I would like to get this changed to explicitly permit
%fedora,%rhel,%centos,%epel, and their variants such as%{?fedora}0. And I believe%hummingbirdshould be added to this list, too, now that Hummingbird images are part of the Fedora family.+1 to explicitly permit %fedora, %rhel, %centos, %epel which reflects the reality.
-1 to allowing %hummingbird at this moment. I think this requires more discussion, and I don't want to block the previous point on that.
%rhelis meant to be used in conditionals for Fedora EPEL and ELN, so I think this is already allowed under the current Guidelines.%rheland%epelare defined when building packages for Fedora EPEL and ELN (Extras), so "those macros and conditionals are also present in Fedora" is a true statement. If we consider Hummingbird part of Fedora, I think%hummingbirdwould also be allowed.Beyond that, I am not a huge fan of changing this to list or special case specific downstream distributions that are not part of the Fedora Project. That opens up a whole 'nother can of worms. I would rather consider allowing conditionals for any derivative of Fedora provided that the conditional does not add significant complexity or significantly impact legibility.
I think if we do this, we should just drop the rule entirely and replace it with guidance on how we want distro conditionals to be used.
@ngompa wrote in #1546 (comment):
IMHO, the legibility win comes from following the Fedora packaging guidelines.
If the use of other distro name conditionals is a mechanism to perform content selection that is not going to significantly harm legibility as it is mostly just boolean choices.
If the use of other distro name conditionals is a mechanism to switch between two different sets of packaging guidelines that is where the complexity and legibility concerns can start to arise depending on what the alternate guidelines are.
With %rhel/%centos/%epel macros, we have two typical uses.
I would be inclined to allow distro conditionals in those two cases, but explicitly exclude the scenario where a conditional is used to select compat with guidelines that did not originate in Fedora (neither current, nor historical). That would exclude sharing specs with other RPM based distros outside the Fedora family tree, or other custom downstream distro guidelines intended to replace/override guidelines already defined by Fedora.
The same two reasons apply to Amazon Linux and Azure Linux too. Do we want to allow conditionals for these two too? And where does it "end"? ^_^
Maybe rather than having a list of "allowed" macros, document how distribution conditionals should be used?
💯
I've had several discussions with AWS folks (cc: @fredlefebvre) about this specifically. Many of their downstream modifications are just basic bcond changes based on the
amznmacro being defined. Often times these align withrhelconditions, so my guidance has been to rework the conditional so that both RHEL and Amazon Linux match the%elsecondition. Describing this and other best practices in documentation has been on my to-do list for a while, but if someone else has time to get it started before me I'm happy to help contribute to it.I agree with @decathorpe's point that we should avoid just expanding the list of allowed macros. Distro-specific macros easily get out of hand and reduce legibility. An alternative that Fedora downstreams could consider is using bcond overrides to globally disable generically-named bcond such as
docs.https://rpm.org/docs/latest/manual/conditionalbuilds.html#overriding-defaults
While the idea of global bcond overrides as a fix-all to distribution differences comes up from time to time, I am not convinced that it is a viable solution due to lack of consistency between packages and use cases.
It won't cover 100% of cases, but it does cover quite a bit, and with a little bit of focus on consistency (e.g. standardize on
%bcond testsover%bcond check), it will cover even more. We don't need to hit 100% anyways, because downstreams will always maintain their own changes, and all we can do is try to facilitate minimizing those changes if possible with bconds and bcond overrides.Build conditions don't intrinsically make legibility better, and can sometimes make it worse, since that is often due to structural differences. We see this a lot in RPM Fusion and some Fedora packages that originate from there.
I'm not swayed by @berrange's argument about legibility for distro conditionals either because they're already starting to get bad between Fedora and RHEL.
It's particularly awful with toolchain packages and the kernel, both of which somewhat treat Fedora as a special case rather than the default case.
@ngompa wrote in #1546 (comment):
There are certainly cases where it ceases to be sensible to have a shared spec between Fedora and RHEL. In QEMU we always took the view that the RHEL spec is too different to want to try to merge with Fedora.
I've not looked at toolchain packages, but IMHO the kernel in particular is quite an extreme example for RPM packaging in general.
We have over 1700 packages using %rhel dist tags and I expect the overwhelming majority are quite reasonable and bring benefit to the maintainers workload through sharing specs. We shouldn't make a policy based on targetting a handful of bad examples, that would negatively impact 1000's of acceptable examples.
We'll never get perfection no matter how strictly we define the rules. We need to aim to maximise the positive usage, but accept there will always be a small number of undesirable examples. Work to improve the undesirable examples through proposing spec changes, rather than trying to litigate it through rules.
I do think that the default case should be Fedora, with downstream being the special case, but that's quite a nebulous concept to express.
@gotmax23 wrote in #1546 (comment):
Yes. But complexity is in the eye of the beholder. I'd just delegate to packagers:
"Spec files MAY contain conditionals for Fedora releases and any derivatives. Conditionals that create significant complexity or negatively impact legibility are discouraged, and packagers SHOULD consider using separate branches in that case."
That proposal sounds reasonable, but I'd say "packagers SHOULD use separate branches" instead of "SHOULD consider using separate branches" to make the statement stronger/more concise.
I believe @ngompa was also working on a more comprehensive set of Guidelines about distro packaging conditionals.
If we decide to add guidelines specific to "how and when to use conditionals", I think it might be interesting to distinguish between what can / cannot be the content of a conditional, and what can / cannot be the actual controlling condition: Something like "if rhel: bcond docs 0" is usually fine, something like "if today == wednesday: Version: 42" is probably not. :)
Yes, that's a good idea, I'll incorporate that into my draft.
I'd say the opposite ;)
The first should be spelled
%bcond docs %{undefined rhel}or equivalent.The second is useful, see https://src.fedoraproject.org/rpms/systemd/blob/rawhide/f/systemd.spec#_78.
@ngompa you mentioned a draft. Is it available somewhere?