Commit graph

39 commits

Author SHA1 Message Date
Igor Gnatenko
83ea3796cd
trivial: use f-strings everywhere
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-11-03 21:45:04 +01:00
Igor Gnatenko
197150ee2e
add support for feeding user configuration
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-11-03 21:45:04 +01:00
Igor Gnatenko
2cac5e5ad5
split features into subpackages
References: https://discussion.fedoraproject.org/t/rfc-new-crates-packaging-design-features-have-their-own-subpackages/563?u=ignatenkobrain
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-11-03 21:45:04 +01:00
5a1cde5b8d Throw an error if -s is used without a crate
In the future we might want to be smarter and find the crate, but let's at least
not ignore the option completely.
2018-09-24 11:09:52 +02:00
2f12c83d14 Remove half-downloaded crate on ^C
Subsequent invocations would fail with an error about a corrupted file.
We don't have support for resuming a failed download, so let's remove the
partial download results.
2018-09-24 11:09:52 +02:00
Igor Gnatenko
2050880140
do better for renamed crates
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-09-11 00:35:46 +02:00
Igor Gnatenko
0dc9fc182e
name spec/patch_file by real crate name
When renaming using patch file, we really want to change file names too.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-09-10 23:37:40 +02:00
7f2885fbfd Add rust2rpm --show-license-map
This is helpful when debugging the list.
2018-08-16 16:16:02 +02:00
73998d6adc Translate SPDX licenses to Fedora license tags, warn about "/"
"/" is deprecated everywhere, so warn about that.
Translation from SPDX is only used for fedora or epel targets.

The Fedora license list coalesces various license variants that have different
SPDX license tags into a single license tag. Most notably, this is done for the
39 BSD variants and 18 MIT variants on the Fedora good licenses list. When a
spdx→fedora mapping exists, it should always be unambiguous, because SPDX
considers any change in the license text to be a unique license, and Fedora is
more permissive in that regard.

To make a review of the translation easy, debug info is output to stdout, and
comments are inserted into the spec when some translation is required or when
there are problems with the upstream licensing.

The license list is pulled from the spdx project:
$ curl 'https://docs.google.com/spreadsheets/d/1LUJuzGKC5K2yYuAg8S-2VYbS2dmg_4IlFdpqj7n9Ghg/export?format=csv&id=1LUJuzGKC5K2yYuAg8S-2VYbS2dmg_4IlFdpqj7n9Ghg&gid=138634715' > rust2rpm/spdx_to_fedora.csv

v2:
- apply "/" replacement always

v3:
- print to stderr
- use csv.DictReader
- filter out empty license lines
2018-08-16 16:16:02 +02:00
4f234e09ca
add option to copy crate to current working directory
This is needed to support the rust2rpm OBS source service.

Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/52

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-08-15 19:57:38 +02:00
Luca Bruno
2c1e19f4eb
main: create intermediate directories for cachedir
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/50
Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/56
2018-08-15 18:48:22 +02:00
Igor Gnatenko
1de3953e88
trivial: replace single quotes by double quotes
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-08-14 08:59:21 +02:00
3637450520 Do not clobber real files when creating a patch
When a file unpacked from a crate is edited, it is OK to edit it
directly. But when editing something that was already there, we should
make a temporary copy. Let's do this copy next to the file being
edited, so it's easy for the user to open related files.
2018-08-13 20:42:37 +02:00
2233404f98 Allow generating the spec file from rust project checkout
This adds the possibility to generate the spec file from a rust project
checkout, by specifying either the toml file or just the directory name, without
having a crate at all. This is nice when developing local projects and tweaking
the metadata. The expected way to use this is 'rust2rpm .../project/', look at
the generated spec file, do fixes to source, regenerate spec file, etc.

$ rust2rpm -t fedora --stdout .
(when testing)
or
$ rust2rpm -t fedora /path/to/project
(in the dist-git directory)

Only args that contain "/" are considered local arguments. An special exception
is made for "." and "..", since that's likely to be a common use case and cannot
be mistaken for a remote crate name.

When --patch is used, the filename is changed from name-version-fix-metadata.diff
to name-fix-metadata.diff. This seems more useful, because after the crate
version is updated, the patch file would either stay the same or would just need
to be rebased, and it is not tied to the crate version.
2018-08-13 20:36:30 +02:00
Anders Blomdell
b5647abe0f First shot at handling local crates 2018-08-13 20:14:01 +02:00
Igor Gnatenko
045dd9358e read os-release using configparser
It is much safer.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-08 20:08:38 +01:00
0cd2ec0298 detect default distribution target based on os-release(5)
Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/46
Signed-off-by: Neal Gompa <ngompa13@gmail.com>
2018-01-08 20:08:16 +01:00
3feda71385 add support for Mageia and (open)SUSE
The crate packaging spec file template has been split out into its own file,
and various distro specific modifications to the spec are incorporated as
include files that are conditionally applied based on the target.

Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/46
Signed-off-by: Neal Gompa <ngompa13@gmail.com>
2018-01-08 20:08:04 +01:00
Igor Gnatenko
09a434b55a make 'rlib' first-class citizen
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/47
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-08 19:09:54 +01:00
Igor Gnatenko
c848eae92d generate spec using latest non-yanked version
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-11-13 21:36:18 +01:00
Igor Gnatenko
9e0a872ece inspector: inject cargo dependency in runtime
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/42
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-10-21 09:54:36 +02:00
Igor Gnatenko
8757161c11 use rust-packaging for BuildRequires
That way we don't need to pull any python/whatever stuff from rust itself.

Closes: https://pagure.io/fedora-rust/rust2rpm/issue/30
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-05-17 12:45:48 +02:00
Igor Gnatenko
1e87d552eb always name main package with rust-
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-03-11 13:21:12 +01:00
Igor Gnatenko
d3433da3a8 add empty line at EOF in spec
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-03-06 16:51:31 +01:00
Igor Gnatenko
bfae101f92 generate changelog automagically
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-03-06 16:48:19 +01:00
Igor Gnatenko
6caf4e5785 remove unused imports
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-03-06 16:34:45 +01:00
Igor Gnatenko
034ac98d65 parse target before templating
Even we don't have epel support at this point, it should be same
as fedora. It doesn't make any sense to rely on target names in
templating.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-26 23:43:49 +01:00
Igor Gnatenko
548d835441 inspector: print buildrequires into requires as well
Those are not completely build-time since we ship source code. We
do need those dependencies to do builds afterwards.

Also use private members to not copy lists.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-26 23:24:25 +01:00
Igor Gnatenko
f487983d6c use rich dependencies to fullfill requirements
Imagine, that:
* A requires 0.6.0 <= X < 0.7.0
* B requires 0.9.0 <= X < 0.10.0
* C requires A and B

If we use Requires + Conflicts, then we just can't build or install
C, because sub-dependencies are conflicting between each other.

Proper syntax is: (X >= 0.6.0 with X < 0.7.0)

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-25 10:02:05 +01:00
Igor Gnatenko
a6d8213e64 include license file into main package as well
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-19 19:55:19 +01:00
Igor Gnatenko
3b87345449 trivial: remove unused variables/imports
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-19 19:28:13 +01:00
Igor Gnatenko
e834debc6a add support for proc-macro kind
Closes: https://pagure.io/fedora-rust/rust2rpm/issue/19
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 19:53:08 +01:00
Igor Gnatenko
69c7ba1d28 save to real files by default instead of stdout
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 01:54:02 +01:00
Igor Gnatenko
7fb08b9515 prepare all metadata in python rather than in jinja
We need to know things like name of package in order to create
properly named spec file.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 01:45:35 +01:00
Igor Gnatenko
98b6cc73d5 respect VISUAL/EDITOR variables and fallback to vi
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 00:42:27 +01:00
Igor Gnatenko
ce5a8204d4 add support for initial patching of Cargo.toml
Closes: https://pagure.io/fedora-rust/rust2rpm/issue/20
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 00:42:27 +01:00
Igor Gnatenko
e880b5031d summary is like description, but not multiline
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 00:11:04 +01:00
Igor Gnatenko
1282937913 metadata: parse description
New cargo exposes description, so we can even generate summary out
of it.

We will need to do some pre-processing in future, but good enough for
the beginning.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-14 18:43:51 +01:00
Igor Gnatenko
2fbb50e1dc distribute rust2rpm in PyPI via setuptools
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-12 11:35:45 +01:00
Renamed from rust2rpm.py (Browse further)