Commit graph

382 commits

Author SHA1 Message Date
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
7117dcce81 Use underscore instead of a dash in compat suffixes
The Fedora Packaging Guidelines are clear on this:

> If the base package name ends with a digit, a single underscore (_)
> MUST be appended to the name, and the version MUST be appended to
> that, in order to avoid confusion over where the name ends and the
> version begins.
>
> If the base package name does not end with a digit, the version MUST
> be directly appended to the package name with no intervening
> separator.

Fixes #180.
2022-02-20 15:40:48 +01:00
Zbigniew Jędrzejewski-Szmek
3781ce3b33 Merge #179 Include linker flags for package note in %build_rustflags 2022-02-20 14:17:32 +00:00
e1f911661f Include linker flags for package note in %build_rustflags
%build_rustflags was used in %cargo_prep, which is executed in %prep,
when %buildsubdir is not set yet. To avoid this, insertion of flags is
moved to an environment variable that is set for %cargo_build and
%cargo_test.

The linker flag gets passed to rustc, and resulting binaries seem to have
note as expected.
2022-02-15 17:25:09 +01:00
fea18a3f0d Mark installed doc files as %doc
I'm keeping this separate becuase it's logically a seperate change.
In the -devel package, we installed the files once. I think it's nice
to mark them as %doc, so that it shows up correctly when filtered
by rpm attributes.

After a mock build with the changes here:

$ rpm -Vv -p /var/lib/mock/fedora-rawhide-x86_64/result/rust-rust-ini-devel-0.17.0-6.fc37.noarch.rpm
...
missing     /usr/share/cargo/registry/rust-ini-0.17.0
missing     /usr/share/cargo/registry/rust-ini-0.17.0/.cargo-checksum.json
missing     /usr/share/cargo/registry/rust-ini-0.17.0/Cargo.toml
missing   l /usr/share/cargo/registry/rust-ini-0.17.0/LICENSE
missing   d /usr/share/cargo/registry/rust-ini-0.17.0/README.rst
missing     /usr/share/cargo/registry/rust-ini-0.17.0/examples
missing     /usr/share/cargo/registry/rust-ini-0.17.0/examples/test.rs
missing     /usr/share/cargo/registry/rust-ini-0.17.0/rustfmt.toml
missing     /usr/share/cargo/registry/rust-ini-0.17.0/src
missing     /usr/share/cargo/registry/rust-ini-0.17.0/src/lib.rs
2022-02-14 14:09:28 +01:00
970160a316 Use license files installed by crate
Before, we'd use the same pattern for the main package (if present),
and the -devel files:
  %license LICENSE1 LICENSE2
Since the create usually also installs the license files to %create_instdir,
we end up with duplicated files in -devel.

It seems reasonable to reuse the file that is already present in
%create_instdir. Fedora packaging guidelines only say that "%license
must be used for license files", and doesn't say anything about the
location. And in fact, you can't assume any fixed location, because
packages will often use a common license directory, so the only
reliable way to list license files is to look at the %license mark.
And in our particular case, -devel files are not installed on user
systems, so we can assume that users will not manually search for
license files by browsing /usr/share/licenses/<package-name>. We can't
remove the license file from %{create_instdir}, because the crate might
be need it, for example to display the license text internally. Thus,
I think reasonable and not against the guidelines to "reuse" the license
file present under %{create_instdir}.

For the main package though, it seems better to keep the existing
location. Those packages *are* installed on end-user systems, and also
it'd be strange to suddently have one file under /usr/share/cargo/registry/.

So this patch uses absolute paths under %create_instdir for -devel,
and the relative path (effectively under /usr/share/licenses) for the
main package.

It is possible to opt-out of the new behaviour with --relative-license-paths.

Fixes #176.
2022-02-14 14:01:47 +01:00
55f64aaf80 Add warnings when no license files have been detected
Fixes #175.
2022-02-14 14:01:47 +01:00
c2a760efcd Add %crate_instdir convenience macro
Fixes #41.

The template is adjusted to use the new macro. This will only work
if the macro is defined, thus the required version of rust-packaging
is bumped.
2022-02-14 14:01:44 +01:00
Michel Alexandre Salim
9d72601698 Update AGPL, GPL, LGPL for new SPDX identifiers
- add the new -only SPDX identifiers
- note that the ones without -only are now deprecated

Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
2022-01-30 13:10:08 -08:00
Igor Raits
fbcb8d0d3e
Support wildcards in 0.x versions
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/173
Signed-off-by: Igor Raits <igor.raits@gmail.com>
2022-01-09 08:08:17 +01:00
Anders Blomdell
dc4dd1c6e0 Normalize requires for '--target plain' 2022-01-05 13:13:00 +01:00
498f0d5978 Filter out .tpl and .in and documentation file names
Those suffixes are commonly used for files that are processed during
build to produce some final version.

Fixes #169.
2021-12-11 12:52:44 +01:00
e9a84e8261 Simplify and tighten license and documentation file name matching
[\.] is the same as [.], and [-] matches the dash, no need for backclash-escaping.
Also, let's shorten the patches by using alternatives for the common parts.

Before we would match any prefix, even though the matches were clearly intended
to cover the whole file name. Let's use fullmatch to make it clear that the whole
string must be matched.
2021-12-11 12:46:27 +01:00
8e8ae0c969 Add --no-rpmautospec option
Fixes #170.
2021-12-11 12:14:01 +01:00
73f5d593c3 fedora: also check for the spec file in the existence check
Fixes https://pagure.io/fedora-rust/rust2rpm/issue/165.
the following workflow wasn't well supported by the check:

- request compat package repo
- fedpkg clone it
- try to run rust2rpm for it
- Get this message:
  Crate tiny_http0.6 is already packaged in Fedora (...)
  Re-run with --no-existence-check if you still want to convert it.
2021-12-11 11:08:35 +00:00
9e4c5fdd0f Stop including %doc in -devel packages
The documentation files are already included once in installation paths
underneath the crate directory. We need them there because the package might
use them in some way, and anyway we don't want to mess with the crate contents.
Adding them a second time under /usr/share/doc creates duplication. People
generally don't install rust-*-devel packages, and it doesn't make much sense
to provide documentation.

Fixes https://pagure.io/fedora-rust/rust2rpm/issue/164.
2021-12-11 11:07:24 +00:00
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