From 01d3f7586150fa0641c768c6c342f6a52de16ee0 Mon Sep 17 00:00:00 2001 From: desert-sailor Date: Fri, 30 May 2025 14:34:17 +0800 Subject: [PATCH] Introduce %%python_extras_subpkg --- macros.python | 50 ++++++++++++++++++++++++++++++++++++++- openEuler-rpm-config.spec | 5 +++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/macros.python b/macros.python index 59df735..7882e4e 100644 --- a/macros.python +++ b/macros.python @@ -224,7 +224,7 @@ find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $pyth # Converts Python dist name to a canonical format %py_dist_name() %{lua:\ name = rpm.expand("%{?1:%{1}}");\ - canonical = string.gsub(string.lower(name), "[^%w%.]+", "-");\ + canonical = string.gsub(string.lower(name), "[^%w%[%]]+", "-");\ print(canonical);\ } @@ -340,3 +340,51 @@ PYTHONDONTWRITEBYTECODE=1 \\ PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus} \\ %{__python3} -m tox -e py%{python3_version_nodots} --current-env %{?*} } + +%python_extras_subpkg(n:i:f:F) %{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 value_n = rpm.expand('%{-n*}') + local value_i = rpm.expand('%{-i*}') + local value_f = rpm.expand('%{-f*}') + local value_F = rpm.expand('%{-F}') + local args = rpm.expand('%{*}') + if value_n == '' then + rpm.expand('%{error:%%%0: missing option ' .. option_n .. '}') + end + if value_i == '' and value_f == '' and value_F == '' then + rpm.expand('%{error:%%%0: missing option ' .. option_i .. ' or ' .. option_f .. ' or ' .. option_F .. '}') + end + if value_i ~= '' and value_f ~= '' then + rpm.expand('%{error:%%%0: simultaneous ' .. option_i .. ' and ' .. option_f .. ' options are not possible}') + end + if value_i ~= '' and value_F ~= '' then + rpm.expand('%{error:%%%0: simultaneous ' .. option_i .. ' and ' .. option_F .. ' options are not possible}') + end + if value_f ~= '' and value_F ~= '' then + rpm.expand('%{error:%%%0: simultaneous ' .. option_f .. ' and ' .. option_F .. ' options are not possible}') + end + if args == '' then + rpm.expand('%{error:%%%0 requires at least one argument with "extras" name}') + end + local requires = 'Requires: ' .. value_n .. ' = %{?epoch:%{epoch}:}%{version}-%{release}' + for extras in args:gmatch('%w+') do + local rpmname = value_n .. '+' .. extras + local pkgdef = '%package -n ' .. rpmname + local summary = 'Summary: Metapackage for ' .. value_n .. ': ' .. extras .. ' extras' + local description = '%description -n ' .. rpmname .. '\\\n' .. + 'This is a metapackage bringing in ' .. extras .. ' extras requires for ' .. value_n .. '.\\\n' .. + 'It contains no code, just makes sure the dependencies are installed.\\\n' + local files = '' + if value_i ~= '' then + files = '%files -n ' .. rpmname .. '\\\n' .. '%ghost ' .. value_i + elseif value_f ~= '' then + files = '%files -n ' .. rpmname .. ' -f ' .. value_f + end + for i, line in ipairs({pkgdef, summary, requires, description, files, ''}) do + print(line .. '\\\n') + end + end +}} diff --git a/openEuler-rpm-config.spec b/openEuler-rpm-config.spec index e1d4c38..5b4cc52 100644 --- a/openEuler-rpm-config.spec +++ b/openEuler-rpm-config.spec @@ -3,7 +3,7 @@ Name: %{vendor}-rpm-config Version: 31 -Release: 25 +Release: 26 License: GPL+ AND MIT Summary: specific rpm configuration files URL: https://gitee.com/src-openeuler/openEuler-rpm-config @@ -211,6 +211,9 @@ sed -i "s|@OSCPE@|$(cat /etc/system-release-cpe)|" %{buildroot}%{rpmvdir}/%{vend %{rpmvdir}/find-requires.ksyms %changelog +* Fri May 30 2025 Dongxing Wang - 31-26 +- Introduce %%python_extras_subpkg + * Fri May 16 2025 Funda Wang - 31-25 - valgrind support riscv since 3.25.0 -- Gitee