diff --git a/rust2rpm/generator.py b/rust2rpm/generator.py index 8369fe9..a70b590 100644 --- a/rust2rpm/generator.py +++ b/rust2rpm/generator.py @@ -209,9 +209,10 @@ def spec_render_crate( "rpm_license_files": license_files, "rpm_doc_files": doc_files, # Parameters that control generation of subpackages - "rpm_binary_package": is_bin or is_cdylib, - "rpm_binary_names": binaries if is_bin else [], + "rpm_binary_package": is_bin, + "rpm_cdylib_package": is_cdylib, "rpm_library_package": is_lib, + "rpm_binary_names": binaries, "crate_features": features, # Parameters for crate metadata "crate_name": package.name, @@ -272,6 +273,8 @@ def spec_render_workspace( binaries = [*metadata.get_binaries()] binaries.sort() + is_cdylib = metadata.is_cdylib() + main_package = guess_main_package(metadata) rpm_version = Version.parse(main_package.version).to_rpm() rpm_description = main_package.get_description() @@ -341,6 +344,7 @@ def spec_render_workspace( "rpm_license_files": license_files, "rpm_doc_files": doc_files, "rpm_binary_names": binaries, + "rpm_cdylib_package": is_cdylib, # Parameters derived from rust2rpm.conf "conf_buildrequires": conf_buildrequires, "conf_test_requires": conf_test_requires, diff --git a/rust2rpm/templates/README.md b/rust2rpm/templates/README.md index 929d8e2..2401cda 100644 --- a/rust2rpm/templates/README.md +++ b/rust2rpm/templates/README.md @@ -34,8 +34,9 @@ | parameter name | type | value | | --------------------- | --------------------- | --------------------------------------------------------------------------- | | `rpm_binary_package` | `bool` | `True` if package ships any binaries, `False` for source-only packages | -| `rpm_binary_names` | `list[str]` | list of the names of executables which are built from the crate | +| `rpm_cdylib_package` | `bool` | `True` if package ships any shared libraries (`cdylib` targets) | | `rpm_library_package` | `bool` | `True` if package has a library component, `False` for binary-only packages | +| `rpm_binary_names` | `list[str]` | list of the names of executables which are built from the crate | | `crate_features` | `list[Optional[str]]` | list of names of features for which sub-packages are generated | ### Parameters for crate metadata @@ -101,6 +102,7 @@ | `rpm_license_files` | `list[str]` | list of the license files which were detected in crate sources | | `rpm_doc_files` | `list[str]` | list of the documentation files which were detected in crate sources | | `rpm_binary_names` | `list[str]` | list of the names of executables which are built from the project | +| `rpm_cdylib_package` | `bool` | `True` if package ships any shared libraries (`cdylib` targets) | ### Parameters derived from rust2rpm.conf diff --git a/rust2rpm/templates/crate.spec b/rust2rpm/templates/crate.spec index 37fdeae..445464a 100644 --- a/rust2rpm/templates/crate.spec +++ b/rust2rpm/templates/crate.spec @@ -1,7 +1,7 @@ {% include rust2rpm_target ~ "-header.spec.inc" ignore missing %} # Generated by rust2rpm {{ rust2rpm_version }} %bcond_without check -{% if not rpm_binary_package %} +{% if not (rpm_binary_package or rpm_cdylib_package) %} %global debug_package %{nil} {% endif %} @@ -82,7 +82,7 @@ BuildRequires: {{ req }} %description %{_description} -{% if rpm_binary_package %} +{% if rpm_binary_package or rpm_cdylib_package %} %package -n %{crate} Summary: %{summary} {% if rpm_group is defined %} @@ -191,10 +191,13 @@ echo {{ "%r" | format(req) }} %cargo_build{{ cargo_args }} %install -{% if not (not rpm_library_package and rpm_binary_package and binaries|length == 0) %} +{% if rpm_cdylib_package and (rpm_library_package or rpm_binary_package) %} %cargo_install{{ cargo_args }} +# FIXME: install shared library +{% elif rpm_cdylib_package %} +# FIXME: install shared library {% else %} -# FIXME +%cargo_install{{ cargo_args }} {% endif %} %if %{with check} diff --git a/rust2rpm/templates/workspace.spec b/rust2rpm/templates/workspace.spec index 821b1cf..f52a15a 100644 --- a/rust2rpm/templates/workspace.spec +++ b/rust2rpm/templates/workspace.spec @@ -86,10 +86,13 @@ echo {{ "%r" | format(req) }} %cargo_build{{ cargo_args }} %install -{% if binaries|length == 0 %} +{% if rpm_cdylib_package and rpm_binary_names|length >= 1 %} %cargo_install{{ cargo_args }} +# FIXME: install shared library +{% elif rpm_cdylib_package %} +# FIXME: install shared library {% else %} -# FIXME +%cargo_install{{ cargo_args }} {% endif %} %if %{with check}