Hi, I have the following code snippet which looks up some groups/packages; stuffs them into a transaction and then needs the reason for installation:
#!/usr/bin/python3
import sys
import libdnf5 as dnf5
from libdnf5.base import GoalProblem_NO_PROBLEM as NO_PROBLEM
base = dnf5.base.Base()
conf = base.get_config()
conf.fastestmirror = True
conf.install_weak_deps = True
conf.zchunk = False
conf.config_file_path = "/dev/null"
conf.cachedir = "/tmp/dnf-test"
base.setup()
repo_sack = base.get_repo_sack()
repo = repo_sack.create_repo("my-repo")
repo_conf = repo.get_config()
repo_conf.name = "fedora"
repo_conf.metalink = (
"https://mirrors.fedoraproject.org/metalink?repo=fedora-38&arch=x86_64"
)
repo_sack.update_and_load_enabled_repos(load_system=False)
rpm_sack = base.get_rpm_package_sack()
rpm_sack.clear_user_excludes()
goal = dnf5.base.Goal(base)
goal.reset()
settings = dnf5.base.GoalJobSettings()
settings.group_with_name = True
for thing in sys.argv[1:]:
goal.add_install(thing, settings)
transaction = goal.resolve()
if transaction.get_problems() != NO_PROBLEM:
print("\n".join(transaction.get_resolve_logs_as_strings()))
raise SystemExit()
tis = [
ti
for ti in transaction.get_transaction_packages()
if dnf5.base.transaction.transaction_item_action_is_inbound(ti.get_action())
]
reasons = [
"NONE",
"DEPENDENCY",
"USER",
"CLEAN",
"WEAK_DEPENDENCY",
"GROUP",
"EXTERNAL_USER",
]
for ti in tis:
print(
ti.get_package().get_name(),
"--",
reasons[ti.get_reason()],
repr(ti.get_reason_change_group_id()),
)
Call with python3 script.py '@core'. The output is (abbreviated):
user@muja images € ./dnf5-test.py '@core'
sudo -- GROUP ''
curl -- GROUP ''
...
audit-libs -- DEPENDENCY ''
glibc -- DEPENDENCY ''
libselinux -- DEPENDENCY ''
openldap -- DEPENDENCY ''
openssl-libs -- DEPENDENCY ''
pam-libs -- DEPENDENCY ''
zlib -- DEPENDENCY ''
dhcp-common -- DEPENDENCY ''
...
I would have expected the transaction items that have a get_reason() of GROUP to have a filled in get_reason_change_group_id(). Perhaps I have set up base incorrectly?
Similary, this has the same behavior in dnf(4):
#!/usr/bin/env python
import sys
import dnf
base = dnf.Base()
conf = base.conf
conf.cachedir = "/tmp/my_cache_dir"
conf.substitutions["releasever"] = "38"
conf.substitutions["basearch"] = "x86_64"
base.repos.add_new_repo(
"my-repo",
conf,
baseurl=[
"http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/"
],
)
base.fill_sack()
base.install_specs(sys.argv[1:])
base.resolve()
tis = [
ti
for ti in base.transaction
if ti.action in dnf.transaction.FORWARD_ACTIONS
]
for ti in tis:
print(ti, ti.reason, ti.get_group())
Hi, I have the following code snippet which looks up some groups/packages; stuffs them into a transaction and then needs the reason for installation:
Call with
python3 script.py '@core'. The output is (abbreviated):I would have expected the transaction items that have a
get_reason()ofGROUPto have a filled inget_reason_change_group_id(). Perhaps I have set upbaseincorrectly?Similary, this has the same behavior in
dnf(4):