Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SP3] Display repository alias if the repository name is not defined (bsc#1184935) #572

Merged
merged 2 commits into from Jun 18, 2021

Conversation

lslezak
Copy link
Member

@lslezak lslezak commented Jun 17, 2021

The Problem

edit_repo_broken

Background

Libzypp (or the reused Yum file format) actually uses two names for repositories:

  • alias - This is the mandatory repository identifier, it should be a short string identifying the repository. It must be unique and some characters are not allowed there (/ 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.
  • name - This is the user visible name, it is optional (might be missing) and it might not be unique (duplicates are allowed), it can contain any arbitrary text, no limit for allowed characters. This is what YaST displays.

The name can contain some variables like $releasever which is replaced by the installed product version. So the openSUSE $releasever name gets expanded to openSUSE 15.3 in Leap 15.3. It is possible to get both values from libzypp, the expanded one (via the name() method) and the unexpanded original (using the rawName() 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:

[test]
enabled=0
autorefresh=1
baseurl=dir:/local/work/test
type=yast2
keeppackages=0

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 the rawName() 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:

edit_repo_fixed

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 35.273% when pulling 067d1ab on repo_name_sp3 into dcda2c7 on SLE-15-SP3.

repo_name = source_state.fetch("raw_name", "")
# if the repository does not define a name then "raw_name" is empty,
# display "name" which contains the repository alias in that case
repo_name = source_state.fetch("name", "") if repo_name.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is possible to have a test case or is it too hard?

Copy link
Member Author

@lslezak lslezak Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is an old YCP code with a 500+ lines method.... 😟

@lslezak lslezak merged commit 9f6b0a8 into SLE-15-SP3 Jun 18, 2021
@lslezak lslezak deleted the repo_name_sp3 branch June 18, 2021 06:34
@lslezak
Copy link
Member Author

lslezak commented Jun 18, 2021

Submitted manually in https://build.suse.de/request/show/243398

@yast-bot
Copy link
Contributor

✔️ Internal Jenkins job #1 successfully finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants