Created
June 26, 2013 15:47
-
-
Save mlschroe/5868566 to your computer and use it in GitHub Desktop.
Example implementation
This file contains 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
find_pkg_updates(Pool *pool, Solvable *s) | |
{ | |
Id p, pp, evr; | |
Dataiterator di; | |
Solvable *is = 0; | |
Queue q; | |
/* first find installed package for the range */ | |
FOR_PROVIDES(p, pp, s->name) | |
{ | |
Solvable *iscand = pool->solvables + p; | |
if (!iscand->repo || iscand->repo != pool->installed) | |
continue; | |
if (iscand->name != s->name || iscand->arch != s->arch) | |
continue; | |
if (!is || pool_evrcmp(pool, is->evr, iscand->evr) < 0) | |
is = iscand; | |
} | |
queue_init(&q); | |
dataiterator_init(&di, pool, 0, 0, UPDATE_COLLECTION_NAME, pool_id2str(pool, s->name), SEARCH_STRING); | |
dataiterator_prepend_keyname(&di, UPDATE_COLLECTION); | |
while (dataiterator_step(&di)) | |
{ | |
dataiterator_setpos_parent(&di); | |
if (pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_ARCH) != s->arch) | |
continue; | |
evr = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_EVR); | |
if (!evr) | |
continue; | |
if (is && pool_evrcmp(pool, is->evr, evr) >= 0) | |
continue; /* already installed */ | |
if (pool_evrcmp(pool, s->evr, evr) < 0) | |
continue; | |
queue_push(&q, di.solvid); | |
} | |
dataiterator_free(&di); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment