From da464d7c8e0b568dc95798ec28d5cc0bbb503a14 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Apr 10 2024 18:01:16 +0000 Subject: Add option -a to include BuilArch: noarch Signed-off-by: Cristian Le --- diff --git a/macros.python-srpm b/macros.python-srpm index 278571f..353219a 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -225,11 +225,12 @@ end } -%python_extras_subpkg(n:i:f:F) %{expand:%{lua: +%python_extras_subpkg(n:i:f:Fa) %{expand:%{lua: local option_n = '-n (name of the base package)' local option_i = '-i (buildroot path to metadata)' local option_f = '-f (builddir path to a filelist)' local option_F = '-F (skip %%files section)' + local option_a = '-a (insert BuildArch: noarch)' local value_n = rpm.expand('%{-n*}') local value_i = rpm.expand('%{-i*}') local value_f = rpm.expand('%{-f*}') @@ -254,6 +255,10 @@ rpm.expand('%{error:%%%0 requires at least one argument with "extras" name}') end local requires = 'Requires: ' .. value_n .. ' = %{?epoch:%{epoch}:}%{version}-%{release}' + local noarch = '' + if opt.a then + noarch = 'BuildArch: noarch' + end for extras in args:gmatch('[^%s,]+') do local rpmname = value_n .. '+' .. extras local pkgdef = '%package -n ' .. rpmname @@ -277,7 +282,7 @@ elseif value_f ~= '' then files = '%files -n ' .. rpmname .. ' -f ' .. value_f end - for i, line in ipairs({pkgdef, summary, requires, description, files, ''}) do + for i, line in ipairs({pkgdef, summary, requires, noarch, description, files, ''}) do print(line .. '\\\n') end end diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 5d2daf2..43a38ab 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -53,7 +53,7 @@ elseif posix.stat('macros.python-srpm') then end } Version: %{__default_python3_version} -Release: 9%{?dist} +Release: 10%{?dist} BuildArch: noarch @@ -163,6 +163,9 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true %changelog +* Wed Apr 10 2024 Cristian Le - 3.12-10 +- %%python_extras_subpkg: Add option -a to include BuildArch: noarch + * Thu Mar 28 2024 Zbigniew Jędrzejewski-Szmek - 3.12-9 - Minor improvements to brp-fix-pyc-reproducibility diff --git a/tests/test_evals.py b/tests/test_evals.py index 1f953e0..79c88ff 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -545,6 +545,7 @@ def test_python_extras_subpkg_i(): %package -n python3-setuptools_scm+toml Summary: Metapackage for python3-setuptools_scm: toml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+toml This is a metapackage bringing in toml extras requires for python3-setuptools_scm. @@ -556,6 +557,7 @@ def test_python_extras_subpkg_i(): %package -n python3-setuptools_scm+yaml Summary: Metapackage for python3-setuptools_scm: yaml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+yaml This is a metapackage bringing in yaml extras requires for python3-setuptools_scm. @@ -574,6 +576,7 @@ def test_python_extras_subpkg_f(): %package -n python3-setuptools_scm+toml Summary: Metapackage for python3-setuptools_scm: toml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+toml This is a metapackage bringing in toml extras requires for python3-setuptools_scm. @@ -584,6 +587,7 @@ def test_python_extras_subpkg_f(): %package -n python3-setuptools_scm+yaml Summary: Metapackage for python3-setuptools_scm: yaml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+yaml This is a metapackage bringing in yaml extras requires for python3-setuptools_scm. @@ -601,6 +605,7 @@ def test_python_extras_subpkg_F(): %package -n python3-setuptools_scm+toml Summary: Metapackage for python3-setuptools_scm: toml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+toml This is a metapackage bringing in toml extras requires for python3-setuptools_scm. @@ -611,6 +616,7 @@ def test_python_extras_subpkg_F(): %package -n python3-setuptools_scm+yaml Summary: Metapackage for python3-setuptools_scm: yaml extras Requires: python3-setuptools_scm = 6-7 + %description -n python3-setuptools_scm+yaml This is a metapackage bringing in yaml extras requires for python3-setuptools_scm. @@ -619,6 +625,22 @@ def test_python_extras_subpkg_F(): assert lines == expected +def test_python_extras_subpkg_a(): + lines = rpm_eval('%python_extras_subpkg -n python3-setuptools_scm -a -F toml', + version='6', release='7') + expected = textwrap.dedent(f""" + %package -n python3-setuptools_scm+toml + Summary: Metapackage for python3-setuptools_scm: toml extras + Requires: python3-setuptools_scm = 6-7 + BuildArch: noarch + %description -n python3-setuptools_scm+toml + This is a metapackage bringing in toml extras requires for + python3-setuptools_scm. + It makes sure the dependencies are installed. + """).lstrip().splitlines() + assert lines == expected + + def test_python_extras_subpkg_underscores(): lines = rpm_eval('%python_extras_subpkg -n python3-webscrapbook -F adhoc_ssl', version='0.33.3', release='1.fc33') @@ -626,6 +648,7 @@ def test_python_extras_subpkg_underscores(): %package -n python3-webscrapbook+adhoc_ssl Summary: Metapackage for python3-webscrapbook: adhoc_ssl extras Requires: python3-webscrapbook = 0.33.3-1.fc33 + %description -n python3-webscrapbook+adhoc_ssl This is a metapackage bringing in adhoc_ssl extras requires for python3-webscrapbook. @@ -649,6 +672,7 @@ def test_python_extras_subpkg_arg_separators(sep): %package -n python3-hypothesis+cli Summary: Metapackage for python3-hypothesis: cli extras Requires: python3-hypothesis = 6.6.0-1.fc35 + %description -n python3-hypothesis+cli This is a metapackage bringing in cli extras requires for python3-hypothesis. It makes sure the dependencies are installed. @@ -658,6 +682,7 @@ def test_python_extras_subpkg_arg_separators(sep): %package -n python3-hypothesis+ghostwriter Summary: Metapackage for python3-hypothesis: ghostwriter extras Requires: python3-hypothesis = 6.6.0-1.fc35 + %description -n python3-hypothesis+ghostwriter This is a metapackage bringing in ghostwriter extras requires for python3-hypothesis. @@ -668,6 +693,7 @@ def test_python_extras_subpkg_arg_separators(sep): %package -n python3-hypothesis+pytz Summary: Metapackage for python3-hypothesis: pytz extras Requires: python3-hypothesis = 6.6.0-1.fc35 + %description -n python3-hypothesis+pytz This is a metapackage bringing in pytz extras requires for python3-hypothesis. It makes sure the dependencies are installed.