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. 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)?
Rich.
[0] https://pagure.io/fedora-ocaml/c/41d5e2db7a4667560d6aedda11a3c6a80c8f1b83?br...
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. 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.
Regards, Dominik
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. 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?
Rich.
On Mon, Sep 05, 2022 at 09:56:58PM +0200, Dominik 'Rathann' Mierzejewski wrote:
There are 26 patches so that's a bit of a PITA. Is there not an easier way?
Rich.
Try using autopatch.
# Apply patches up to #1000 from this spec. %autopatch -M1000 -p1
https://pkgs.rpmfusion.org/cgit/free/chromium-freeworld.git/tree/chromium-fr...
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
On Monday, September 5, 2022 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. 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)?
Yes, conditionalizing Source or Patch lines is a bad idea. This exact case is explicitly forbidden by the guidelines[1]. There is also a guidelines PR to forbid any type of Source/Patch conditionaliztion[2].
[1]: https://docs.fedoraproject.org/en-US/packaging-guidelines/ #_no_arch_specific_sources_or_patches
[2]: https://pagure.io/packaging-committee/pull-request/1163
If you don't want to add %patchX for every Patch, you can use regular `%setup -q` together with %autopatch, which allows more granular control than `%autosetup`.
From /usr/lib/rpm/macros:
``` # Apply patches using %autosetup configured SCM. # Typically used with no arguments to apply all patches in the order # introduced in the spec, but alternatively can be used to apply indvidual # patches in arbitrary order by passing them as arguments. # -v Verbose # -p<N> Prefix strip (ie patch -p argument) # -m<min> Apply patches with number >= min only (if no arguments) # -M<max> Apply patches with number <= max only (if no arguments) %autopatch(vp:m:M:) %{lua: ```
On Mon, 2022-09-05 at 15:00 -0500, Maxwell G via devel wrote:
On Monday, September 5, 2022 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. 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)?
Yes, conditionalizing Source or Patch lines is a bad idea. This exact case is explicitly forbidden by the guidelines[1]. There is also a guidelines PR to forbid any type of Source/Patch conditionaliztion[2].
because src.rpm will be different if build in one specific arch and src.rpm should have the same results built in any arch
#_no_arch_specific_sources_or_patches
If you don't want to add %patchX for every Patch, you can use regular `%setup -q` together with %autopatch, which allows more granular control than `%autosetup`.
From /usr/lib/rpm/macros:
# Apply patches using %autosetup configured SCM. # Typically used with no arguments to apply all patches in the order # introduced in the spec, but alternatively can be used to apply indvidual # patches in arbitrary order by passing them as arguments. # -v Verbose # -p<N> Prefix strip (ie patch -p argument) # -m<min> Apply patches with number >= min only (if no arguments) # -M<max> Apply patches with number <= max only (if no arguments) %autopatch(vp:m:M:) %{lua:
maybe this works:
%autosetup -M122 -m124
%ifnarch riscv64 %patch123 -p1 %endif
On 5/9/22 16: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
When I have to do things like that (often temporarily), I do something like this
%ifnarch riscv64 Patch123: downstream.patch %else Source23: 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. 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)?
Rich.
[0] https://pagure.io/fedora-ocaml/c/41d5e2db7a4667560d6aedda11a3c6a80c8f1b83?br...
Pablo.
On Mon, Sep 05, 2022 at 08:42:34PM +0100, 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.
Unrelated to your question, but FWIW PatchNNN is not required, all patches can be merely "Patch: filename" and they'll get applied in the order they are listed in the spec.
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. 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)?
Rather than fixing the root cause, if you want a relatively simple workaround still, you could merely move the conditional into the patch hack:
if test $(uname -m) == "riscv64" then ...autoconf patch stuff... fi
or something along those lines </hand-waving-suggestion>
With regards, Daniel
On Tue, 2022-09-06 at 09:04 +0100, Daniel P. Berrangé wrote:
Unrelated to your question, but FWIW PatchNNN is not required, all patches can be merely "Patch: filename" and they'll get applied in the order they are listed in the spec.
🤯🤯🤯
On 06. 09. 22 19:06, Adam Williamson wrote:
On Tue, 2022-09-06 at 09:04 +0100, Daniel P. Berrangé wrote:
Unrelated to your question, but FWIW PatchNNN is not required, all patches can be merely "Patch: filename" and they'll get applied in the order they are listed in the spec.
🤯🤯🤯
See https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.... and https://youtu.be/0bfA0441dxc?t=666 and https://pagure.io/packaging-committee/pull-request/1157