Re: %bcond_with/%bcond_without

2021-01-29 Thread Miro Hrončok

On 03. 04. 20 22:36, Zbigniew Jędrzejewski-Szmek wrote:

On Fri, Apr 03, 2020 at 02:23:12PM -0400, Stephen Gallagher wrote:

Fabio Valenti made this comment in the FESCo ticket[1].

"Side note: I think more people would be amenable to including
"conditionals" into their packages if they weren't only shown off as
`%if eln this else that`. I think there's more value in doing "feature
flags" rather than conditionalize everything based on the `dist` tag,
for example something like this might even be useful in fedora
branches (e.g. for bootstrapping):

```spec
# at the top of the .spec file, where it's easily visible
%if 0%{?eln}
%bcond_with docs
%else
%bconf_without docs
%endif

# ...

%if %{with docs}
# do something
%endif
```

This makes conditionals (when they are necessary) much easier to
maintain (and understand), in my experience."


This is a side topic, and I didn't want to clutter the FESCo ticket
with that. But here we have threads, so I hope that you'll forgive me ;)

If find the %bcond_with/%bcond_without pattern abhorrent.

1. The logic is reversed: when I see "with" I think something is enabled,
when I see "without" I think something is disabled. But it's actually
the other way around here, which I find very confusing and often get
the condition reversed on the first try.

2. The value ('0%{?eln}') in this example is expressed before the name
('docs'), which is like saying 'value =: name'.

3. It takes five (!) lines to express the something that should be one
line.

So... could we please get a way to express this in rpm with a sane syntax:

%define_cond docs 0%{?fedora} > 0

(Naming and details of syntax are just examples, but the important
parts are: one line, name before value, positive logic).


A followup:

https://github.com/rpm-software-management/rpm/pull/1520

--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
___
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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Richard Shaw
On Mon, Apr 6, 2020 at 2:03 AM Petr Pisar  wrote:

>
> The dist-bound conditional should be specified outside the spec file,
> preferably on a distribution-level. E.g. RHEL decides that it does not
> want to distribute a documentation, then it defines "%_without_docs 1" in
> srpm
> build root macros.
>
> This way the package becomes fully agnostic of the distribution it builds
> in.
> No hard-coded exceptions anymore.
>

That may work fine for distro based decisions but 100% of the distro based
conditionals I use are to work around package dependency versioning or
availability, which that wouldn't solve.

Thanks,
Richard
___
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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Panu Matilainen

On 4/6/20 12:53 PM, Nicolas Mailhot via devel wrote:

Le lundi 06 avril 2020 à 09:03 +0200, Petr Pisar a écrit :


# Build an HTML manual with ascidoc
%bcond_without docs
# Perform the tests
%bcond_without tests


I feel the above syntax is hopeless. You need boilerplate (in all eln
specs!) to explain that foo_without tests means enabling tests.

Good syntax does not need line-by-line comments.


Agreed, but miscommenting only spreads the confusion further.
Once you accept what it actually does instead of thinking what you'd 
wish it was, it starts making more sense:


# Add an option to build without running tests
%bcond_without tests

...because *that* is what it does. Also because of this, 
%bcond_with/without is very ill-suited to the kind of distro-wide 
default settings being discussed.


- Panu -



Regards,


___
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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Petr Pisar
On Mon, Apr 06, 2020 at 11:53:55AM +0200, Nicolas Mailhot via devel wrote:
> Le lundi 06 avril 2020 à 09:03 +0200, Petr Pisar a écrit :
> > 
> > # Build an HTML manual with ascidoc
> > %bcond_without docs
> > # Perform the tests
> > %bcond_without tests
> 
> I feel the above syntax is hopeless. You need boilerplate (in all eln
> specs!) to explain that foo_without tests means enabling tests.
> 
> Good syntax does not need line-by-line comments.
> 
The comments are not because of a bad syntax of %bcond_without. The comments
explain what "docs" means. It can be a user manual for a package, it can be an
API documentation for another package. While "docs" or "tests" looks
self-decribing, there can be another identifiers whose meaning or implications
are not so obvious. Here in the exampl it actually provides a very useful hint
that if you enable documentation, you will need ascidoc (probably a new
dependency).

If your only issue is the %bcond_with" and %bcond_without semantics, then
I agree. But that's only a matter of chosing a better word. Nothing that
cannot be fixed.

However, in my opinion, the build knobs should not be burried in the spec file
for the sole purpose of building this one package.

The knobs should be visibile on RPM level in the source RPM package so that
one can query a repository for what new depencies I will need when I enable
"docs". Now one needs to inspect each spec file or rebuild the SRPMs. Quite an
expensive task.

Also the knobs should be inheritable. There should be a distribution-level
"docs" knob and then a package-level "docs" knob. So that a distribution can
disable/enable the documentation everywhere with one switch and at the same
time can specify the exceptions for the individual packages.

I really recommend to people interested in this topic to look on Gentoo USE
flags because this is a feature extensively used there so it's more probable
it's done right there:

A packager's view 

A user's view 
A fancier USE flag index 

-- Petr


signature.asc
Description: PGP signature
___
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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Apr 06, 2020 at 09:03:08AM +0200, Petr Pisar wrote:
> On Sat, Apr 04, 2020 at 03:14:07PM +, Zbigniew Jędrzejewski-Szmek wrote:
> > This is not what we were discussing. This should be compared with
> > %bcond_with/%bcond_without, which would looks like this:
> > 
> > %if 0%{?fedora} > 0
> > %bcond_without docs
> > %bcond_without tests
> > %endif
> > 
> > %if 0%{?rhel} > 0
> > %bcond_with docs
> > %bcond_without tests
> > %endif
> > 
> > Which IMO clearly loses the contest.
> > 
> > Returning to the one-definition vs. multiple-definitions issue:
> > I think I'd prefer the shorter version, though I admit it's pretty
> > close in this case.
> > 
> > The biggest usage problem is that rpm does not verify that everything
> > is assigned, so (with a longer list) it's fairly easy to forget to
> > define one of the items in one of the cases, silently leaving a
> > feature disabled.
> > 
> > Also, things quickly get complicated when issues depend on one another:
> > %define_cond docs 0%{?fedora} > 0 || 0%{rhel} >= 8
> > %define_cond tests 1
> > %define_cond doc-tests %{with_docs} && %{with_tests} && 0%{?rhel} >= 9
> > 
> > Ideally, we would be able to do both, and e.g. in this case use
> > the "verbose" style for the first two switches, and the one-line style
> > for the third condition.
> > 
> Ideally, there should be no dist-bound conditions (%if 0%{?rhel} > 0). In the
> spec file should only be a list of the switches with their default state
> (on/off), possibly with a documentation:
> 
> # Build an HTML manual with ascidoc
> %bcond_without docs
> # Perform the tests
> %bcond_without tests
> 
> The dist-bound conditional should be specified outside the spec file,
> preferably on a distribution-level. E.g. RHEL decides that it does not
> want to distribute a documentation, then it defines "%_without_docs 1" in srpm
> build root macros.

Standarization of common defines is a different aspect of the whole
issue. To make them work, we would need to standarize such defines and
include them in Packaging Guidelines. (I'm only aware of 'bootstrap'
being mentioned in PG right now.) I think it would be generally useful
to have 'bootstrap', 'docs', and 'tests' standarized.

> This way the package becomes fully agnostic of the distribution it builds in.
> No hard-coded exceptions anymore.

I don't think this would ever be possible — there's plenty of other
conditions which don't fall into such neat global categories.

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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Nicolas Mailhot via devel
Le lundi 06 avril 2020 à 09:03 +0200, Petr Pisar a écrit :
> 
> # Build an HTML manual with ascidoc
> %bcond_without docs
> # Perform the tests
> %bcond_without tests

I feel the above syntax is hopeless. You need boilerplate (in all eln
specs!) to explain that foo_without tests means enabling tests.

Good syntax does not need line-by-line comments.

Regards,

-- 
Nicolas Mailhot
___
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


Re: %bcond_with/%bcond_without

2020-04-06 Thread Petr Pisar
On Sat, Apr 04, 2020 at 03:14:07PM +, Zbigniew Jędrzejewski-Szmek wrote:
> This is not what we were discussing. This should be compared with
> %bcond_with/%bcond_without, which would looks like this:
> 
> %if 0%{?fedora} > 0
> %bcond_without docs
> %bcond_without tests
> %endif
> 
> %if 0%{?rhel} > 0
> %bcond_with docs
> %bcond_without tests
> %endif
> 
> Which IMO clearly loses the contest.
> 
> Returning to the one-definition vs. multiple-definitions issue:
> I think I'd prefer the shorter version, though I admit it's pretty
> close in this case.
> 
> The biggest usage problem is that rpm does not verify that everything
> is assigned, so (with a longer list) it's fairly easy to forget to
> define one of the items in one of the cases, silently leaving a
> feature disabled.
> 
> Also, things quickly get complicated when issues depend on one another:
> %define_cond docs 0%{?fedora} > 0 || 0%{rhel} >= 8
> %define_cond tests 1
> %define_cond doc-tests %{with_docs} && %{with_tests} && 0%{?rhel} >= 9
> 
> Ideally, we would be able to do both, and e.g. in this case use
> the "verbose" style for the first two switches, and the one-line style
> for the third condition.
> 
Ideally, there should be no dist-bound conditions (%if 0%{?rhel} > 0). In the
spec file should only be a list of the switches with their default state
(on/off), possibly with a documentation:

# Build an HTML manual with ascidoc
%bcond_without docs
# Perform the tests
%bcond_without tests

The dist-bound conditional should be specified outside the spec file,
preferably on a distribution-level. E.g. RHEL decides that it does not
want to distribute a documentation, then it defines "%_without_docs 1" in srpm
build root macros.

This way the package becomes fully agnostic of the distribution it builds in.
No hard-coded exceptions anymore.

-- Petr


signature.asc
Description: PGP signature
___
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


Re: %bcond_with/%bcond_without

2020-04-04 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Apr 04, 2020 at 11:31:04AM +0200, Aleksandra Fedorova wrote:
> Hi,
> 
> On Fri, Apr 3, 2020 at 10:38 PM Zbigniew Jędrzejewski-Szmek
>  wrote:
> >
> > On Fri, Apr 03, 2020 at 02:23:12PM -0400, Stephen Gallagher wrote:
> > > Fabio Valenti made this comment in the FESCo ticket[1].
> > >
> > > "Side note: I think more people would be amenable to including
> > > "conditionals" into their packages if they weren't only shown off as
> > > `%if eln this else that`. I think there's more value in doing "feature
> > > flags" rather than conditionalize everything based on the `dist` tag,
> > > for example something like this might even be useful in fedora
> > > branches (e.g. for bootstrapping):
> > >
> > > ```spec
> > > # at the top of the .spec file, where it's easily visible
> > > %if 0%{?eln}
> > > %bcond_with docs
> > > %else
> > > %bconf_without docs
> > > %endif
> > >
> > > # ...
> > >
> > > %if %{with docs}
> > > # do something
> > > %endif
> > > ```
> > >
> > > This makes conditionals (when they are necessary) much easier to
> > > maintain (and understand), in my experience."
> >
> > This is a side topic, and I didn't want to clutter the FESCo ticket
> > with that. But here we have threads, so I hope that you'll forgive me ;)
> >
> > If find the %bcond_with/%bcond_without pattern abhorrent.
> >
> > 1. The logic is reversed: when I see "with" I think something is enabled,
> >when I see "without" I think something is disabled. But it's actually
> >the other way around here, which I find very confusing and often get
> >the condition reversed on the first try.
> >
> > 2. The value ('0%{?eln}') in this example is expressed before the name
> >('docs'), which is like saying 'value =: name'.
> >
> > 3. It takes five (!) lines to express the something that should be one
> >line.
> >
> > So... could we please get a way to express this in rpm with a sane syntax:
> >
> > %define_cond docs 0%{?fedora} > 0
> 
> I am all for clarity and cleaner syntax.
> But I don't think this particular example is a good illustration for
> it. If we have more then one switch, or more than one set of switches
> it won't work.
> 
> Something like:
> 
> %if 0%{?fedora} > 0
> %define_cond docs 1
> %define_cond tests 1
> %endif
> 
> %if 0%{?rhel} > 0
> %define_cond docs 0
> %define_cond tests 1
> %endif
> 
> is more readable than
> 
> %define_cond docs 0%{?fedora} > 0
> %define_cond tests (0%{?fedora} > 0 OR 0%{?rhel} > 0)
> 
> even though there are more lines in it.

This is not what we were discussing. This should be compared with
%bcond_with/%bcond_without, which would looks like this:

%if 0%{?fedora} > 0
%bcond_without docs
%bcond_without tests
%endif

%if 0%{?rhel} > 0
%bcond_with docs
%bcond_without tests
%endif

Which IMO clearly loses the contest.

Returning to the one-definition vs. multiple-definitions issue:
I think I'd prefer the shorter version, though I admit it's pretty
close in this case.

The biggest usage problem is that rpm does not verify that everything
is assigned, so (with a longer list) it's fairly easy to forget to
define one of the items in one of the cases, silently leaving a
feature disabled.

Also, things quickly get complicated when issues depend on one another:
%define_cond docs 0%{?fedora} > 0 || 0%{rhel} >= 8
%define_cond tests 1
%define_cond doc-tests %{with_docs} && %{with_tests} && 0%{?rhel} >= 9

Ideally, we would be able to do both, and e.g. in this case use
the "verbose" style for the first two switches, and the one-line style
for the third condition.

Zbyszek

P.S. '%bcond  ' suggested in [1] is clearly a better
name than '%define_cond'.

[1] https://github.com/rpm-software-management/rpm/issues/941
___
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


Re: %bcond_with/%bcond_without

2020-04-04 Thread Richard Shaw
On Sat, Apr 4, 2020 at 4:32 AM Aleksandra Fedorova 
wrote:

> Something like:
>
> %if 0%{?fedora} > 0
> %define_cond docs 1
> %define_cond tests 1
> %endif
>
> %if 0%{?rhel} > 0
> %define_cond docs 0
> %define_cond tests 1
> %endif
>

Isn't the >0 superfluous?  Just the "%if 0%{?fedora}" will evaluate as TRUE.

Thanks,
Richard
___
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


Re: %bcond_with/%bcond_without

2020-04-04 Thread Aleksandra Fedorova
Hi,

On Fri, Apr 3, 2020 at 10:38 PM Zbigniew Jędrzejewski-Szmek
 wrote:
>
> On Fri, Apr 03, 2020 at 02:23:12PM -0400, Stephen Gallagher wrote:
> > Fabio Valenti made this comment in the FESCo ticket[1].
> >
> > "Side note: I think more people would be amenable to including
> > "conditionals" into their packages if they weren't only shown off as
> > `%if eln this else that`. I think there's more value in doing "feature
> > flags" rather than conditionalize everything based on the `dist` tag,
> > for example something like this might even be useful in fedora
> > branches (e.g. for bootstrapping):
> >
> > ```spec
> > # at the top of the .spec file, where it's easily visible
> > %if 0%{?eln}
> > %bcond_with docs
> > %else
> > %bconf_without docs
> > %endif
> >
> > # ...
> >
> > %if %{with docs}
> > # do something
> > %endif
> > ```
> >
> > This makes conditionals (when they are necessary) much easier to
> > maintain (and understand), in my experience."
>
> This is a side topic, and I didn't want to clutter the FESCo ticket
> with that. But here we have threads, so I hope that you'll forgive me ;)
>
> If find the %bcond_with/%bcond_without pattern abhorrent.
>
> 1. The logic is reversed: when I see "with" I think something is enabled,
>when I see "without" I think something is disabled. But it's actually
>the other way around here, which I find very confusing and often get
>the condition reversed on the first try.
>
> 2. The value ('0%{?eln}') in this example is expressed before the name
>('docs'), which is like saying 'value =: name'.
>
> 3. It takes five (!) lines to express the something that should be one
>line.
>
> So... could we please get a way to express this in rpm with a sane syntax:
>
> %define_cond docs 0%{?fedora} > 0

I am all for clarity and cleaner syntax.
But I don't think this particular example is a good illustration for
it. If we have more then one switch, or more than one set of switches
it won't work.

Something like:

%if 0%{?fedora} > 0
%define_cond docs 1
%define_cond tests 1
%endif

%if 0%{?rhel} > 0
%define_cond docs 0
%define_cond tests 1
%endif

is more readable than

%define_cond docs 0%{?fedora} > 0
%define_cond tests (0%{?fedora} > 0 OR 0%{?rhel} > 0)

even though there are more lines in it.

>
> (Naming and details of syntax are just examples, but the important
> parts are: one line, name before value, positive logic).
>
> Zbyszek
> ___
> 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


-- 
Aleksandra Fedorova
bookwar
___
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


Re: %bcond_with/%bcond_without

2020-04-03 Thread Sérgio Basto
On Fri, 2020-04-03 at 20:36 +, Zbigniew Jędrzejewski-Szmek wrote:
> 1. The logic is reversed: when I see "with" I think something is
> enabled,
>when I see "without" I think something is disabled. But it's
> actually
>the other way around here, which I find very confusing and often
> get
>the condition reversed on the first try.

%bcond_with , means that you can add --with , so the default is without
:) 

in /lib/rpm/macros line 95 , you got the documentation. 

-- 
Sérgio M. B.
___
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


Re: %bcond_with/%bcond_without

2020-04-03 Thread Christopher Engelhard
On 03.04.20 22:36, Zbigniew Jędrzejewski-Szmek wrote:
> So... could we please get a way to express this in rpm with a sane syntax:
> 
> %define_cond docs 0%{?fedora} > 0

Oh please, yes.

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


Re: %bcond_with/%bcond_without

2020-04-03 Thread Miro Hrončok

On 03. 04. 20 22:36, Zbigniew Jędrzejewski-Szmek wrote:

So... could we please get a way to express this in rpm with a sane syntax:

%define_cond docs 0%{?fedora} > 0

(Naming and details of syntax are just examples, but the important
parts are: one line, name before value, positive logic).


Yes please. See 
https://github.com/rpm-software-management/rpm/issues/941#issuecomment-584697721


--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
___
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