Automatically word-wrap the description of extras subpackages
This only works for package and extra names less than 79 characters long. I don't expect many actual packages to exceed this limit. 78 characters should be enough for everybody. Why 78? 79 is the line-lenght limit from rpmlint. And we need to put punctuation in there.
This commit is contained in:
parent
5b5cc39d89
commit
c746b25f28
@ -202,8 +202,18 @@
|
||||
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' ..
|
||||
local description = '%description -n ' .. rpmname .. '\\\n'
|
||||
local current_line = 'This is a metapackage bringing in'
|
||||
for _, word in ipairs({extras, 'extras', 'requires', 'for', value_n .. '.'}) do
|
||||
local line = current_line .. ' ' .. word
|
||||
if line:len() > 79 then
|
||||
description = description .. current_line .. '\\\n'
|
||||
current_line = word
|
||||
else
|
||||
current_line = line
|
||||
end
|
||||
end
|
||||
description = description .. current_line .. '\\\n' ..
|
||||
'It contains no code, just makes sure the dependencies are installed.\\\n'
|
||||
local files = ''
|
||||
if value_i ~= '' then
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: python-rpm-macros
|
||||
Version: 3.9
|
||||
Release: 12%{?dist}
|
||||
Release: 13%{?dist}
|
||||
Summary: The common Python RPM macros
|
||||
|
||||
# macros and lua: MIT, compileall2.py: PSFv2
|
||||
@ -107,6 +107,10 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Feb 05 2021 Miro Hrončok <mhroncok@redhat.com> - 3.9-13
|
||||
- Automatically word-wrap the description of extras subpackages
|
||||
- Fixes: rhbz#1922442
|
||||
|
||||
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.9-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
|
@ -340,7 +340,8 @@ def test_python_extras_subpkg_i():
|
||||
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.
|
||||
This is a metapackage bringing in toml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
|
||||
%files -n python3-setuptools_scm+toml
|
||||
@ -350,7 +351,8 @@ def test_python_extras_subpkg_i():
|
||||
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.
|
||||
This is a metapackage bringing in yaml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
|
||||
%files -n python3-setuptools_scm+yaml
|
||||
@ -367,7 +369,8 @@ def test_python_extras_subpkg_f():
|
||||
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.
|
||||
This is a metapackage bringing in toml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
|
||||
%files -n python3-setuptools_scm+toml -f ghost_filelist
|
||||
@ -376,7 +379,8 @@ def test_python_extras_subpkg_f():
|
||||
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.
|
||||
This is a metapackage bringing in yaml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
|
||||
%files -n python3-setuptools_scm+yaml -f ghost_filelist
|
||||
@ -392,7 +396,8 @@ def test_python_extras_subpkg_F():
|
||||
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.
|
||||
This is a metapackage bringing in toml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
|
||||
|
||||
@ -401,12 +406,35 @@ def test_python_extras_subpkg_F():
|
||||
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.
|
||||
This is a metapackage bringing in yaml extras requires for
|
||||
python3-setuptools_scm.
|
||||
It contains no code, just makes sure the dependencies are installed.
|
||||
""").lstrip().splitlines()
|
||||
assert lines == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('basename_len', [1, 10, 30, 45, 78])
|
||||
@pytest.mark.parametrize('extra_len', [1, 13, 28, 52, 78])
|
||||
def test_python_extras_subpkg_description_wrapping(basename_len, extra_len):
|
||||
basename = 'x' * basename_len
|
||||
extra = 'y' * extra_len
|
||||
lines = rpm_eval(f'%python_extras_subpkg -n {basename} -F {extra}',
|
||||
version='6', release='7')
|
||||
for idx, line in enumerate(lines):
|
||||
if line.startswith('%description'):
|
||||
start = idx + 1
|
||||
lines = lines[start:]
|
||||
assert all(len(l) < 80 for l in lines)
|
||||
assert len(lines) < 6
|
||||
if len(" ".join(lines[:-1])) < 80:
|
||||
assert len(lines) == 2
|
||||
expected_singleline = (f"This is a metapackage bringing in {extra} extras "
|
||||
f"requires for {basename}. It contains no code, "
|
||||
f"just makes sure the dependencies are installed.")
|
||||
description_singleline = " ".join(lines)
|
||||
assert description_singleline == expected_singleline
|
||||
|
||||
|
||||
unversioned_macros = pytest.mark.parametrize('macro', [
|
||||
'%__python',
|
||||
'%python',
|
||||
|
Loading…
Reference in New Issue
Block a user