Bug 1049226

Summary: query.filter(latest_per_arch=True) returns multiple packages
Product: [Fedora] Fedora Reporter: Daniel Mach <dmach>
Component: hawkeyAssignee: Ales Kozumplik <akozumpl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: akozumpl, jzeleny, mls, packaging-team-maint, pnemade, rholy
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: hawkey-0.4.8-1.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-23 11:03:43 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:
Bug Depends On:    
Bug Blocks: 578256    
Attachments:
Description Flags
reproducer none

Description Daniel Mach 2014-01-07 09:00:43 UTC
Created attachment 846516 [details]
reproducer

Current behaviour:
query.filter(latest_per_arch=True) returns multiple packages per name and arch

Expected behaviour:
one package per name and arch is returned


See attached reproducer for details.

Comment 1 Ales Kozumplik 2014-01-07 14:08:54 UTC
Reproduced.

Not a bug in latest_per_arch, but a feature of libsolv itself: it by default does not add available packages of incompatible architectures (I assume this was run on x86_64) to the whatprovides structures. The querying then can fail as a result.

Dan, you can use hawkey directly and specify a different architecture when creating the Sack:

sack = hawkey.Sack(arch=ppc64)

Michael, is there an option in libsolv to consider all packages in cases like this?

Comment 2 Daniel Mach 2014-01-07 15:33:57 UTC
(In reply to Ales Kozumplik from comment #1)
> Reproduced.
> 
> Not a bug in latest_per_arch, but a feature of libsolv itself: it by default
> does not add available packages of incompatible architectures (I assume this
> was run on x86_64) to the whatprovides structures. The querying then can
> fail as a result.
> 
> Dan, you can use hawkey directly and specify a different architecture when
> creating the Sack:
> 
> sack = hawkey.Sack(arch=ppc64)
I tried following hack and the test passed:
import dnf.package
import dnf.sack
from dnf.sack import Sack

def build_sack(base):
    cachedir = base.conf.cachedir
    # create the dir ourselves so we have the permissions under control:
    dnf.util.ensure_dir(cachedir)
    return Sack(pkgcls=dnf.package.Package, pkginitval=base,
                cachedir=cachedir,
                rootdir=base.conf.installroot, arch="ppc64") # added ppc64 arch

dnf.sack.build_sack = build_sack


> 
> Michael, is there an option in libsolv to consider all packages in cases
> like this?

I think following scenarios should be supported:
1) default system arch
sack = hawkey.Sack()

2) user defined arch
sack = hawkey.Sack(arch="ppc64")

3) all arches in repo (consider repoquery and similar tools)
sack = hawkey.Sack(arch="ALL")

1) and 2) -- packages of incompatible arches should not be available in the sack

Comment 3 Michael Schröder 2014-01-07 15:41:20 UTC
No, the whatprovides hash intentionally only contains "installable" packages.

I don't see why filter_latest really needs to use it, though. Just change the code to push all package ids in the "res" map onto the samename queue, then sort the queue by package name.

Comment 4 Michael Schröder 2014-01-07 15:45:53 UTC
(that last comment was an answer to Ales question, of course)

If you want to implement arch="ALL", just don't call pool_setarch (or call it with a NULL arch.

Comment 5 Michael Schröder 2014-01-07 17:43:53 UTC
Maybe do something like: http://paste.fedoraproject.org/66471/

Comment 6 Ales Kozumplik 2014-01-08 09:43:08 UTC
Thank you for the analysis and the patch, Michael, I've submitted it to master in 522fb1c.

Comment 7 Fedora Update System 2014-01-21 07:03:48 UTC
hawkey-0.4.8-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/hawkey-0.4.8-1.fc20

Comment 8 Fedora Update System 2014-01-22 03:07:28 UTC
Package hawkey-0.4.8-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing hawkey-0.4.8-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-1248/hawkey-0.4.8-1.fc20
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2014-01-23 11:03:43 UTC
hawkey-0.4.8-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.