Re: Possible to combine ExclusiveArch?

2023-07-17 Thread Daniel P . Berrangé
On Sat, Jul 15, 2023 at 05:11:02PM +0200, Nils Philippsen wrote:
> On Fri, 2023-07-14 at 13:30 +0100, Richard W.M. Jones 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.
> 
> I beg to differ. When a tag in RPM can have multiple items (e.g.
> Provides, (Build)Requires), this …:
> 
> Tag: item1 item2 item3
> 
> … is consistently equivalent to this:
> 
> Tag: item1
> Tag: item2
> Tag: item3
> 
> To have ExclusiveArch behave differently would be surprising – nobody
> () would read this and expect the effective list of arches the
> package would be built for to be empty:
> 
> ExclusiveArch: x86_64
> ExclusiveArch: s390x
> ExclusiveArch: aarch64
> 
> > 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?
> 
> I think this would be a good approach.

It is certainly easier to read and understand than using a LUA script
to get to implement variable intersection for ExclusiveArch !

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
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


Re: Possible to combine ExclusiveArch?

2023-07-16 Thread Richard W.M. Jones
On Sun, Jul 16, 2023 at 02:34:42PM +0100, Richard W.M. Jones wrote:
> 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  
> > 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:

I don't mean "same" I mean "non-overlapping".

>   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@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


Re: Possible to combine ExclusiveArch?

2023-07-16 Thread Richard W.M. Jones
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  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@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


Re: Possible to combine ExclusiveArch?

2023-07-16 Thread Richard W.M. Jones
On Sun, Jul 16, 2023 at 01:32:49PM +0200, Kevin Kofler via devel wrote:
> Nils Philippsen wrote:
> > I beg to differ. When a tag in RPM can have multiple items (e.g.
> > Provides, (Build)Requires), this …:
> > 
> > Tag: item1 item2 item3
> > 
> > … is consistently equivalent to this:
> > 
> > Tag: item1
> > Tag: item2
> > Tag: item3
> > 
> > To have ExclusiveArch behave differently would be surprising – nobody
> > () would read this and expect the effective list of arches the
> > package would be built for to be empty:
> > 
> > ExclusiveArch: x86_64
> > ExclusiveArch: s390x
> > ExclusiveArch: aarch64
> 
> +1. The current union behavior is reasonable, please do not change it 
> incompatibly (and inconsistenly with all other tags, as pointed out above).

I take your point that we shouldn't change it now.  It is however very
weird when you first come across it (with ExclusiveArch).  A syntax
like this would be clear and not incompatible:

  ExclusiveArch: intersection (%{kernel_arches}, %{java_arches})

(Or even using Unicode ‘∩’ :-)

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@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


Re: Possible to combine ExclusiveArch?

2023-07-16 Thread Kevin Kofler via devel
Nils Philippsen wrote:
> I beg to differ. When a tag in RPM can have multiple items (e.g.
> Provides, (Build)Requires), this …:
> 
> Tag: item1 item2 item3
> 
> … is consistently equivalent to this:
> 
> Tag: item1
> Tag: item2
> Tag: item3
> 
> To have ExclusiveArch behave differently would be surprising – nobody
> () would read this and expect the effective list of arches the
> package would be built for to be empty:
> 
> ExclusiveArch: x86_64
> ExclusiveArch: s390x
> ExclusiveArch: aarch64

+1. The current union behavior is reasonable, please do not change it 
incompatibly (and inconsistenly with all other tags, as pointed out above).

Kevin Kofler
___
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


Re: Possible to combine ExclusiveArch?

2023-07-15 Thread Fabio Valentini
On Fri, Jul 14, 2023 at 2:30 PM Richard W.M. Jones  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".

Fabio
___
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


Re: Possible to combine ExclusiveArch?

2023-07-15 Thread Nils Philippsen
On Fri, 2023-07-14 at 13:30 +0100, Richard W.M. Jones 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.

I beg to differ. When a tag in RPM can have multiple items (e.g.
Provides, (Build)Requires), this …:

Tag: item1 item2 item3

… is consistently equivalent to this:

Tag: item1
Tag: item2
Tag: item3

To have ExclusiveArch behave differently would be surprising – nobody
() would read this and expect the effective list of arches the
package would be built for to be empty:

ExclusiveArch: x86_64
ExclusiveArch: s390x
ExclusiveArch: aarch64

> 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?

I think this would be a good approach.


Nils
-- 
Nils Philippsen / Senior Software Engineer / Red Hat
PGP fingerprint: D0C1 1576 CDA6 5B6E BBAE 95B2 7D53 7FCA E9F6 395D
___
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


Possible to combine ExclusiveArch?

2023-07-14 Thread Richard W.M. Jones
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?

Rich.

[1] https://src.fedoraproject.org/rpms/qemu/pull-request/43

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
___
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