[SP3] Display repository alias if the repository name is not defined (bsc#1184935) #572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
Background
Libzypp (or the reused Yum file format) actually uses two names for repositories:
/
is automatically replaced because the alias is also used as the.repo
file name). YaST never displays the alias as this is kind of internal data.The name can contain some variables like
$releasever
which is replaced by the installed product version. So theopenSUSE $releasever
name gets expanded toopenSUSE 15.3
in Leap 15.3. It is possible to get both values from libzypp, the expanded one (via thename()
method) and the unexpanded original (using therawName()
method).Debugging
Originally I was able to reproduce the problem in some previous Tumbleweed release. It behaved strangely, for some repositories the name was displayed correctly, for some it was just empty.
Later I could not reproduce the problem it with the latest TW, but luckily the problem happens on my older Leap workstation.
Details
I was able to reproduce the problem locally with some testing repository I used in the past. The
/etc/zypp/repos.d/test.repo
contained:As you can see the
name
attribute is actually missing there!It turned out that the
name()
method fallbacks to the repository alias in libzypp if the name is not defined. But therawName()
method does not use any fallback, if the name is not defined it returns empty string.And YaST (as an exception) displays the raw name in that dialog to allow editing the variables in the name...
The Fix
To fix the problem YaST should display the name if the raw name is empty, in that case the name contains the alias as a fallback. That's also what YaST and zypper show as the repository name in that case.
Testing
Just tested manually with that repository mentioned above, the name (actually the alias fallback) is displayed correctly: