diff --git a/CHANGELOG.md b/CHANGELOG.md index 1269a65..210dae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +Unreleased +========== + +Added: + +- Support for generating spec files that target distributions with older + versions of RPM was implemented. Currently, the only difference between + "normal" and "legacy" mode is whether the `SourceLicense` tag is present in + generated spec files. Support for this tag was added in RPM 4.18, but RHEL 9 + is currently on RPM 4.16. In "legacy" mode (i.e. when targeting EPEL 9), the + `SourceLicense` tag in generated spec files is replaced with a comment. To + enable "legacy" mode, pass the new `--legacy` flag on the CLI. + Version 26.0.0 ============== diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 9842475..eaf2a83 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -199,6 +199,7 @@ def main(): main_package=main_package, upstream_version=version, target=args.target, + legacy=args.legacy, rpm_name=rpm_name, license_files=license_files, doc_files=doc_files, @@ -231,6 +232,7 @@ def main(): metadata=metadata, upstream_version=version, target=args.target, + legacy=args.legacy, rpm_name=rpm_name, patch_file_automatic=patch_files[0], patch_file_manual=patch_files[1], @@ -270,6 +272,7 @@ def main(): metadata=metadata, upstream_version=version, target=args.target, + legacy=args.legacy, rpm_name=rpm_name, compat=args.compat, patch_file_automatic=patch_files[0], diff --git a/rust2rpm/cli.py b/rust2rpm/cli.py index f3becd4..e6e1cb0 100644 --- a/rust2rpm/cli.py +++ b/rust2rpm/cli.py @@ -102,6 +102,12 @@ def get_parser() -> argparse.ArgumentParser: action="store_true", help="Create a vendor tarball and write a spec for building with vendored dependencies", ) + parser.add_argument( + "-l", + "--legacy", + action="store_true", + help="Generate a spec file that is compatible with older versions of RPM", + ) parser.add_argument( "crate", help="crates.io name\n" "path/to/local.crate\n" "path/to/project/", diff --git a/rust2rpm/generator.py b/rust2rpm/generator.py index 3feddcb..d281f4f 100644 --- a/rust2rpm/generator.py +++ b/rust2rpm/generator.py @@ -178,6 +178,7 @@ def spec_render_crate( metadata: Metadata, upstream_version: str, target: str, + legacy: bool, rpm_name: str, compat: bool, patch_file_automatic: Optional[str], @@ -331,6 +332,7 @@ def spec_render_crate( # Parameters specific to rust2rpm "rust2rpm_version": generator_version, "rust2rpm_target": target, + "rust2rpm_legacy": legacy, "rust_packaging_dep": rust_packaging_dep, # Parameters for RPM package metadata "rpm_name": rpm_name, @@ -424,6 +426,7 @@ def spec_render_project( metadata: Metadata, upstream_version: str, target: str, + legacy: bool, rpm_name: str, patch_file_automatic: Optional[str], patch_file_manual: Optional[str], @@ -535,6 +538,7 @@ def spec_render_project( # Parameters specific to rust2rpm "rust2rpm_version": generator_version, "rust2rpm_target": target, + "rust2rpm_legacy": legacy, "rust_packaging_dep": rust_packaging_dep, # Parameters for RPM package metadata "rpm_name": rpm_name, @@ -621,6 +625,7 @@ def spec_render_workspace( main_package: Package, upstream_version: str, target: str, + legacy: bool, rpm_name: str, license_files: list[str], doc_files: list[str], @@ -728,6 +733,7 @@ def spec_render_workspace( # Parameters specific to rust2rpm "rust2rpm_version": generator_version, "rust2rpm_target": target, + "rust2rpm_legacy": legacy, "rust_packaging_dep": rust_packaging_dep, # Parameters for RPM package metadata "rpm_name": rpm_name, diff --git a/rust2rpm/templates/project.spec b/rust2rpm/templates/project.spec index b619401..7e96d07 100644 --- a/rust2rpm/templates/project.spec +++ b/rust2rpm/templates/project.spec @@ -33,7 +33,11 @@ Group: {{ rpm_group }} {% if crate_license != rpm_license %} # Upstream license specification: {{ crate_license|default("(missing)") }} {% endif %} +{% if rust2rpm_legacy %} +# Source License: {{ rpm_license|default("# FIXME") }} +{% else %} SourceLicense: {{ rpm_license|default("# FIXME") }} +{% endif %} # FIXME: paste output of %%cargo_license_summary here License: # FIXME # LICENSE.dependencies contains a full license breakdown diff --git a/rust2rpm/templates/workspace.spec b/rust2rpm/templates/workspace.spec index 94205fd..757f8b8 100644 --- a/rust2rpm/templates/workspace.spec +++ b/rust2rpm/templates/workspace.spec @@ -22,7 +22,11 @@ Summary: {{ rpm_summary }} Group: {{ rpm_group }} {% endif %} +{% if rust2rpm_legacy %} +# Source License: {{ rpm_license|default("# FIXME") }} +{% else %} SourceLicense: {{ rpm_license|default("# FIXME") }} +{% endif %} # FIXME: paste output of %%cargo_license_summary here License: # FIXME # LICENSE.dependencies contains a full license breakdown diff --git a/rust2rpm/tests/test_generator.py b/rust2rpm/tests/test_generator.py index 66069ff..26bc1fb 100644 --- a/rust2rpm/tests/test_generator.py +++ b/rust2rpm/tests/test_generator.py @@ -54,6 +54,7 @@ def test_spec_file_render_crate(filename: str, conf: Optional[str], target: str) rendered = spec_render_crate( target=target, + legacy=False, upstream_version=version, metadata=metadata, rpm_name=rpm_name, @@ -108,6 +109,7 @@ def test_spec_file_render_project(filename: str, vendor_tarball: Optional[str], rendered = spec_render_project( target=target, + legacy=False, upstream_version=version, metadata=metadata, rpm_name=crate, @@ -162,6 +164,7 @@ def test_spec_file_render_workspace(filename: str, vendor_tarball: Optional[str] main_package=guess_main_package(metadata), upstream_version=version, target=target, + legacy=False, rpm_name=crate, license_files=["LIC1", "LIC2"], doc_files=["DOC1", "DOC2"],