On Thu Sep 29, 2022 at 21:00 +0200, Miro Hrončok wrote:
Hello packaging folks.
I was in need of computing an intersection of 2 arches today.
Consider this:
%java_arches: aarch64 ppc64le s390x x86_64
%my_arches: i686 x86_64
Plan:
ExclusiveArch: <intersection of %java_arches and %my_arches>
Is there some idiomatic way of doing this? I came up with:
ExclusiveArch: %(comm -12 <(echo %{java_arches} | tr ' ' '\n' |
sort) \
<(echo %{my_arches} | tr ' ' '\n' | sort) | tr
'\n' ' ')
Which I consider quite horrible.
I was considering Lua to avid shelling out to nested Shell, but Lua has no easy
sets, so the code would be much longer.
Is there some easier way? Should there be? Something like:
ExclusiveArch: %{arch_intersect %java_arches & %my_arches}
Note the & that serves as a separator, otherwise the arches would be mixed and
would need to be put in some kind of quotes. Alternatively, the macro names
could be passed instead to avoid a need of a separator
ExclusiveArch: %{arch_intersect java_arches my_arches}
(Both approaches allow to intersect arbitrary number of sets.)
FWIW, I recently came across
```
%global grafana_arches %{lua: go_arches = {}
for arch in rpm.expand("%{go_arches}"):gmatch("%S+") do
go_arches[arch] = 1
end
for arch in rpm.expand("%{nodejs_arches}"):gmatch("%S+") do
if go_arches[arch] then
print(arch .. " ")
end
end}
```
in
https://src.fedoraproject.org/rpms/grafana/blob/rawhide/f/grafana.spec#_11.
--
Maxwell G (@gotmax23)
Pronouns: He/Him/His