diff --git a/0000-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch b/0000-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e26a9c899fee27cb4fadcbd3f38bd285f7804b1 --- /dev/null +++ b/0000-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch @@ -0,0 +1,40 @@ +From 1b14d44d5705e2c87bc52d56f9ea184994669da1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 22 Feb 2022 11:41:46 +0100 +Subject: [PATCH 2/2] Allow easy overriding of the + opt-level/debuginfo/codegen-units flags + +Some crates use debuginfo=0 or debuginfo=1 to reduce memory pressure during +builds. This should make this easy. + +Fixes https://pagure.io/fedora-rust/rust2rpm/issue/181 +--- + data/macros.rust | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/data/macros.rust b/data/macros.rust +index 3a9281849f..efa46a3212 100644 +--- a/data/macros.rust ++++ b/data/macros.rust +@@ -1,14 +1,18 @@ + %__rustc %{_bindir}/rustc + %__rustdoc %{_bindir}/rustdoc + ++%rustflags_opt_level 3 ++%rustflags_debuginfo 2 ++%rustflags_codegen_units 1 ++ + # Enable optimization, debuginfo, and link hardening. + %build_rustflags %{shrink: +- -Copt-level=3 +- -Cdebuginfo=2 ++ -Copt-level=%rustflags_opt_level ++ -Cdebuginfo=%rustflags_debuginfo ++ -Ccodegen-units=%rustflags_codegen_units + -Clink-arg=-Wl,-z,relro + -Clink-arg=-Wl,-z,now + %{?_package_note_file:-Clink-arg=-Wl,-dT,%{_package_note_file}} +- -Ccodegen-units=1 + --cap-lints=warn + } + diff --git a/0001-Fix-autodetection-of-rpmautospec.patch b/0001-Fix-autodetection-of-rpmautospec.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3c5bd08cfb7059c7bdf83bfa2010f4ca86407b2 --- /dev/null +++ b/0001-Fix-autodetection-of-rpmautospec.patch @@ -0,0 +1,31 @@ +From b9e95b4d61739f21c2f64ee3df497d93272a67af Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 28 Feb 2022 14:01:20 +0100 +Subject: [PATCH 2/3] Fix autodetection of rpmautospec + +When store_true or store_false are used, the default default changes +from None to a boolean. I didn't know about this, and I wrote the code +to assume args.rpmautospec would be None. rpmautospec detection was +effectively always disabled. +--- + rust2rpm/__main__.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py +index 0f575ad12f..13dc26a313 100644 +--- a/rust2rpm/__main__.py ++++ b/rust2rpm/__main__.py +@@ -360,8 +360,10 @@ def main(): + parser.add_argument("-s", "--store-crate", action="store_true", + help="Store crate in current directory") + parser.add_argument("-a", "--rpmautospec", action="store_true", ++ default=None, + help="Use autorelease and autochangelog features") + parser.add_argument("--no-rpmautospec", action="store_false", ++ default=None, + help="Do not use rpmautospec") + parser.add_argument("--relative-license-paths", action="store_true", + help="Put all license files in main license directory") +-- +2.35.1 + diff --git a/rust-packaging.spec b/rust-packaging.spec new file mode 100644 index 0000000000000000000000000000000000000000..eb486692a5bb95c19c900b6cbc22581e63d92792 --- /dev/null +++ b/rust-packaging.spec @@ -0,0 +1,70 @@ +%define anolis_release 1 +%global debug_package %{nil} + +Name: rust-packaging +Epoch: 1 +Version: 21 +Release: %{anolis_release}%{?dist} +Summary: RPM macros for building Rust packages + +License: MIT +URL: https://pagure.io/fedora-rust/rust2rpm +Source0: https://pagure.io/fedora-rust/rust2rpm/archive/v%{version}/rust2rpm-v%{version}.tar.gz + +Patch0: 0000-Allow-easy-overriding-of-the-opt-level-debuginfo-cod.patch +Patch1: 0001-Fix-autodetection-of-rpmautospec.patch + +Requires: gawk +Requires: python3-rust2rpm = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: rust-srpm-macros > %{version} +Requires: rust +Requires: cargo >= 1.41 + +%description +The package provides RPM macros for building Rust projects. + +%package -n python3-rust2rpm +Summary: Generate RPM spec files for Rust packages +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pytest +BuildRequires: cargo +Requires: cargo +Provides: rust2rpm = %{epoch}:%{version}-%{release} +%{?python_provide:%python_provide python3-rust2rpm} + +%description -n python3-rust2rpm +%{summary}. + +%prep +%autosetup -n rust2rpm-v%{version} -p1 + +%build +%py3_build + +%install +%py3_install +install -D -p -m 0644 -t %{buildroot}%{_rpmmacrodir} data/macros.rust data/macros.cargo +install -D -p -m 0644 -t %{buildroot}%{_fileattrsdir} data/cargo.attr + +%check +py.test-%{python3_version} -vv test.py + +%files +%license LICENSE +%{_rpmmacrodir}/macros.rust +%{_rpmmacrodir}/macros.cargo +%{_fileattrsdir}/cargo.attr + +%files -n python3-rust2rpm +%license LICENSE +%doc NEWS +%{_bindir}/rust2rpm +%{_bindir}/cargo-inspector +%{python3_sitelib}/rust2rpm-*.egg-info/ +%{python3_sitelib}/rust2rpm/ + + +%changelog +* Wed Apr 20 2022 happy_orange - 1:21-1 +- Init package from upstream diff --git a/rust2rpm-v21.tar.gz b/rust2rpm-v21.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..eb5ddf18a04fd471ef7219e22c8e0567d8c48262 Binary files /dev/null and b/rust2rpm-v21.tar.gz differ