On Sat, Jul 15, 2023 at 05:22:38PM +0200, Fabio Valentini wrote: > On Fri, Jul 14, 2023 at 2:30 PM Richard W.M. Jones <rjones@xxxxxxxxxx> wrote: > > > > For some virt packages we need to combine 2 or 3 of: > > > > ExclusiveArch: %{kernel_arches} > > ExclusiveArch: %{qemu_sysemu_host_arches} # [1] > > ExclusiveArch: %{ocaml_native_compiler} > > > > to mean only compile on the intersection of these arches. If you have > > multiple ExclusiveArch lines then RPM seems to do the union of arches > > which is the opposite of what anyone would want. > > > > Dan Berrange came up with a clever way to do it though ... > > > > %ifnarch %{kernel_arches} > > ExcludeArch: %{_arch} > > %endif > > %ifnarch %{qemu_sysemu_host_arches} > > ExcludeArch: %{_arch} > > %endif > > > > But this makes my head hurt. Is there a better way or could RPM > > provide explicit union and intersection operators? > > Well, if you want set union / intersection as an RPM macro, the first > thing I'd try would be to implement this as a lua macro ... > Lua does not have a native "set" data type, but it can be simulated by > using a table's (hashmap's) keys as a "set". I think this works ... ExclusiveArch: %{lua: -- "impossible" ensures we don't get "Empty tag: ExclusiveArch:" -- if both lists are the same: local arches = { impossible = 1 } local karches = {} for a in macros.kernel_arches:gmatch("%S+") do karches[a] = 1 end for a in macros.java_arches:gmatch("%S+") do if karches[a] then arches[a] = 1 end end for a, t in pairs(arches) do print(a..' ') end } eg: $ rpmspec -P test.spec | grep ExclusiveArch ExclusiveArch: ppc64le x86_64 s390x impossible aarch64 It's a shame Lua doesn't have an intersection operator though. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top _______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-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/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue