Hi,
On Fri, Apr 3, 2020 at 10:38 PM Zbigniew Jędrzejewski-Szmek
<zbyszek(a)in.waw.pl> 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(a)lists.fedoraproject.org
To unsubscribe send an email to devel-leave(a)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