Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1879168

Summary: dnf.package.Package.reponame is always "@System"
Product: Red Hat Enterprise Linux 8 Reporter: Michal Bocek <mbocek>
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED ERRATA QA Contact: Radek Bíba <rbiba>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 8.2CC: james.antill, nsella, pkratoch
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.4.2-9.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:00:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Bocek 2020-09-15 15:11:33 UTC
Description of problem:
The dnf documentation [1] says that the dnf.package.Package.reponame attribute is the "Id of repository the package was installed from (string)." Unfortunately, this attribute is always equal to "@System", no matter the repository a package has been installed from.

[1] https://dnf.readthedocs.io/en/latest/api_package.html?highlight=package#dnf.package.Package.reponame

Version-Release number of selected component (if applicable):
dnf-0:4.2.17-7.el8_2.noarch
rpm-0:4.14.2-37.el8.x86_64

Steps to Reproduce:
Run this piece of python code on RHEL 8.2:
```
import dnf
b = dnf.Base()
b.fill_sack(load_system_repo=True, load_available_repos=False)
for pkg in b.sack.query():
    print(pkg.name + '-' + pkg.evr + ': ' +  pkg.reponame)
```

Actual results:
The name of the repository from which a package has been installed is always @System:
...
NetworkManager-tui-1:1.22.8-5.el8_2: @System
acl-2.2.53-1.el8: @System
audit-3.0-0.17.20191104git1c2f876.el8: @System
...

Expected results:
I expect the reponame to match the repoid from which each package has been installed, e.g. "@rhel-8-for-x86_64-appstream-rpms".

Additional info:
The undocumented attribute dnf.package.Package._from_repo contains the correct repoid. When I use it instead of the reponame attribute, I get:
...
NetworkManager-tui-1:1.22.8-5.el8_2: @rhel-8-for-x86_64-baseos-rpms
acl-2.2.53-1.el8: @rhel-8-for-x86_64-baseos-rpms
audit-3.0-0.17.20191104git1c2f876.el8: @rhel-8-for-x86_64-baseos-rpms
...

Comment 2 Jaroslav Mracek 2020-11-06 09:00:22 UTC
I suggest that this not a bug? In case that you have only installed packages in set, all of them will have "@System" as a repo name, because they are installed. I suggest that you want to look at different value from a private attribute `_from_repo`. Is it what are you looking for?

Comment 4 Michal Bocek 2020-11-19 14:40:29 UTC
Using the private attribute dnf.package.Package._from_repo is what I've mentioned in Additional info of the bug description. That's what I'm using as a workaround.

You mention installing packages in set. I'm not sure what that means. But the reponame is @System even for packages installed through dnf as a single package, e.g. by issuing `dnf install nano`. That's the reason it seems to me like a bug.

However, if it's not going to be fixed, at least the documentation should be updated. Because the current "reponame - Id of repository the package was installed from (string)." [1] is wrong now.
[1] https://dnf.readthedocs.io/en/latest/api_package.html?highlight=package#dnf.package.Package.reponame

Comment 5 Jaroslav Mracek 2020-11-24 08:35:59 UTC
I created a new attribute for package class `from_repo` - https://github.com/rpm-software-management/dnf/pull/1692

Comment 6 Jaroslav Mracek 2020-11-25 12:51:18 UTC
I am proposing additional change: https://github.com/rpm-software-management/dnf/pull/1695.

Comment 7 Jaroslav Mracek 2021-01-13 08:48:14 UTC
Gating tests: https://github.com/rpm-software-management/ci-dnf-stack/pull/917/files
Feature: repoquery/main.feature

Comment 14 errata-xmlrpc 2021-05-18 15:00:36 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dnf bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1657