From 9f63ef78d353c21f771726fa2e24ad1622c30671 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Fri, 2 Mar 2012 15:00:47 +0100 Subject: [PATCH] - add idqinst parameter to pool_addfileprovides_queue so that it can also return the added id list for the installed repo --- bindings/solv.i | 2 +- examples/solv.c | 31 +++++++++++++++++++++++++------ src/pool.c | 12 ++++++++++-- src/pool.h | 2 +- tools/common_write.c | 2 +- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 3bc6593..c790212 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -955,7 +955,7 @@ typedef struct { Queue addfileprovides_queue() { Queue r; queue_init(&r); - pool_addfileprovides_queue($self, &r); + pool_addfileprovides_queue($self, &r, 0); return r; } void createwhatprovides() { diff --git a/examples/solv.c b/examples/solv.c index 455eae8..ed288b7 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -2505,7 +2505,7 @@ addsoftlocks(Pool *pool, Queue *job) void -rewrite_repos(Pool *pool, Queue *addedfileprovides) +rewrite_repos(Pool *pool, Queue *addedfileprovides, Queue *addedfileprovides_inst) { Repo *repo; Repodata *data; @@ -2536,14 +2536,30 @@ rewrite_repos(Pool *pool, Queue *addedfileprovides) continue; /* found a non-externsion repodata, can't rewrite */ if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq)) { + if (repo == pool->installed && addedfileprovides_inst) + { + for (j = 0; j < addedfileprovides->count; j++) + MAPCLR(&providedids, addedfileprovides->elements[j]); + for (j = 0; j < addedfileprovides_inst->count; j++) + MAPSET(&providedids, addedfileprovides_inst->elements[j]); + } n = 0; for (j = 0; j < fileprovidesq.count; j++) if (MAPTST(&providedids, fileprovidesq.elements[j])) n++; - if (n == addedfileprovides->count) + if (repo == pool->installed && addedfileprovides_inst) + { + for (j = 0; j < addedfileprovides_inst->count; j++) + MAPCLR(&providedids, addedfileprovides_inst->elements[j]); + for (j = 0; j < addedfileprovides->count; j++) + MAPSET(&providedids, addedfileprovides->elements[j]); + if (n == addedfileprovides_inst->count) + continue; /* nothing new added */ + } + else if (n == addedfileprovides->count) continue; /* nothing new added */ } - repodata_set_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides); + repodata_set_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, repo == pool->installed && addedfileprovides_inst ? addedfileprovides_inst : addedfileprovides); repodata_internalize(data); cinfo = repo->appdata; writecachedrepo(repo, data, 0, cinfo ? cinfo->cookie : installedcookie); @@ -2652,6 +2668,7 @@ main(int argc, char **argv) int allpkgs = 0; FILE **newpkgsfps; Queue addedfileprovides; + Queue addedfileprovides_inst; Id repofilter = 0; int cleandeps = 0; @@ -2863,10 +2880,12 @@ main(int argc, char **argv) // FOR_REPOS(i, repo) // printf("%s: %d solvables\n", repo->name, repo->nsolvables); queue_init(&addedfileprovides); - pool_addfileprovides_queue(pool, &addedfileprovides); - if (addedfileprovides.count) - rewrite_repos(pool, &addedfileprovides); + queue_init(&addedfileprovides_inst); + pool_addfileprovides_queue(pool, &addedfileprovides, &addedfileprovides_inst); + if (addedfileprovides.count || addedfileprovides_inst.count) + rewrite_repos(pool, &addedfileprovides, &addedfileprovides_inst); queue_free(&addedfileprovides); + queue_free(&addedfileprovides_inst); pool_createwhatprovides(pool); queue_init(&job); diff --git a/src/pool.c b/src/pool.c index 99bc332..6b14e18 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1149,7 +1149,7 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru } void -pool_addfileprovides_queue(Pool *pool, Queue *idq) +pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst) { Solvable *s; Repo *installed, *repo; @@ -1167,6 +1167,8 @@ pool_addfileprovides_queue(Pool *pool, Queue *idq) if (idq) queue_empty(idq); + if (idqinst) + queue_empty(idqinst); isfp = installed ? &isf : 0; for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++) { @@ -1202,6 +1204,9 @@ pool_addfileprovides_queue(Pool *pool, Queue *idq) if (idq) for (i = 0; i < sf.nfiles; i++) queue_push(idq, sf.ids[i]); + if (idqinst) + for (i = 0; i < sf.nfiles; i++) + queue_push(idqinst, sf.ids[i]); solv_free(sf.ids); for (i = 0; i < sf.nfiles; i++) { @@ -1219,6 +1224,9 @@ pool_addfileprovides_queue(Pool *pool, Queue *idq) #endif if (installed) pool_addfileprovides_search(pool, &cbd, &isf, installed); + if (installed && idqinst) + for (i = 0; i < isf.nfiles; i++) + queue_pushunique(idqinst, isf.ids[i]); solv_free(isf.ids); for (i = 0; i < isf.nfiles; i++) { @@ -1236,7 +1244,7 @@ pool_addfileprovides_queue(Pool *pool, Queue *idq) void pool_addfileprovides(Pool *pool) { - pool_addfileprovides_queue(pool, 0); + pool_addfileprovides_queue(pool, 0, 0); } void diff --git a/src/pool.h b/src/pool.h index 4191f53..02f0be2 100644 --- a/src/pool.h +++ b/src/pool.h @@ -264,7 +264,7 @@ static inline int pool_match_nevr(Pool *pool, Solvable *s, Id d) */ extern void pool_createwhatprovides(Pool *pool); extern void pool_addfileprovides(Pool *pool); -extern void pool_addfileprovides_queue(Pool *pool, Queue *idq); +extern void pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst); extern void pool_freewhatprovides(Pool *pool); extern Id pool_queuetowhatprovides(Pool *pool, Queue *q); diff --git a/tools/common_write.c b/tools/common_write.c index 3ea6a5b..9dcbe75 100644 --- a/tools/common_write.c +++ b/tools/common_write.c @@ -205,7 +205,7 @@ tool_write(Repo *repo, const char *basename, const char *attrname) info = repo_add_repodata(repo, 0); repodata_set_str(info, SOLVID_META, REPOSITORY_TOOLVERSION, LIBSOLV_TOOLVERSION); queue_init(&addedfileprovides); - pool_addfileprovides_queue(repo->pool, &addedfileprovides); + pool_addfileprovides_queue(repo->pool, &addedfileprovides, 0); if (addedfileprovides.count) { kd.haveaddedfileprovides = 1; -- 2.7.4