Commit graph

365 commits

Author SHA1 Message Date
Aleksei Bavshin
f1be3a0d4d
macros: pass CFLAGS/CXXFLAGS to the processes started by cargo
This is mainly targeted to the crates using `rust-cc`, where we want to
apply system-wide compiler flags when invoking the compiler. `cc`
supports CFLAGS and CXXFLAGS, but we never set those.
Defining that per project is not possible, as we have no way to inherit
any build context from a dependency package.

Possibly also affects: `bindgen`, `cxx`, any other crate that invokes
the C/C++ compiler and passes the CFLAGSS
2021-12-05 22:20:52 -08:00
aa6282874f Version 20 2021-11-29 22:27:58 +01:00
6d4fba2249 Fix insertion of "the"
We want the second "the" in both cases.
Fixup for f5b8160f18.
2021-11-29 14:44:15 +01:00
e27e68bda6 Fix handling of rpmautospec detection
Fixup for 7e0afd5da2: the condition was
updated in one place, but not in the other we used the original
args.rpmautospec value.
2021-11-29 14:33:54 +01:00
Zbigniew Jędrzejewski-Szmek
d93c49914c Merge #160 Fix insertion of comments, parsing of os-release, and bump status to "production" 2021-11-29 13:24:25 +00:00
Igor Raits
f5b8160f18
spec: Fixup missing articles in "the generated description"
Fixes: c5eda336f0
Signed-off-by: Igor Raits <igor.raits@gmail.com>
2021-11-28 16:35:45 +01:00
df09a9d313 setup: bump development status to "production"
We have been using this in production for years… No need to
be coy.
2021-11-28 12:50:37 +01:00
02a76c3372 Import the os-release parser from the man page
Fixes https://pagure.io/fedora-rust/rust2rpm/issue/159.

The code in the man page is licensed as CC-0, so it's fine to just
copy it here. (And I wrote it, so it would be fine anyway ;)).
2021-11-28 12:50:37 +01:00
1100c60d7b Fix insertion of newlines in license conversion comments
We would end up with not-enough/one-too-many in various cases.
2021-11-28 12:50:19 +01:00
1482f79e28 Drop __cargo_skip_build logic
It looks like this logic was only used for module builds, which is not
how Rust packages have been built for a few Fedora releases now.

Fixes #142.
2021-11-25 08:49:17 +00:00
Igor Raits
ea59cb27d1 Always require upper-bound dependency with ~ sign
Proper fix is quite complex and given we do not package pre-release
versions very often (and esp. not multiple versions of them), this is
good enough (not nice though).

Signed-off-by: Igor Raits <igor.raits@gmail.com>

Fixes https://pagure.io/fedora-rust/rust2rpm/issue/70.
2021-11-22 13:46:56 +01:00
af4e3714eb Version 19
This adds a NEWS file with retroactive entries. We used to add this
information in tag descriptions, but a NEWS file is much easier to
access for users.
2021-11-22 13:25:47 +01:00
d7b369845d setup.py: we support Python 3.9 and 3.10 too 2021-11-22 12:46:30 +01:00
0da628dc61 licensing: add LGPL-2.0-or-later
Fedora treats LGPL-2.0 the same as LGPL-2.1, so the mapping
should be identical to 2.1.

Fixes #156.
2021-11-22 12:22:45 +01:00
c5eda336f0 spec: add missing articles in the generated description
Also wrap it to ~80 columns.
2021-11-22 12:13:54 +01:00
7b853072f5 cargo-inspector: don't print the traceback if a file is missing
$ cargo-inspector -n zola
Traceback (most recent call last):
  File "/usr/bin/cargo-inspector", line 33, in <module>
    sys.exit(load_entry_point('rust2rpm==18', 'console_scripts', 'cargo-inspector')())
  File "/home/zbyszek/python/rust2rpm/rust2rpm/inspector.py", line 78, in main
    files = [_cargo_toml(args.path, f) for f in files]
  File "/home/zbyszek/python/rust2rpm/rust2rpm/inspector.py", line 78, in <listcomp>
    files = [_cargo_toml(args.path, f) for f in files]
  File "/home/zbyszek/python/rust2rpm/rust2rpm/inspector.py", line 50, in _cargo_toml
    raise FileNotFoundError(f'Cargo.toml not found for binary {binary_or_cargo_toml}')
FileNotFoundError: Cargo.toml not found for binary zola

becomes

$ cargo-inspector -n zola
FileNotFoundError: Cargo.toml not found for binary zola
2021-11-22 11:07:50 +00:00
aa849b8aa5 Supress tracebacks for "expected" exceptions in more places
afbee03f26 tried to suppress tracebacks, but I was testing it by calling
'PYTHONPATH=… python -m rust2rpm' and completely missed the fact that the
setuptools entrypoint wrapper calls main() directly and is not covered by
this.

Also, the same should be done for cargo-inspector.
2021-11-22 11:07:50 +00:00
Michel Alexandre Salim
1b5ad32178 Fix CDDL mapping
Fedora's Software Good Licenses List:
https://fedoraproject.org/wiki/Licensing:Main#Good_Licenses

has had CDDL-1.0 and CDDL-1.1 distinguished from each other since 2017.

Update our mapping - and remove the incorrect text that CDDL 1.1 might
not be acceptable.

Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
2021-11-16 13:40:33 -08:00
Davide Cavalca
21d77319e1 Detect more license files 2021-11-10 21:27:25 -08:00
Daniel Gonçalves
07f24fc13c Add python 3.10 to tox.ini 2021-10-14 18:41:02 +02:00
Alberto Planas
31a778c4f2 rust2rpm: return single metadata
When generating the spec file, takes care of asserting that there is a
single metadata.  If not, write a warning.
2021-10-13 14:25:21 +02:00
Alberto Planas
1883197d9c Fixes from the last review 2021-10-12 15:10:33 +02:00
Alberto Planas
981aeed93d Remove duplicated output at the end 2021-10-12 15:10:33 +02:00
Alberto Planas
9269105f5b inspector: dont collect all workspaces by default 2021-10-12 15:10:33 +02:00
Alberto Planas
1c2247ea93 metadata: virtual manifest dont have JSON 2021-10-12 15:10:33 +02:00
Alberto Planas
653037692f metadata: fix __repr__ for None feature 2021-10-12 15:10:33 +02:00
Alberto Planas
9bcfa374ec Document _cargo_toml 2021-10-12 15:10:33 +02:00
Alberto Planas
b8c292f0aa Drop _go_to_top_cargo_toml 2021-10-12 15:10:33 +02:00
Alberto Planas
7b93f1a01a metadata: parse read-manifest directly 2021-10-12 15:10:33 +02:00
Alberto Planas
f1e1cd58a6 inspector: update path flag help 2021-10-12 15:10:33 +02:00
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