Commit graph

430 commits

Author SHA1 Message Date
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
598c5e3972 Guess crate name based on %crate or directory name
This makes is much nicer to work with dist-git: the same command
without modifications can be used for different crates.
2022-07-08 09:32:17 +02:00
628fb7c494 Skip pre-release versions when looking for the lastest
Fixes #57.
2022-07-06 12:49:39 +02:00
4436a110cf Use separate lines for each file in %doc/%license
Fixes #187.
2022-07-06 12:49:39 +02:00
c18514544e Move old test file under src/tests/ 2022-07-05 17:01:36 +02:00
03584a81e4 Stop translating license for Fedora and EPEL
The infrastracture to translate the license remains in place.
We can remove it later, when all users are gone. I'm keeping
the behaviour for Mageia unchanged for now. I assume that they'll
want to follow the change in Fedora later too.

We still want to do syntax cleanup with translate_slashes().

Fixes #193.
2022-07-04 09:45:25 +02:00
92edcce644 Refactor the patching code to pass args lower in the call stack
The code is complicated by passing behaviour options through multiple
levels. This is already hard to read because the names are different
at different levels. Let's just pass args, so that it's easy to add
new options in the future.
2022-07-04 09:45:25 +02:00
91230d4eba Invert negative arguments in --help parsing
"Negative logic" is harder to follow. We may define only a
negative option for users, but we should still convert it to a normal
boolean internally.
2022-07-04 09:45:25 +02:00
91907b066f Use just a single field for handling of --build-requires
Having two fields in the args structure is super ugly. Let's just
use one field, and assign True or False to it.

No change in function.
2022-07-04 09:45:25 +02:00
1d225f99b1 Make --no-rpmautospec actually work
It seems I screwed up the implementation one hundred percent.
2022-07-04 09:45:25 +02:00
166214f834 docs: start adding docstrings to functions
I don't have enough energy to do this for all functions, but I'll try
to add some docs as I look at the code. The project is growing and it's
harder to remember what all the parts do.
2022-07-04 09:45:25 +02:00
30fa63961e
spec template: Remove unnecessary patch numbering
Signed-off-by: Maxwell G <gotmax@e.email>
2022-07-03 18:26:41 -05:00
98638813aa
macros.cargo: vacuum up Cargo.toml.orig in addition to Cargo.lock
This fixes builds with cargo from Rust 1.62+, which now complains
and fails our builds if the Cargo.toml.orig file already exists.
2022-07-01 19:29:56 +02:00
4b93531d5f
Allow setting the "all-features" setting in rust2rpm.conf
This new setting works the same way as the `--all-features` CLI flag
when set to `true`. This makes it possible to set it to `true` permanently,
without having to remember to use the CLI flag when running rust2rpm.
2022-06-06 21:37:00 +02:00
63acdf63c4 Accept and move to rust2rpm.conf as standard config file location
Using .rust2rpm.conf is confusing to new users, because they never see
these files in existing packages and are only seeing magic happen.

This commit changes the default location of the configuration file to
./rust2rpm.conf, and will rename existing .rust2rpm.conf or _rust2rpm.conf
files to the new name if they already exist.

I have also added a little more documentation about the config file itself
to the README.
2022-06-06 07:33:54 +00:00
Anders Blomdell
f54be37deb Base rpmautospec on choosen target instead of default_target 2022-06-03 16:42:13 +02:00
7d8c9a8028 Print information about written files
We already output some messages, but not the most important part: what
files were written.
2022-02-28 15:06:51 +01:00
b9e95b4d61 Fix autodetection of rpmautospec
When store_true or store_false are used, the default default changes
from None to a boolean. I didn't know about this, and I wrote the code
to assume args.rpmautospec would be None. rpmautospec detection was
effectively always disabled.
2022-02-28 15:06:51 +01:00
1b14d44d57 Allow easy overriding of the opt-level/debuginfo/codegen-units flags
Some crates use debuginfo=0 or debuginfo=1 to reduce memory pressure during
builds. This should make this easy.

Fixes https://pagure.io/fedora-rust/rust2rpm/issue/181
2022-02-22 12:05:49 +01:00
0aa82d22b0 Add comment about unused macro 2022-02-22 11:28:52 +01:00
cc8cabd57b Version 21 2022-02-20 15:51:04 +01:00