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

treebuilder.py: get_branding inconsistency #1430

Open
cjschroeder opened this issue Oct 24, 2024 · 4 comments
Open

treebuilder.py: get_branding inconsistency #1430

cjschroeder opened this issue Oct 24, 2024 · 4 comments

Comments

@cjschroeder
Copy link

cjschroeder commented Oct 24, 2024

In treebuilder.py, get_branding() tries to determine which package provides "system-release".

query = dnf5.rpm.PackageQuery(self.dbo)
query.filter_provides(["system-release"], EQ)
pkgs = sorted([p for p in list(query)
                       if not p.get_name().startswith("generic")])

This past week, I started to see issues with lorax and creating a custom bootiso. I've been using lorax, since fc28 or fc32, for this exact thing without issue.

Depending on how the specified repositories are loaded, the results in "pkgs" will vary and affect the value of

release = pkgs[0].get_name()

and then cause issue due to a conflict with installing mydist-logos and fedora-logos.

I created a simple script to demonstrate the indeterminate results.

#!/usr/bin/python3

import libdnf5
from libdnf5.common import QueryCmp_EQ as EQ

base = libdnf5.base.Base()
base.load_config_from_file()
base.setup()
sack = base.get_repo_sack()
sack.create_repos_from_system_configuration()
sack.update_and_load_enabled_repos(False)

rq = libdnf5.repo.RepoQuery(base)
rq.filter_enabled(True)
print("Using repos: ", ", ".join(r.get_id() for r in rq))

q = libdnf5.rpm.PackageQuery(base)
q.filter_provides(["system-release"], EQ)
s = sorted([p for p in list(q) if not p.get_name().startswith("generic")])
print("Using: ", s[0])
print("   ", repr(s[0]))

Run multiple instances of the above script and you'll see differing output.

$ ./t1.py
Using repos:  mydist, fedora, updates, mydist-dev
Using:  mydist-release-40-1.fc40.noarch
    <libdnf5.rpm.Package object, mydist-release-40-1.fc40.noarch, id: 1234>

$ ./t1.py
Using repos:  mydist-dev, mydist, fedora, updates
Using:  mydist-release-40-2.fc40.noarch
    <libdnf5.rpm.Package object, mydist-release-40-2.fc40.noarch, id: 1240>

$ ./t1.py
Using repos:  fedora, mydist-dev, mydist, updates
Using:  fedora-release-40-38.noarch
    <libdnf5.rpm.Package object, fedora-release-40-38.noarch, id: 7995>

$ ./t1.py
Using repos:  updates, mydist-dev, fedora, mydist
Using:  fedora-release-40-39.noarch
    <libdnf5.rpm.Package object, fedora-release-40-39.noarch, id: 3090

I have found that by reordering the "--source" arguments to lorax has thus far resolved the issue.

Original:

$ lorax \
   <snip>
   --source="https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/" \
   --source="https://dl.fedoraproject.org/pub/fedora/linux/updates/40/Everything/x86_64/" \
   --source="http://10.88.0.11/dnfrepo" \
   <snip>

Resolved:

$ lorax \
   <snip>
   --source="https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/" \
   --source="http://10.88.0.11/dnfrepo" \   <--- THIS
   --source="https://dl.fedoraproject.org/pub/fedora/linux/updates/40/Everything/x86_64/" \
   <snip>

Components:

Fedora 40

$ rpm -qa|grep -E 'lorax|python3-3.12|dnf5'
lorax-templates-generic-40.7-1.fc40.x86_64
lorax-40.7-1.fc40.x86_64
lorax-lmc-virt-40.7-1.fc40.x86_64
lorax-lmc-novirt-40.7-1.fc40.x86_64
libdnf5-5.1.17-2.fc40.x86_64
libdnf5-cli-5.1.17-2.fc40.x86_64
dnf5-5.1.17-2.fc40.x86_64
dnf5-plugins-5.1.17-2.fc40.x86_64
python3-libdnf5-5.1.17-2.fc40.x86_64
python3-3.12.7-1.fc40.x86_64
@bcl
Copy link
Contributor

bcl commented Oct 25, 2024

Something in dnf5 must have changed, or has been random all this time and you were just lucky.
dnf5 returns everything that matches from all the repos, but the sort should make the results consistent and you should always have been getting fedora-release. What does list(p) look like before and after sorting? From the example it looks to me like either the fedora-release isn't returned or the sort isn't properly sorting.

Usually the best thing to do is have a single provider of system-release in the repos. But something else you could do is use --variant mydist and a package named something like 'release-mydist' so that it will override the normal behavior.

@cjschroeder
Copy link
Author

cjschroeder commented Oct 28, 2024

Lists q and s are virtually the same on every run, minus any "generic" names in s.

While q can vary, it seems using sorted() to produce s should be deterministic, but it's not. Likely due to not sorting with a "key". It appears to sort on "id".

I don't use the variant arg, since I create a generic boot iso used to stitch together multiple variants later on.

@bcl
Copy link
Contributor

bcl commented Oct 28, 2024

Ah! That might explain things, since they're package objects not just strings.

@cjschroeder
Copy link
Author

Exactly!

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

No branches or pull requests

2 participants