From 227309d19851df4d2fc9f1519427a7603a240e0a Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Wed, 6 Feb 2008 19:55:36 +0000 Subject: [PATCH] Make mergesolv work again. --- tools/mergesolv.c | 109 ++++++++++++++++++++++-------------------------------- 1 file changed, 44 insertions(+), 65 deletions(-) diff --git a/tools/mergesolv.c b/tools/mergesolv.c index 44d3ddd..b3a1795 100644 --- a/tools/mergesolv.c +++ b/tools/mergesolv.c @@ -22,14 +22,52 @@ #include "repo_solv.h" #include "repo_write.h" +static char *verticals[] = { + "authors", + "description", + "messagedel", + "messageins", + "eula", + "diskusage", + 0 +}; + +static unsigned char *filter; +static int nfilter; + +static void +create_filter(Pool *pool) +{ + char **s; + Id id; + for (s = verticals; *s; s++) + { + id = str2id(pool, *s, 1); + if (id >= nfilter) + { + filter = sat_realloc(filter, id + 16); + memset(filter + nfilter, 0, id + 16 - nfilter); + nfilter = id + 16; + } + filter[id] = 1; + } +} + +static int +keyfilter(Repo *data, Repokey *key, void *kfdata) +{ + if (key->name < nfilter && filter[key->name]) + return KEY_STORAGE_VERTICAL_OFFSET; + return KEY_STORAGE_INCORE; +} + int main(int argc, char **argv) { Pool *pool = pool_create(); - int i; - int new_id_size; - Id *new_id; + Repo *repo; + repo = repo_create(pool, ""); while (argc-- > 1) { FILE *fp; @@ -39,71 +77,12 @@ main(int argc, char **argv) perror(argv[1]); exit(0); } - repo_add_solv(repo_create(pool, ""), fp); + repo_add_solv(repo, fp); fclose(fp); } - if (!pool->nrepos) - return 0; - - new_id_size = 0; - for (i = 0; i < pool->nrepos; i++) - new_id_size += pool->repos[i]->idarraysize; - new_id = (Id*) malloc (sizeof (Id) * new_id_size); - new_id_size = 0; - for (i = 0; i < pool->nrepos; i++) - { - Repo *repo = pool->repos[i]; - int si; - Solvable *s; - memcpy (new_id + new_id_size, repo->idarraydata, - repo->idarraysize * sizeof (new_id[0])); - FOR_REPO_SOLVABLES (repo, si, s) - { - if (s->provides) - s->provides += new_id_size; - if (s->obsoletes) - s->obsoletes += new_id_size; - if (s->conflicts) - s->conflicts += new_id_size; - if (s->requires) - s->requires += new_id_size; - if (s->recommends) - s->recommends += new_id_size; - if (s->suggests) - s->suggests+= new_id_size; - if (s->supplements) - s->supplements += new_id_size; - if (s->enhances) - s->enhances += new_id_size; - if (s->freshens) - s->freshens += new_id_size; - if (i > 0) - s->repo = pool->repos[0]; - } - new_id_size += repo->idarraysize; - if (i > 0) - { - pool->repos[0]->nsolvables += repo->nsolvables; - if (pool->repos[0]->start > repo->start) - pool->repos[0]->start = repo->start; - if (pool->repos[0]->end < repo->end) - pool->repos[0]->end = repo->end; - repo->nsolvables = 0; - repo->start = pool->nsolvables; - repo->end = repo->start; - free (repo->idarraydata); - repo->idarraydata = 0; - } - } - while (pool->nrepos > 1) - { - repo_free(pool->repos[pool->nrepos - 1], 1); - } - free (pool->repos[0]->idarraydata); - pool->repos[0]->idarraydata = new_id; - pool->repos[0]->idarraysize = new_id_size; - repo_write(pool->repos[0], stdout, 0, 0); + create_filter(pool); + repo_write(repo, stdout, keyfilter, 0); pool_free(pool); return 0; -- 2.7.4