diff options
author | Michael Schroeder <mls@suse.de> | 2007-12-21 18:16:33 +0000 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2007-12-21 18:16:33 +0000 |
commit | 3e410095817197d87d032510204906f05f5d4198 (patch) | |
tree | f59fc18b588e6bf7c60ecef3481b3e26de5ba168 | |
parent | 4f5ad43b4a7f2f66f76e87be8007e02d53faca72 (diff) | |
download | libsolv-3e410095817197d87d032510204906f05f5d4198.tar.gz libsolv-3e410095817197d87d032510204906f05f5d4198.tar.bz2 libsolv-3e410095817197d87d032510204906f05f5d4198.zip |
- add evrmatch
- first shot at adding file provides
-rw-r--r-- | src/evr.c | 48 | ||||
-rw-r--r-- | src/evr.h | 1 | ||||
-rw-r--r-- | src/pool.c | 128 | ||||
-rw-r--r-- | src/pool.h | 1 |
4 files changed, 178 insertions, 0 deletions
@@ -167,4 +167,52 @@ evrcmp(Pool *pool, Id evr1id, Id evr2id, int mode) return r; } +int +evrmatch(Pool *pool, Id evrid, const char *epoch, const char *version, const char *release) +{ + const char *evr1; + const char *s1; + const char *r1; + int r; + + evr1 = id2str(pool, evrid); + for (s1 = evr1; *s1 >= '0' && *s1 <= '9'; s1++) + ; + if (s1 != evr1 && *s1 == ':') + { + if (epoch) + { + r = vercmp(evr1, s1, epoch, epoch + strlen(epoch)); + if (r) + return r; + } + evr1 = s1 + 1; + } + else if (epoch) + { + while (*epoch == '0') + epoch++; + if (*epoch) + return -1; + } + for (s1 = evr1, r1 = 0; *s1; s1++) + if (*s1 == '-') + r1 = s1; + if (version) + { + r = vercmp(evr1, r1 ? r1 : s1, version, version + strlen(version)); + if (r) + return r; + } + if (release) + { + if (!r1) + return -1; + r = vercmp(r1 + 1, s1, release, release + strlen(release)); + if (r) + return r; + } + return 0; +} + // EOF @@ -25,6 +25,7 @@ extern "C" { extern int vercmp(const char *s1, const char *q1, const char *s2, const char *q2); extern int evrcmp(Pool *pool, Id evr1id, Id evr2id, int mode); +extern int evrmatch(Pool *pool, Id evrid, const char *epoch, const char *version, const char *release); #ifdef __cplusplus } @@ -24,6 +24,7 @@ #include "poolid_private.h" #include "poolarch.h" #include "util.h" +#include "bitmap.h" #include "evr.h" #define SOLVABLE_BLOCK 255 @@ -626,5 +627,132 @@ pool_setdebuglevel(Pool *pool, int level) pool->debugmask = mask; } +/*************************************************************************/ + +struct searchfiles { + const char **files; + int nfiles; +}; + +#define SEARCHFILES_BLOCK 127 + +static void +pool_addfileprovides_dep(Pool *pool, Id *ida, Map *seen, struct searchfiles *sf) +{ + Id dep, sid; + const char *s; + + while ((dep = *ida++) != 0) + { + while (ISRELDEP(dep)) + { + Reldep *rd; + sid = pool->ss.nstrings + GETRELID(dep); + if (MAPTST(seen, sid)) + { + dep = 0; + break; + } + MAPSET(seen, sid); + rd = GETRELDEP(pool, dep); + if (rd->flags < 8) + dep = rd->name; + else if (rd->flags == REL_NAMESPACE) + { + if (rd->name == NAMESPACE_INSTALLED) + { + dep = 0; /* for now */ + break; + } + dep = rd->evr; + } + else + { + Id ids[2]; + ids[0] = rd->name; + ids[1] = 0; + pool_addfileprovides_dep(pool, ids, seen, sf); + dep = rd->evr; + } + } + if (!dep) + continue; + if (MAPTST(seen, dep)) + continue; + MAPSET(seen, dep); + s = id2str(pool, dep); + if (*s != '/') + continue; + if ((sf->nfiles & SEARCHFILES_BLOCK) == 0) + sf->files = xrealloc2(sf->files, sf->nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); + sf->files[sf->nfiles++] = strdup(s); + } +} + +#if 0 +static int +addfileprovides_cb(void *data, Solvable *s, Id key, const char *str) +{ + Pool *pool = s->repo->pool; + Id id; + id = str2id(pool, str, 0); + if (!id) + return 0; /* can't happen */ + s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER); + return 0; +} +#endif + +void +pool_addfileprovides(Pool *pool) +{ + Solvable *s; + Repo *repo; + Map seen; + struct searchfiles sf; + int i; + + map_init(&seen, pool->ss.nstrings + pool->nrels); + memset(&sf, 0, sizeof(sf)); + + for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++) + { + repo = s->repo; + if (!repo) + continue; + if (s->obsoletes) + pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &seen, &sf); + if (s->conflicts) + pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &seen, &sf); + if (s->requires) + pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &seen, &sf); + if (s->recommends) + pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &seen, &sf); + if (s->suggests) + pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &seen, &sf); + if (s->supplements) + pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &seen, &sf); + if (s->enhances) + pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &seen, &sf); + if (s->freshens) + pool_addfileprovides_dep(pool, repo->idarraydata + s->freshens, &seen, &sf); + } + map_free(&seen); + POOL_DEBUG(SAT_DEBUG_STATS, "found %d file dependencies\n", sf.nfiles); + if (!sf.nfiles) + return; +#if 0 + for (i = 0; i < sf.nfiles; i++) + POOL_DEBUG(SAT_DEBUG_STATS, "looking up %s in filelist\n", sf.files[i]); +#endif + if ((sf.nfiles & SEARCHFILES_BLOCK) == 0) + sf.files = xrealloc2(sf.files, sf.nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); + sf.files[sf.nfiles++] = 0; +#if 0 + pool_search(0, SOLVABLE_FILELIST, (const char *)sf.files, SEARCH_STRING|SEARCH_MULTIPLE, addfileprovides_cb, 0); +#endif + xfree(sf.files); + pool_freewhatprovides(pool); /* as we have added provides */ +} // EOF @@ -207,6 +207,7 @@ extern const char *solvable2str(Pool *pool, Solvable *s); * Prepares a pool for solving */ extern void pool_createwhatprovides(Pool *pool); +extern void pool_addfileprovides(Pool *pool); extern void pool_freewhatprovides(Pool *pool); extern Id pool_queuetowhatprovides(Pool *pool, Queue *q); |