Bug 2231262

Summary: Wrap license at word boundary
Product: [Fedora] Fedora Reporter: Dennis Brendel <dbrendel>
Component: dnf5Assignee: rpm-software-management
Status: NEW --- QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: 38CC: jkolarik, nsella, pkratoch, ppisar, rpm-software-management, zbyszek
Target Milestone: ---Keywords: FutureFeature, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dennis Brendel 2023-08-11 07:21:30 UTC
When running `dnf5 info <package>` I expected the text to be wrapped consistently, depending on the terminal width.

While at least the description field seems to wrap at around 88 characters the license field only wraps at the terminal width.


Reproducible: Always

Steps to Reproduce:
1. Terminal is wider than 88 characters
2. dnf5 info vim
Actual Results:  
# echo $COLUMNS
120
# dnf5 info vim
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : vim-enhanced
Epoch           : 2
Version         : 9.0.1677
Release         : 2.fc38
Architecture    : x86_64
Installed size  : 4.0 MiB
Source          : vim-9.0.1677-2.fc38.src.rpm
From repository : updates
Summary         : A version of the VIM editor which includes recent enhancements
URL             : http://www.vim.org/
License         : Vim AND LGPL-2.1-or-later AND MIT AND GPL-1.0-only AND (GPL-2.0-only OR Vim) AND Apache-2.0 AND BSD-2-
                : Clause AND BSD-3-Clause AND GPL-2.0-or-later AND GPL-3.0-or-later AND OPUBL-1.0
Description     : VIM (VIsual editor iMproved) is an updated and improved version of the
                : vi editor.  Vi was the first real screen-based editor for UNIX, and is
                : still very popular.  VIM improves on vi by adding new features:
                : multiple windows, multi-level undo, block highlighting and more.  The
                : vim-enhanced package contains a version of VIM with extra, recently
                : introduced features like Python and Perl interpreters.
                : 
                : Install the vim-enhanced package if you'd like to use a version of the
                : VIM editor which includes recently added enhancements like
                : interpreters for the Python and Perl scripting languages.  You'll also
                : need to install the vim-common package.


Expected Results:  
Something like this:
# dnf5 info vim
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : vim-enhanced
Epoch           : 2
Version         : 9.0.1677
Release         : 2.fc38
Architecture    : x86_64
Installed size  : 4.0 MiB
Source          : vim-9.0.1677-2.fc38.src.rpm
From repository : updates
Summary         : A version of the VIM editor which includes recent enhancements
URL             : http://www.vim.org/
License         : Vim AND LGPL-2.1-or-later AND MIT AND GPL-1.0-only AND (GPL-2.0-only O
                : R Vim) AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND GPL-2.0-or
                : -later AND GPL-3.0-or-later AND OPUBL-1.0
Description     : VIM (VIsual editor iMproved) is an updated and improved version of the
                : vi editor.  Vi was the first real screen-based editor for UNIX, and is
                : still very popular.  VIM improves on vi by adding new features:
                : multiple windows, multi-level undo, block highlighting and more.  The
                : vim-enhanced package contains a version of VIM with extra, recently
                : introduced features like Python and Perl interpreters.
                : 
                : Install the vim-enhanced package if you'd like to use a version of the
                : VIM editor which includes recently added enhancements like
                : interpreters for the Python and Perl scripting languages.  You'll also
                : need to install the vim-common package.

Comment 1 Zbigniew Jędrzejewski-Szmek 2023-08-11 14:05:12 UTC
In general, word-breaks shouldn't be done. E.g. for the license stuff,
half of the license string might also be a valid license, and then the
result could be quite confusing. So I think the license should be handles
like %description, with the words wrapped whole.

Comment 2 Petr Pisar 2023-08-14 13:48:10 UTC
Both License and Description are wrapped at character boundary (I hope than not at byte boundary) with dnf5-5.1.1-20230814004427.13.gfe78108c.fc40.x86_64 and libsmartcols-2.39.1-3.fc39.x86_64 according to a size of the terminal:

# echo $COLUMNS 
85
root@fedora-40:~ # dnf5 --disablerepo=rawhide --enablerepo=f40-build  info vim-enhanced
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : vim-enhanced
Epoch           : 2
Version         : 9.0.1712
Release         : 1.fc40
Architecture    : x86_64
Installed size  : 4.0 MiB
Source          : vim-9.0.1712-1.fc40.src.rpm
From repository : f40-build
Summary         : A version of the VIM editor which includes recent enhancements
URL             : http://www.vim.org/
License         : Vim AND LGPL-2.1-or-later AND MIT AND GPL-1.0-only AND (GPL-2.0-onl
                : y OR Vim) AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND GPL-
                : 2.0-or-later AND GPL-3.0-or-later AND OPUBL-1.0
Description     : VIM (VIsual editor iMproved) is an updated and improved version of 
                : the
                : vi editor.  Vi was the first real screen-based editor for UNIX, and
                :  is
                : still very popular.  VIM improves on vi by adding new features:
                : multiple windows, multi-level undo, block highlighting and more.  T
                : he
                : vim-enhanced package contains a version of VIM with extra, recently
                : introduced features like Python and Perl interpreters.
                : 
                : Install the vim-enhanced package if you'd like to use a version of 
                : the
                : VIM editor which includes recently added enhancements like
                : interpreters for the Python and Perl scripting languages.  You'll a
                : lso
                : need to install the vim-common package.
Vendor          : Fedora Project

Observe T-he and a-lso line ends.

The description is pre-wrapped in an RPM package. This (80 columns) is prescribed by Fedora packaging guidelines <https://docs.fedoraproject.org/en-US/packaging-guidelines/#_summary_and_description>. The description is a text block while the license is a one-line string. That's the difference between Description and License.

So DNF5 handles both fields consistently. What you observe is how the data are stored in RPM.

I agree that rather then breaking words (which is difficult to do correctly without a language-specific dictionary), DNF5 should rather break lines per words. Excessively long words are a problem. I would rather keep them overflowing, but I can image technical limitations in smartcols library forcing to break them in all cases.

Comment 3 Dennis Brendel 2023-08-15 15:11:22 UTC
Thank you for the explanation! Yeah, rpm -qi show the exact same, so that makes sense.

I agree on that the word boundary should be were lines break. There could be a workaround that line breaks for licenses happen on the [andANDorOR] boundary, if that's covering all cases. That might even improve readability.

But it's still just a cosmetic thing.