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/versionsFixes#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.)
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.
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.
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.
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
```
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
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>
+ /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>
In cargo 1.41, `cargo install` adds a new `.crates2.json` file in the
install root for tracking version upgrades. This would be another file
that `%cargo_install` should remove afterward, but there is also a new
`--no-track` option which disables such metadata files altogether.
This update should be coordinated with the Rust toolchain update in the
distro, e.g. with rust-packaging `Requires: cargo >= 1.41`. The new
option will be rejected as an unstable option on earlier versions.
For example,
```toml
[dependencies]
open-ssl = { version="0.10", package = "openssl", optional = true }
[features]
openssl = ["actix-tls/openssl", "awc/openssl", "open-ssl"]
```
would end up previously with just +openssl subpackage with dependency on
crate(openssl). Now we create +open-ssl subpackage with dependency on
crate(openssl) and +openssl subpackage with dependencies on
crate(actix-tls/openssl), crate(awc/openssl) and +open-ssl subpackage.
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>