Bug 1013916 - Cannot iterate all packages loaded by load_system_repo from RPM db
Summary: Cannot iterate all packages loaded by load_system_repo from RPM db
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: hawkey
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ales Kozumplik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-01 03:56 UTC by cqi
Modified: 2014-09-30 23:41 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-01 08:23:58 UTC
Type: Bug


Attachments (Terms of Use)
simple Python script playing with hawkey (1.68 KB, text/x-python)
2013-10-01 03:56 UTC, cqi
no flags Details

Description cqi 2013-10-01 03:56:46 UTC
Created attachment 805688 [details]
simple Python script playing with hawkey

Description of problem:

Iterating all packages loaded via load_system_repo cannot get same result of command `rpm -aq`.

I'm running Fedora 19. And hawkey packages are

hawkey-0.3.16-2.git1e5a593.fc19.x86_64
python-hawkey-0.3.16-2.git1e5a593.fc19.x86_64


How reproducible:
A Python script is attached. Run the script.

Steps to Reproduce:
$ python hawkey_script.py


Actual results:

1. the total number of packages is not same. hawkey always returns less packages than rpm, no matter what runing the script after installing or updating packages.

2. many packages listed by `rpm -aq` are not included in the result generated by hawkey.

Comment 1 Ales Kozumplik 2013-10-01 05:38:20 UTC
Hi, this must be the bug we discussed. I'll take a look.

Comment 2 Ales Kozumplik 2013-10-01 07:51:01 UTC
The difference in some package names is that hawkey doesn't print out nonzero epoch --- that is probably a bug, I'll have to dig deeper into that.

The mismatch in counts is because 'rpm -qa' also outputs the gpg keys kept in rpmdb, which is kind of an RPM-specific hack and we don't return these by design.

Comment 3 Ales Kozumplik 2013-10-01 08:23:58 UTC
So it's the other way round: hawkey correctly outputs package epochs if they are nonzero, the default 'rpm -qa' never outputs epochs, which is also the correct behavior for rpm.

If I modify your script slightly, i.e.:

def no_epoch_str(pkg):
    return '%s-%s-%s.%s' % (pkg.name, pkg.version, pkg.release, pkg.arch)

def packages_count_from_hawkey():
    sack = hawkey.Sack()
    sack.load_system_repo()
    packages = hawkey.Query(sack)
    return map(no_epoch_str, packages)

I get two same outputs for both paths of obtaining the package list, the only difference is that 'rpm -qa' returns the gpgkeys present in the DB as described in comment 2.

Closing this as NOTABUG.


Note You need to log in before you can comment on or make changes to this bug.