Re: Intersection of 2 arches macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
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/packaging@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue

[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux