Hi, I may be overlooking the obvious, but how can I specify the rpmbuild parameters? So far I have resorted to hardcoding the settings inside the spec file, but that does not work very well over a broader range of distro versions.
rpmbuild --with/–without arguments are simply translated into macros at runtime. It is up to your spec file to check whether macro is set and change behavior accordingly.
However, kafka is never defined, not even on Tumbleweed. So I thought I need to provide a --with-kafka to rpmbuild. But I do not know how to do that on “osc build” and much less on how to do that when submitting to the OBS web service (which is my ultimate goal to use).
into the spec without a conditional around it. Doesn’t work either.
I now tried to resort to
%define with_kafka 1
And checking with
%if %{with_kafka}
again, no success.
I see, however, that macros actually trigger for which the spec unconditionally says:
%bcond_without some_feature
Which means some_feature get’s activated albeit of the bcond_without.
This brings me to the conclusion that something external to the spec must turn these settings on or off. I am getting a bit desperate. I have “solved” the issue by doing different specs for other distros, but that’s really a bad hack.
to work. The work-around I found works for me, but I would really like to understand why %bcond does not work (or other said: how to provide the external parameters obviously required).
Sorry, did not pay enough attention (sometimes it is hard to spot underscores). That’s wrong. %with_kafka is defined only if condition is met, otherwise it is not defined and you get an error. You really should use %{with kafka} (pay attention - it is space, not underscore). Here %{with} is macro which takes one argument and expands to 0 or 1 depending on whether corresponding %with_kafka (notice underscore) is defined. %with_kafka itself is defined by %bcond_with (or %bcond_without) macros. There is also %{without foo} macro for convenience.
Otherwise you must check first whether macro is defined (%{?with_kafka …}, %{defined with_kafka} or similar), but %{with foo} macro already does it for you. It is equivalent to 0%{with_kafka}.
To me this looks much cleaner than the “inverse bcond logic” - but if you are more fluent with RPM, that’s probably a mood point. So maybe it is even clearer, if I use this approach, to name the macro like “build_kafka”. So it is clear it’s not related to the with/without RPM logic.
That said, I am still glad for your answer as it helps to understand. I’ll also play a bit more with %bcond_with and _without.
The question that is still not answered is if there is any way to provide rpmbuild parameters (e.g. --with-kafka) on OBS. Is this possible? As of my current understanding it is impossible, so we need to resort to the default values and set them accordingly.
You can define macros in project configuration, so you can have multiple projects using the same spec file with different macro values. See Project Configuration | User Guide
Actually no - I am literally after what I have asked. I now know how to build multiple projects from the spec file. However, I would still be interested to know if there is any setting external to the spec file which can be used to provide parameters to rpmbuild.
I admit the question is out of curiosity, but the answer will possible also show a misunderstanding on my part (if there is a way). I think about things like project config or so.
Well, maybe it’s actually the answer There is nothing listed in the project config settings, so there seems to be now way to specify e.g. --with-kafka rpmbuild parameter. Instead I can use macros as you say.
If that’s correct I think my confusion is cleared up