[opensuse-packaging] Conditionals and BuildRequires
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi fellow packagers, I'm attempting to add a conditional in spec for running tests in a package. The goal is to have an option to disable the tests in %check and conditionally removing the related build requirements. The example is a python package [1]. The conditional is "%bcond_without test" and the test requirements are wrapped in an if clause like: %if %{with test} BuildRequires: %{python_module blinker} ... %endif Similarly the %check section looks like: %if %{with test} %pytest %endif I've added the following to the project config: Macros: %_without_test 1 :Macros However, OBS does not respect the conditonal and complains that some of the BuildRequires inside the if block are unresolvable. I've tested this with another package where there are no missing build requirements and OBS skips the tests as expected. Is there a way to have OBS ignore the BuildRequires inside a conditional like this? [1] https://build.opensuse.org/package/show/home:seanmarlow:branches:devel:langu... Thanks, - -- Sean Marlow Public Cloud Developer sean.marlow@suse.com -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEqA16xWoe2L38VgYCJ30GzZDdUEsFAl1BthQACgkQJ30GzZDd UEvIwxAAli4YLTwvMt9xHTWtAgNATPA+xuyAPlPK5t4yAXdEyRFY2X7QQVm1Uc3T H0odA/s46260OW0qiCA+moVN9Yvv1ooeWWat1Ybz0rdXJ5cB70QJ40Nd1Hx60b81 G7S3OSbJWEQf8OOCBsorcFZMsUTRoyyKiyN0V4ulWvV42UCLuIY+mj7/yIgrJG1s 35KtIoFSxaHWAvJCulWhtamoleRZdwlc8G6WdyW7nhvQI8LjVjvveFKSOGLZqofn rtn+0zYhNZMvGU0BttPbs1zm1kofx5jMKu/K7VkRJzfZuaFru37kSf2xl2qt6bWs rQXPy8L3848puYoBrHFJsFFaQRrQjSz2gRs+Bjs0LcBkgeReWdEwnH1AW2DSR1EA 0MLaXjpS034yjqud7gWdLLK1LqXQeBOiCyAvdAZhYuvp9lZNI/JmEENoeMvL5KJz X7CnVvY7Qn+cPDEcwignVXaPcVy/9db2OUTjtG4Wq5B4owbk95ytcl3o70w8yvdc auJe/rZRY1mSjFQx442MstSXtLzdw0LnRHRkoP6YKHSasr7ZJQfUWcm3qJjkE1QJ PsQe01SiVCrm842kLuJ7HVYh/0mibqIVfrV321nD0z2FxAhDEbOU/ufQK07khhM+ /3zAJ5P0jLFbyoQwLSoYJFOKZwOEVulyBmgSNIprMBWmMtQKwSE= =XiDg -----END PGP SIGNATURE----- N�����r��y隊Z)z{.��ZrF��x>�{.n�+������Ǩ��r��i�m��0��ޙ���������$j���0�����Ǩ�
Hello, Am Mittwoch, 31. Juli 2019, 17:39:05 CEST schrieb Sean Marlow:
I'm attempting to add a conditional in spec for running tests in a package. The goal is to have an option to disable the tests in %check and conditionally removing the related build requirements. The example is a python package [1].
The conditional is "%bcond_without test" and the test requirements are wrapped in an if clause like:
I'll copy&paste a comment I added to apparmor.spec years ago: # warning - confusing syntax ahead ;-) # bcond_with means "disable" # bcond_without means "enable" So to disable the tests, you'll need %bcond_with test Regards, Christian Boltz --
Und wie nennt man das Gegenteil von Durstig? Besoffen. [Kai Poehlmann & Mickey Kottenhahn in detebe]
-- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Wed, 2019-07-31 at 18:56 +0200, Christian Boltz wrote:
Hello,
Hi,
Am Mittwoch, 31. Juli 2019, 17:39:05 CEST schrieb Sean Marlow:
I'm attempting to add a conditional in spec for running tests in a package. The goal is to have an option to disable the tests in %check and conditionally removing the related build requirements. The example is a python package [1].
The conditional is "%bcond_without test" and the test requirements are wrapped in an if clause like:
I'll copy&paste a comment I added to apparmor.spec years ago:
# warning - confusing syntax ahead ;-) # bcond_with means "disable" # bcond_without means "enable"
So to disable the tests, you'll need %bcond_with test
This is not what I understood from reading the docs even though they are very confusing [2]. "That is, if you defined --with, and now you want to use --without, the right way to do is do nothing, because if you define --with, the default will leave as without." - From the docs it seems bcond_with is ignored by default so tests would not run. To enable tests you add the with macro to the project conf. The bcond_without is enabled by default. To disable tests you add the without macro to the project conf. The tests should be enabled by default so that's why I chose the bcond_without option. The %check section seems to work as expected when the without macro is added to project conf. The tests are not run. However, even though the BuildRequires are in a similar if clause OBS still picks those up and expects them to resolve even when tests are disabled. The information on setting the macro value I found at [3].
Regards,
Christian Boltz --
Und wie nennt man das Gegenteil von Durstig? Besoffen. [Kai Poehlmann & Mickey Kottenhahn in detebe]
[2] https://en.opensuse.org/openSUSE:RPM_conditional_builds [3] https://en.opensuse.org/openSUSE:Build_Service_prjconf Thanks, - -- Sean Marlow Public Cloud Developer sean.marlow@suse.com -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEqA16xWoe2L38VgYCJ30GzZDdUEsFAl1B11cACgkQJ30GzZDd UEusoQ//fYifn/iIUJTV0okm5oCYI+ekclj/NArIoVQk7FGTcEFtQ/YURy0ZlMb4 B+cnzhb91bNhnv7c/P2hF6CWZudBU/+qM6R+5PA6XKheutVWttjkHP989Jq71DS5 3Gl0P27fPd9RQ4j9fhMrbnLAreki4tsigS53X4Hcdg/gYExNntPpaaOrQOJ2N4+b e9ynUPocHLV1HzR3wra0uaMFFdpvBqPZXPpYtp4QehaY+8uMxVOnX4pWg/3qImh5 uwW+Ym0FlPctVMQ9cZm0AHXakLdTnszojna1HIi0PBTLIIdyn3kzOgrCz+E9+bpQ il3M2nCJ9kOmM+61pWCjwSIKr+5/sdUZz3ewkgLABQQBTcwP1nC8/GPDuij74Wks B42EjUMYZUfYxJv8/xJh3LG6V23+eaxXu9p0JAOMhlOZSDLTkrSeiSaMWmJ+Io8B z2hbujJE5wb18mLW/iL+je72z+/6+25n5ICC7oTjvooXmUJ3r9cEOdI+q4+F/WZH YxB6SwdwasCDbomXADYot7OzVCRQIrtW2b/1PBsbAMyRv8OqQqEIAEL2sy62t+9i wMMtKNLb9EcmhD32ZxPCZmqkV9IADgE3/OBEUQgIeMgyP5k/dcpyxdPqRPhau0AT 1A0M6QZAA5wINnCcjgTuX7RwD6RtNjE7D1RJ/snbPBWMbGi0cbQ= =Yci/ -----END PGP SIGNATURE-----
On Wednesday, 31 July 2019 18.56.48 CEST Christian Boltz wrote:
Hello,
Am Mittwoch, 31. Juli 2019, 17:39:05 CEST schrieb Sean Marlow:
I'm attempting to add a conditional in spec for running tests in a package. The goal is to have an option to disable the tests in %check and conditionally removing the related build requirements. The example is a python package [1].
The conditional is "%bcond_without test" and the test requirements
are wrapped in an if clause like: I'll copy&paste a comment I added to apparmor.spec years ago:
# warning - confusing syntax ahead ;-) # bcond_with means "disable" # bcond_without means "enable"
So to disable the tests, you'll need %bcond_with test
Correct: Read "bcond_with" as "only define the following if set as build condition, which is not set by default. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (3)
-
Christian Boltz
-
Oliver Kurz
-
Sean Marlow