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

Add support for non-installable packages in whatmatchessolvable() #334

Closed
ignatenkobrain opened this issue Jul 7, 2019 · 8 comments
Closed
Labels
A-selection Area: Selections RFE 🎁

Comments

@ignatenkobrain
Copy link
Collaborator

#!/usr/bin/python3

import solv

pool = solv.Pool()

repo = pool.add_repo('available')
sprov = repo.add_solvable()
sprov.name = 'sprov'
sprov.evr = '1-1'
sprov.arch = 'noarch'
sprov.add_deparray(solv.SOLVABLE_PROVIDES, pool.Dep('x').Rel(solv.REL_EQ, pool.str2id('2.1.0')))
for arch in ('noarch', 'src'):
    sreq = repo.add_solvable()
    sreq.name = f's-{arch}'
    sreq.evr = '1-1'
    sreq.arch = arch
    sreq.add_deparray(solv.SOLVABLE_REQUIRES, pool.parserpmrichdep('(x >= 2.0.0 with x < 3.0.0)'))

pool.createwhatprovides()

print(pool.whatmatchessolvable(solv.SOLVABLE_REQUIRES, sprov))

returns

[<Solvable #3 s-noarch-1-1.noarch>]
@ignatenkobrain
Copy link
Collaborator Author

/* intersect dependencies in keyname with all provides of solvable solvid,                                    
 * return list of matching packages */                                                                        
/* this currently only works for installable packages */                                                      

which does check for pool_installable(), which mean packages with ARCH_SRC are ignored...

@ignatenkobrain ignatenkobrain changed the title whatmatchessolvable does not check source RPMs Add support for non-installable packages in whatmatchessolvable() Jul 7, 2019
@ignatenkobrain
Copy link
Collaborator Author

@mlschroe what would it take to add support of non-installable packages to this function?

@ignatenkobrain ignatenkobrain added the A-selection Area: Selections label Jul 7, 2019
@mlschroe
Copy link
Member

mlschroe commented Jul 8, 2019

I don't think we should for consistency reasons. Why don't you use the selection variant as a workaround?

sel = pool.Selection_all()
sel.matchsolvable(sprov, 0, solv.SOLVABLE_REQUIRES)
print(sel.solvables())

@mlschroe
Copy link
Member

mlschroe commented Jul 8, 2019

(Too bad that swig prevents a return of $self so that we could write pool.Selection_all().matchsolvable(...).solvables())

@ignatenkobrain
Copy link
Collaborator Author

Oh, I didn't know about this workaround :)

@ignatenkobrain
Copy link
Collaborator Author

Too bad that swig prevents a return of $self

Can't you return XSelection and tell it to not free memory on it?

@mlschroe
Copy link
Member

mlschroe commented Jul 9, 2019

No, that wouldn't work. sel = sel.matchsolvable() would free the underlying object. It needs to be some SWIG trickery.

@mlschroe
Copy link
Member

mlschroe commented Jul 9, 2019

Hey, I found out how to do it. See commit 6935152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-selection Area: Selections RFE 🎁
Projects
None yet
Development

No branches or pull requests

2 participants