rust2rpm: add support for "testrequires" setting in rust2rpm.conf

Dependencies listed as "testrequires" are handled the same as dependencies
that are listed as "buildrequires", except that they are wrapped in an
"%if %{with check}" conditional in the generated spec file.
This commit is contained in:
Fabio Valentini 2022-10-26 11:55:47 +02:00
parent 60dc5dfb99
commit ff04186184
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF
2 changed files with 17 additions and 0 deletions

View file

@ -23,6 +23,9 @@ These configuration options are available right now:
compiler internals for crates that are also bundled with Rust itself)
- `buildrequires`: additional build dependencies that must be installed for the
package to build correctly (i.e., `pkgconfig(foo)` for the `foo-sys` crate)
- `testrequires`: additional build dependencies that must be installed for the
package's tests to build and / or run correctly (treated like `buildrequires`,
but wrapped in an `%if %{with check}` conditional in the generated spec)
- `lib.requires`: additional build dependencies that must be installed for the
crate to build correctly as a dependency of another crate (usually, this
contains the same values as the `buildrequires` option)

View file

@ -78,6 +78,13 @@ BuildRequires: {{ req }}
{% for req in to_list(distconf.get("buildrequires"))|sort %}
BuildRequires: {{ req }}
{% endfor %}
{% if distconf.get("testrequires") %}
%if %{with check}
{% for req in to_list(distconf.get("testrequires"))|sort %}
BuildRequires: {{ req }}
{% endfor %}
%endif
{% endif %}
{% if has_buildrequires and not only_main %}
{% endif %}
{% endif %}
@ -205,6 +212,13 @@ use {% if feature is not none %}the "{{ feature }}" feature of {% endif %}the "%
{% for req in to_list(distconf.get("buildrequires"))|sort %}
echo {{ "%r" | format(req) }}
{% endfor %}
{% if distconf.get("testrequires") %}
%if %{with check}
{% for req in to_list(distconf.get("testrequires"))|sort %}
echo {{ "%r" | format(req) }}
{% endfor %}
%endif
{% endif %}
{% endif -%}