Commit graph

335 commits

Author SHA1 Message Date
Alberto Planas
8839912832 inspector: rename force flag 2021-10-12 15:10:33 +02:00
Alberto Planas
ccd5b3aa66 metadata: simplify expression 2021-10-12 15:10:33 +02:00
Alberto Planas
e1f0828151 inspector: work directly with a set 2021-10-12 15:10:33 +02:00
Alberto Planas
e2c6c69c0a metadata: support workspaces for non-virtual crates 2021-10-12 15:10:33 +02:00
Alberto Planas
246ee489a0 Add bundled() provider for vendoring
This commit add basic support for crate vendoring in Rust. The user will
use something like `cargo vendor` to create a vendor directory (that can
later be deployed as a tgz) that contains all the dependencies.

This patch will analyze the output of `cargo manifest` to calculate the
closure of dependencies, and via the new parameter `--provides-vendor`,
print all the 'bundled(crate(NAME/FEATURE)) = 0.0.0' provided by the
binary.

The algorithm is not perfect, as today it will include all the features
resolved for the crate (not all the availables, tho), but basically is
something like:

1.- A dependency generator macro, cargo_bundled, will call
cargo-inspector like this:

  # In STDIN we will provide the name of the binary
  cargo-inspector --provides-vendor --path %{_builddir}

2.- cargo-inspector will search inside the 'path' tree a Cargo.toml that
generate the binary name send via STDIN.

3.- From this point, we go up to the tree to find the top-most
Cargo.toml, as this will be the directory where .cargo/config is living.
We make this directory our `cwd`.

4.- Using the metadata from `cargo manifest`, we generate the closure of
dependencies required by this binary. To simplify the problem, the
current code do not resolve the features, and accept the one resolved by
cargo as valid. Most of the time this will be OK, maybe will include
some extra features needed for other binaries.

5.- Print the 'bundled()' data.

This code will only be executed in the directory 'vendor' is present in
the top-most directory found on step 3.
2021-10-12 15:10:33 +02:00
Alberto Planas
3487db7b75 metadata: add simple version evaluator 2021-10-12 15:10:33 +02:00
Alberto Planas
31bfe95446 inspector: find Cargo.toml from binary 2021-10-12 15:10:33 +02:00
Alberto Planas
b746a2ec5c metadata: support virtual manifest 2021-10-12 15:10:33 +02:00
afbee03f26 Suppress tracebacks for "expected" errors
We shouldn't crash when network communication fails, or when a subprocess fails.
The traceback is unsightly, and causes bug reports to be files. Let's just print
the error.

$ PYTHONPATH=$HOME/python/rust2rpm python -m rust2rpm ./asdfasdf.asdf
error: the manifest-path must be a path to a Cargo.toml file
Subcommand failed with code 101: cargo read-manifest --manifest-path=./asdfasdf.asdf
$ PYTHONPATH=$HOME/python/rust2rpm python -m rust2rpm asdfasdf
Failed to download metadata: 404 Client Error: Not Found for url: https://crates.io/api/v1/crates/asdfasdf/versions

Fixes #145.

(This does the relatively easy thing of printing the original message. In
principle we could try to figure out what the exact error was and print uniform
error messages. But that'd be quite a lot of work, and fairly brittle, because
we'd need to cover all possible errors. So let's do this thing which should
be good enough in 95% of cases.)
2021-10-12 12:47:57 +00:00
Zbigniew Jędrzejewski-Szmek
057dd98350 Merge #149 Adding some tests 2021-10-11 17:50:21 +00:00
Daniel Gonçalves
bc8357dc3c Add python 3.8 and 3.9 to tox.ini 2021-10-10 15:33:48 +02:00
Daniel Gonçalves
6fe36bfafd Add hyphens to underscores tests 2021-10-10 14:30:07 +02:00
Davide Cavalca
bc04fe22cf Optionally check if a package already exists in Fedora 2021-10-06 09:14:54 -07:00
Zbigniew Jędrzejewski-Szmek
f0de38ad72 Merge #147 Fix bug introduced by recent patches and clean up the code a bit 2021-09-30 08:36:41 +00:00
a2b42c056c Rector explicit indexing into a tuple unpacking 2021-09-29 22:32:50 +02:00
bdaa087c17 Refactor the code to generate file lists
The code was very hard to read because it was doing explicit lists
concatenations. Let's make the code more python by using 'yield' on
the interesting items, and hide the creation of the list in a decorator.
2021-09-29 22:32:50 +02:00
Daniel Gonçalves
2523fd3c14 rust2rpm: replace hyphens by underscores in version
- fix issue#124
2021-09-28 17:53:24 +00:00
Daniel Gonçalves
0089888cd7 rust2rpm: replace hyphens by underscores in version
- fix issue#124
2021-09-28 19:06:29 +02:00
120d609f58 Fix crash when path to a toml file is given
Fixes a programming error introduced in b284d61ee7, the
variables were not defined.
2021-09-28 13:34:19 +02:00
Zbigniew Jędrzejewski-Szmek
676ad35a1b Merge #137 Files autodetection fixes 2021-09-28 10:42:13 +00:00
7e0afd5da2 fedora: check existing spec file for rpmautospec
If we have a new file: assume yes. If there was an old file, convert
only when the old file had %autochangelog.

The regexp for %autochangelog is taken from
https://pagure.io/fedora-infra/rpmautospec/pull-request/219.
2021-09-20 12:47:37 +02:00
31afa28c74 Simplify assignment
No functional change.
2021-09-20 12:46:13 +02:00
22804aeab0 fedora: use rpmautospec by default
rpmautspec has some shortcomings (e.g. lack of support for multi-line
changelog entries), but those shortcomings are not very important for
rust packages. Let's just use rpmautospec by default for convenience.
2021-09-17 09:40:05 +02:00
Robert-André Mauchin
b284d61ee7 Files autodetection fixes
Do not include subdirectories as %doc. Fix #136.
Sort license and doc files alphabetically. Fix #135.
Only include doc files from the root directory. Fix #134.
2021-07-14 19:57:56 +02:00
f0b940205c
buildsys: release++ 2021-07-12 16:39:43 +02:00
d7b59b3757
rust2rpm: use changelog timestamp without time and timezone on Fedora 2021-07-12 15:32:15 +02:00
f52cbe0232
rust2rpm: add support for using rpmautospec (autorelease + autochangelog) 2021-07-12 15:23:43 +02:00
Robert-André Mauchin
0a91ff0c03 Quick and dirty license and doc files detection
Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>
2021-03-29 17:28:12 +02:00
Igor Raits
d231e5d433
fedora-helper: Use f35 as a base for license generation
Signed-off-by: Igor Raits <igor.raits@gmail.com>
2021-03-07 21:40:31 +01:00
5ec3227115 licensing: "Python-2.0" is fine in Fedora
The license is listed on fedora's list of "Good" licenses:
https://fedoraproject.org/wiki/Licensing:Main#Good_Licenses.
It is called "Python" and the notes link to
https://docs.python.org/2/license.html.

https://spdx.org/licenses/Python-2.0.html provides the exact same text
as https://docs.python.org/2/license.html. Thus SPDX's "Python-2.0" is
the same as our "Python".

Fixes #121.
2021-02-12 05:11:52 +00:00
ff4c8a62a0 licensing: convert csv to unix eols
The file was originally like that, but the encodings
have become inconsistent through edits anyway. Let's just
change to a normal encoding.
2021-02-12 05:11:52 +00:00
Jan Staněk
035e458f0a
Parse features with + in their name
If a crate has a feature with `+` in it's name,
the `%__cargo_feature_from_name` macro fails to correctly parse it.
For example, the `cxxbridge-flags` crate declares (among others)
the `c++20` feature; that is currently parsed as follows:

```lua
> string.match("cxxbridge-flags+c++20-devel", "^.+%+(.+)-devel$")
20
```

The adjusted regex matches the *first* `+` as feature name separator:

```lua
> string.match("cxxbridge-flags+c++20-devel", "^[^+]+%+(.+)-devel$")
c++20
```
2021-02-01 13:56:37 +01:00
Igor Raits
1a28095971
buildsys: release++
Signed-off-by: Igor Raits <igor.raits@gmail.com>
2020-12-26 12:50:28 +01:00
Igor Raits
94dcd7b71e rust2rpm: Return back printing BuildRequires in %generate_buildrequires
This reverts commit 8e103f6aaf (partially).

Signed-off-by: Igor Raits <igor.raits@gmail.com>
2020-12-26 12:49:15 +01:00
857192c0dd
buildsys: release++ 2020-11-13 13:55:06 +01:00
8e103f6aaf
rust2rpm: allow removing unwanted features
Also, don't "echo" BuildRequires, this is very weird.
2020-11-13 11:04:27 +01:00
44eed8233c
rust2rpm: set User-Agent header to work around new crates.io limits 2020-11-03 18:52:20 +01:00
Javier Martinez Canillas
a0b2e3c799
licensing: Add LGPL-2.1-or-later short identifier as a LGPLv2+ variant
The SPDX license short identifier for "GNU Lesser General Public License
v2.1 or later" is LGPL-2.1-or-later [0]. Add a SPDX to Fedora mapping.

[0]: https://spdx.org/licenses/LGPL-2.1-or-later.html
2020-10-05 12:17:36 +02:00
629bba09f1 Add EUPL-1.2 to license list
https://spdx.org/licenses/EUPL-1.2.html

Discussed in https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/LZQ4SRN6L5JWEDKL23K4CXDG7TJWFTLF/.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2020-08-19 15:21:00 +02:00
Igor Raits
a8c7f5c197
fedora-helper: Rawhide is now f34
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-08-18 15:05:21 +02:00
Andreas Schwab
8dcf851319 Add riscv64 to %rust_arches
Signed-off-by: Andreas Schwab <schwab@suse.de>
2020-08-13 21:24:06 +02:00
Igor Raits
f74d7a19ae
fedora-helper: Use repo_local for local RPMs
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
2020-06-19 06:44:13 +02:00
Igor Raits
b09a48a0c1
fedora-helper: Fixup comment
Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-30 18:58:12 +02:00
Igor Raits
8fee5adf47
fedora-helper: Do not fail if unlink() fails
Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-30 18:43:56 +02:00
Igor Raits
979ccdb601
fedora-helper: Do not create CACHEDIR twice
Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-30 18:40:40 +02:00
Igor Raits
fdf954cd36
fedora-helper: Clarify how to generate binary license with dynamic BuildRequires
Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-30 18:39:58 +02:00
Igor Raits
d1ee7ed95c
Add tool that helps with maintenance in Fedora
Most likely there are some missing checks for None and the program may
segfault, but this can be fixed in future.

Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-30 18:32:28 +02:00
Michel Alexandre Salim
850b1ab5a2 Add mapping for LGPL-3.0-or-later to LGPLv3+
see https://spdx.org/licenses/
2020-05-22 17:09:56 -07:00
Igor Raits
ca9fc7e466
buildsys: release++
Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-22 15:54:31 +02:00
Thomas Jarosch
90d0e85da2
Fix up Cargo.toml.orig error message that started to appear with Rust 1.43.0
+ /usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 /opt/rust/bin/cargo package -l
+ grep -w -v Cargo.lock
+ xargs -d '\n' /bin/cp --parents -a -t /user/rpmbuild/BUILDROOT/rust-term_size-0.3.0-1.i2n.x86_64/datastore/dev/rust/cargo/registry/term_size-0.3.0
warning: No (git) VCS found for `/datastore/rpmbuild/BUILD/term_size-0.3.0`
/bin/cp: cannot stat 'Cargo.toml.orig': No such file or directory

Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-02 19:12:54 +02:00