Some cfg-expressions evaluated to "False" because all target_arch
checks were evaluated as "True", but that broke in situations where
the cfg-expression checked for the *absence* of a match for a specific
target_arch.
With this change, cfg-expressions are now evaluated once for every
supported target_arch, and they evaluate to "True" if the expression
evaluated to "True" for *any* value of target_arch.
The "sort" Jinja2 filter doesn't work because the bins are objects,
not strings. This commit changes the sorting to happen correctly,
before binary targets are passed to the template for rendering.
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 situation can occur in two ways:
- either the crate has published only pre-releases so far, or
- all previously published stable releases were yanked
Previous to this change, if there were no manual changes, the automatically
generated patch would not affect the calculated metadata, and result in
broken .spec files.
The logic in the cfg-expression evaluator checked *too many cases*,
some of which would have resulted in generation of broken patches
and packages. We need to ensure that the evaluation is independent
of the host architecture (i.e. we need to keep *all* dependencies
that are valid on *any* of our build targets, even if they end up
being unused on *some* of them).
When the automatic patching step was implemented, the metadata started
being read from the original Cargo.toml file instead of from the one
with manually applied changes.
Recent changes (in particular, use of the new "structural pattern
matching" syntax, which was introduced in Python 3.10) were already
incompatible with Python <3.10, but neither the tox settings nor
the project metadata had been updated to reflect this fact.
Fedora 35, the oldest currently supported branch of Fedora, already
ships with Python 3.10 by default, so we don't drop support for any
current Fedora releases.
This is slightly undefined, but it's more user-friendly to treat e.g. VISUAL=
the same as $VISUAL being unset. So to use e.g. RUST2RPM_NO_DETECT_PACKAGER,
"RUST2RPM_NO_DETECT_PACKAGER=1" must be used, and "RUST2RPM_NO_DETECT_PACKAGER="
is not enough.
The basic workflow is that very similarly to how we would open an editor to do
manual patching of Cargo.toml, we automatically rewrite the file first. In this
automatic rewrite, for any sections like [target.cfg(…)], we evaluate the
conditional and drop the whole section if the conditional is known to be false.
When the conditional cannot be evaluated because it uses some form that we don't
understand, it is left untouched. But it seems that the conditionals used in
practice don't have too much variety. If parser and evaluator certainly don't
cover all the corner cases, but it might not matter in practice. We can always
fix them later if unsupported cases are found.
Removed dependencies are filter out from [feature] lists:
For example for tokio:
[features]
-net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2", "winapi/namedpipeapi"]
+net = ["libc", "mio/os-poll", "mio/os-ext", "mio/net", "socket2"]
If -p was used, after the automatic filtering, the editor is opened for the user
to do further manual patching.
Automatic and manual changes land in separate patches.
Fixes#2.