Created
October 30, 2018 19:52
-
-
Save ignatenkobrain/d38e5546ca346e76cc74f97d5528a13a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <solv/policy.h> | |
#include <solv/pool.h> | |
#include <solv/repo.h> | |
#include <solv/repo_solv.h> | |
#include <solv/selection.h> | |
int | |
main (int argc, | |
char **argv) | |
{ | |
Pool *pool; | |
Repo *bin, *src; | |
FILE *fp; | |
Queue sel; | |
pool = pool_create (); | |
pool_setarch (pool, "x86_64"); | |
bin = repo_create (pool, "binary"); | |
fp = fopen ("/var/cache/dnf/rawhide.solv", "rb"); | |
repo_add_solv (bin, fp, 0); | |
fclose (fp); | |
src = repo_create (pool, "source"); | |
fp = fopen ("/var/cache/dnf/rawhide-source.solv", "rb"); | |
repo_add_solv (src, fp, 0); | |
fclose (fp); | |
pool_createwhatprovides (pool); | |
queue_init (&sel); | |
selection_make (pool, &sel, argv[1], SELECTION_NAME | SELECTION_GLOB); | |
Queue rpms; | |
queue_init (&rpms); | |
selection_solvables (pool, &sel, &rpms); | |
queue_free (&sel); | |
pool_best_solvables (pool, &rpms, 0); | |
Queue q; | |
queue_init (&q); | |
for (int i = 0; i < rpms.count; i++) | |
{ | |
Id p = rpms.elements[i]; | |
Solvable *s = pool_id2solvable (pool, p); | |
printf ("%s\n", pool_solvid2str (pool, p)); | |
pool_whatmatchessolvable (pool, SOLVABLE_REQUIRES, p, &q, 0); | |
for (int j = 0; j < q.count; j++) | |
{ | |
Solvable *d = pool_id2solvable (pool, q.elements[j]); | |
if ((strcmp (solvable_lookup_sourcepkg (s), solvable_lookup_sourcepkg (d))) != 0) | |
printf (" - %s\n", pool_solvid2str (pool, q.elements[j])); | |
} | |
queue_empty (&q); | |
} | |
queue_free (&rpms); | |
pool_free (pool); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment