On 05. 09. 22 21:58, Richard W.M. Jones wrote:
On Mon, Sep 05, 2022 at 09:56:58PM +0200, Dominik 'Rathann' Mierzejewski wrote:
On Monday, 05 September 2022 at 21:42, Richard W.M. Jones wrote:
I have a downstream patch[0] which -- I don't really understand why --
breaks riscv64 builds but is necessary for primary Fedora arches.  Is
it correct to do:

   %ifnarch riscv64
   Patch123: downstream.patch
   %endif

given that the package uses %autosetup and therefore doesn't have
explicit %patch lines.

I think this means that if I build the SRPM on riscv64 then the
downstream patch wouldn't be included, meaning that SRPM would then
fail to build on other arches.

This is correct. And forbidden by the packaging guidelines as others pointed 
out.

As long as riscv64 lives in another Koji, this will not create real problems. However once (if) riscv64 is added to the proper Fedora Koji, when the SRPM would be built on riscv64, the build would fail on all other architectures due to the missing patch file.

In this particular case that doesn't
matter, but it feels wrong.  Is there a recommended way to do this
(apart from fixing the patch)?

Change %autosetup to plain %setup and apply the patch conditionally
instead of conditionally including it in the SRPM.

There are 26 patches so that's a bit of a PITA.  Is there not an
easier way?

You can do this:

=============================================================
Patch1:   ...
Patch2:   ...
...
PatchX:   ...
...

# Patches after 500 are applied conditionally

# Only applied on non-riscv64
Patch501: downstream.patch

...

%prep
%autosetup -N (-S git_am or whatever other options you like)
# apply all patches < 500
%autopatch -M 499

# apply conditional patches
%ifnarch riscv64
%autopatch 501
%endif
=============================================================

Alternatively, if you cannot (or don't want to) reorder the patches for some reason, you could do:

=============================================================
# apply all patches <= 122
%autopatch -M 122

%ifnarch riscv64
%autopatch 123
%endif

# apply all patches >= 124
%autopatch -m 124
=============================================================

Which is a tad uglier.

Note that %autopatch accepts positional arguments with patch numbers only since RPM 4.17. Before that you can either use %patch501 (which does not work with %autosetup -S) or %apply_patch -q %{PATCH501} (which RPM considered internal and removed from 4.17+).

For an uglier but portable solution that works on RPM <=4.16 and >=4.17, and also respects %autosetup -S option, see https://src.fedoraproject.org/rpms/python3.8/blob/f35/f/python3.8.spec#_736

--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to