Commit graph

350 commits

Author SHA1 Message Date
60dc5dfb99
macros: replace i686 with %{ix86} in %{rust_arches}
This change has been present in downstream Fedora packaging for ages,
let's just merge it upstream.
2022-10-26 11:45:49 +02:00
feab8e6a41
rust2rpm: drop ExclusiveArch: %{rust_arches} on Fedora
RPM will gain a dependency on a Rust component (rpm-sequoia), so all
architectures supported by RPM will by definition be the architectures
supported by Rust, making the ExclusiveArch tag unnecessary.

c.f. https://pagure.io/fedora-rust/rust2rpm/issue/228
c.f. https://pagure.io/packaging-committee/issue/1220
2022-10-26 11:38:11 +02:00
69b5574ce0
Add %cargo_license and %cargo_license_summary macros 2022-10-19 11:39:20 +02:00
23523b5fdc
rust2rpm: fall back to latest pre-release if there is no stable release
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
2022-10-11 14:19:08 +02:00
93e10cba84
spec template: sort listed binaries in %files listing 2022-10-11 13:03:21 +02:00
5bc8840a67
rust2rpm: only remove optional target-specific deps from features 2022-10-09 21:24:57 +02:00
c026764e94
Adapt cfg-expression evaluation for the new wasm64 target_arch 2022-09-05 17:20:43 +02:00
55998b3bd2
Ensure both generated and manual patches affect spec generation
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.
2022-07-26 12:13:47 +02:00
f0d04b09e8
Ensure rust2rpm doesn't autogenerate architecture-dependent patches
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).
2022-07-25 12:09:43 +02:00
cc4e5fd341
Version 22 2022-07-24 18:55:35 +02:00
a16df5f90f
Enforce consistent formatting with black 2022-07-24 18:47:09 +02:00
f31fd721f5
Ensure rust2rpm reads crate metadata is read from the patched file
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.
2022-07-24 13:01:40 +02:00
c4488a3fe8
Prettify and slightly reformat printed log messages 2022-07-24 12:52:09 +02:00
67c878e32a
Implement simple logging; ensure rust2rpm --stdout still works 2022-07-24 11:21:30 +02:00
a090caaa62
Adapt diff files generated by rust2rpm v22 to be more like those from v21
- change file names of written patches to match the old one
- don't leak the name of temporary directories into the diff
2022-07-24 10:07:33 +02:00
1763c73dfa
Ensure exactly one trailing newline in rendered spec files 2022-07-24 00:54:18 +02:00
53d07c28ad
Drop false claims of support Python 3.8 or 3.9
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.
2022-07-23 19:41:48 +02:00
407e56c606
Update tox environments to match supported Python versions 2022-07-23 18:58:24 +02:00
1209f5f08f
Port to declarative setuptools configuration 2022-07-22 17:45:04 +02:00
c464cecfff
Add missing pyparsing dependency to setup.py install_requires 2022-07-22 16:51:33 +02:00
c834a9658a
Update tox settings to work with the latest changes 2022-07-22 15:48:14 +02:00
fb78d645d6 README: add brief note about testing 2022-07-21 13:11:13 +02:00
aa7e1310d2
minor code fixes and cleanups all around 2022-07-20 20:53:36 +02:00
6e9bbc14e5 Declare compatiblity with python3.11
Tested with python3-3.11.0~b3-8.fc37.x86_64, seems to work fine.
2022-07-15 15:05:30 +02:00
6712419366 cfg: rename variable for clarity 2022-07-15 15:05:30 +02:00
d231aa7d0b cfg: fix compatibility with pyparsing 2.4.7
I was developing this with 3.0.1. Seems to work fine after some simple
adjustments.
2022-07-15 15:05:27 +02:00
bca49d9143 tests: avoid syntax deprecated in python 3.11 2022-07-15 12:33:48 +02:00
59eb676441 Treat empty environment variables as unset
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.
2022-07-15 12:33:25 +02:00
365d47a843 Use walrus more
It was already used in other places, so this doesn't change much.
Walrus was added in 3.8, so drop 3.7 from the compat list.
2022-07-15 12:33:25 +02:00
cd1281d709 Use python3.7 syntax for subprocess.call
Since text= was added in 3.7, let's drop 3.6 from the compat list.
2022-07-15 12:33:25 +02:00
fa659143ad Rename packager_identity to packager
For some reason, the same thing was called differently in some parts
of the code. Let's use the same name everywhere.
2022-07-15 12:33:25 +02:00
d4655c252b Split out util.py with generic helpers
This way we can keep the length of the main file down a bit.
2022-07-15 12:31:38 +02:00
5630d7df1e tests: adjust imports
Fixup for 093eef77a7.
2022-07-15 12:31:38 +02:00
093eef77a7 rust2rpm: split off core functionality and cargo-inspector 2022-07-15 09:24:58 +00:00
Yizheng Xie
be5ee90bc4 Add CC-PDDC to license list 2022-07-14 16:12:58 -07:00
Zbigniew Jędrzejewski-Szmek
2b28554e5e Merge #183 Automatically strip foreign dependencies 2022-07-12 08:52:22 +00:00
a57d4b2c95 Automatically strip foreign dependencies
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.
2022-07-12 10:48:16 +02:00
d326bb0180 Add cfg.parse_and_evaluate() 2022-07-12 10:48:16 +02:00
61e7b5fc7a Add parser and evaluator for rust cfg expressions 2022-07-12 10:48:16 +02:00
Zbigniew Jędrzejewski-Szmek
80602add3d Merge #200 Add tests that actually test spec file generation 2022-07-12 08:46:57 +00:00
3fdc1b24cb Make sure the generated spec file has the trailing newline 2022-07-08 16:51:02 +02:00
cdfed25089 tests: fix date in output
Otherwise we'd get bogus changes on every recreation.
2022-07-08 16:51:02 +02:00
d9c3212961 tests: add a test that does generation for all targets from sample crates 2022-07-08 16:51:02 +02:00
942b435cb3 Refactor code to separate config gathering from spec file generation
This is a prerequisite for testing the rendering logic without invoking
the whole program. But I think it also makes it much easier to see what
is going on.

I used slightly non-standard formatting with extra whitespace because
the invocation was hard to rid otherwise.
2022-07-08 16:38:10 +02:00
a09caca7e3 templates: rename "md" to "metadata"
We also use "md" as short for "markdown", and this abbrevation can be
confusing. It's also weird to use 'md' as the parameter name in an
exported entry point.
2022-07-08 15:55:28 +02:00
274fa18712 Split out parser generation into a separate function 2022-07-08 15:54:35 +02:00
5bf0041067 Do not print comment about license if no conversion was done 2022-07-08 15:54:35 +02:00
345e8accbc
rust2rpm: fix logic in existence check (use correct URL for .spec) 2022-07-08 15:03:35 +02:00
0544354e00
rust2rpm: tweak existence check warning (tweak for compat packages) 2022-07-08 15:00:07 +02:00
aa2bacbad6 Simplify handling of package suffix
Instead of constructing the package name from "rust-" prefix,
the name, and the suffix, let's just do it once.
2022-07-08 09:32:17 +02:00