diff --git a/macros.python b/macros.python index 59df73513baf08f0fb27bfe04522888e10525145..7882e4e3f4c97c6054a9f036b942fb077d2a3b2a 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 e1d4c38e5deb47f8c0f776fe272d187da82e4e4e..5b4cc5239ec8731688e4004bc36489d939253d85 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