From 128a5e3d43938e2667cfec0541cc7de61ff65efd Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 22 Oct 2007 18:01:35 +0000 Subject: [PATCH] - first step in getting rid of dependency pointers: store back pointer to source in Solvable. --- src/pool.c | 25 ------------------------- src/pool.h | 2 -- src/solvable.h | 9 ++++++--- src/solver.c | 6 +++--- src/source_solv.c | 1 + tools/source_content.c | 3 ++- tools/source_helix.c | 1 + tools/source_patchxml.c | 2 ++ tools/source_rpmdb.c | 2 ++ tools/source_rpmmd.c | 8 +------- tools/source_susetags.c | 1 + 11 files changed, 19 insertions(+), 41 deletions(-) diff --git a/src/pool.c b/src/pool.c index 495c3e7..5f1d844 100644 --- a/src/pool.c +++ b/src/pool.c @@ -513,29 +513,4 @@ pool_addrelproviders(Pool *pool, Id d) return pool->whatprovidesdata + pool->whatprovides[d]; } - -/* - * return source of solvable - * or NULL - */ - -Source * -pool_source(Pool *pool, Solvable *s) -{ - int i; - Source *source; - int off = s - pool->solvables; - - for (i = 0; i < pool->nsources; i++) - { - source = pool->sources[i]; - if (off >= source->start - && off < source->start+source->nsolvables) - { - return source; - } - } - return NULL; -} - // EOF diff --git a/src/pool.h b/src/pool.h index e5c71ec..509ba4f 100644 --- a/src/pool.h +++ b/src/pool.h @@ -135,8 +135,6 @@ extern Id pool_queuetowhatprovides(Pool *pool, Queue *q); extern Id *pool_addrelproviders(Pool *pool, Id d); -extern Source *pool_source(Pool *pool, Solvable *s); - static inline int pool_installable(Pool *pool, Solvable *s) { if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC) diff --git a/src/solvable.h b/src/solvable.h index aaecd71..4840298 100644 --- a/src/solvable.h +++ b/src/solvable.h @@ -8,14 +8,17 @@ #define SOLVABLE_H #include "pooltypes.h" +#include "source.h" typedef struct _Solvable { Id name; Id arch; - Id evr; + Id evr; /* epoch:version-release */ - // dependencies are pointers into idarray of source the solvable originates from - Id *provides; // terminated with Id 0 + Source *source; /* source we belong to */ + + /* dependencies are pointers into idarray of source */ + Id *provides; /* terminated with Id 0 */ Id *obsoletes; Id *conflicts; diff --git a/src/solver.c b/src/solver.c index 0f592a3..a254046 100644 --- a/src/solver.c +++ b/src/solver.c @@ -854,7 +854,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) #endif addrule(solv, -n, 0); /* mark requestor as uninstallable */ if (solv->rc_output) - printf(">!> !unflag %s-%s.%s[%s]\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), source_name(pool_source(pool, s))); + printf(">!> !unflag %s-%s.%s[%s]\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), source_name(s->source)); continue; } #if 0 @@ -2480,7 +2480,7 @@ printdecisions(Solver *solv) } if (solv->rc_output) { - Source *source = pool_source(pool, s); + Source *source = s->source; if (source && strcmp(source_name(source), "locales")) printf("[%s]", source_name(source)); } @@ -2701,7 +2701,7 @@ solve(Solver *solv, Queue *job) case SOLVER_INSTALL_SOLVABLE: /* install specific solvable */ if (solv->rc_output) { Solvable *s = pool->solvables + what; - printf(">!> Installing %s from channel %s\n", id2str(pool, s->name), source_name(pool_source(pool, s))); + printf(">!> Installing %s from channel %s\n", id2str(pool, s->name), source_name(s->source)); } addrule(solv, what, 0); /* install by Id */ break; diff --git a/src/source_solv.c b/src/source_solv.c index 2d6ddd6..706d3b9 100644 --- a/src/source_solv.c +++ b/src/source_solv.c @@ -484,6 +484,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) #endif for (i = 0, s = pool->solvables + source->start; i < numsolv; i++, s++) { + s->source = source; databits = 0; if (numsolvdatabits) { diff --git a/tools/source_content.c b/tools/source_content.c index c939ca8..a89be60 100644 --- a/tools/source_content.c +++ b/tools/source_content.c @@ -177,7 +177,7 @@ pool_addsource_content(Pool *pool, FILE *fp) source = pool_addsource_empty(pool); memset(&pd, 0, sizeof(pd)); - line = malloc(1024); + line = xmalloc(1024); aline = 1024; pd.source = source; @@ -233,6 +233,7 @@ pool_addsource_content(Pool *pool, FILE *fp) memset(deps + pack, 0, (PACK_BLOCK + 1) * sizeof(struct deps)); } s = pool->solvables + source->start + pack; + s->source = source; dp = deps + pack; pack++; } diff --git a/tools/source_helix.c b/tools/source_helix.c index b879c73..5b1bad1 100644 --- a/tools/source_helix.c +++ b/tools/source_helix.c @@ -637,6 +637,7 @@ endElement(void *userData, const char *name) { case STATE_PACKAGE: /* package complete */ + s->source = pd->source; if (!s->arch) /* default to "noarch" */ s->arch = ARCH_NOARCH; diff --git a/tools/source_patchxml.c b/tools/source_patchxml.c index 1f62c56..38d3f69 100644 --- a/tools/source_patchxml.c +++ b/tools/source_patchxml.c @@ -295,6 +295,7 @@ startElement(void *userData, const char *name, const char **atts) /* HACK: close patch */ if (pd->kind && !strcmp(pd->kind, "patch")) { + s->source = pd->source; if (!s->arch) s->arch = ARCH_NOARCH; pd->deps[pd->pack].provides = source_addid_dep(pd->source, pd->deps[pd->pack].provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); @@ -406,6 +407,7 @@ endElement(void *userData, const char *name) case STATE_PATCH: if (!strcmp(name, "patch") && strcmp(pd->kind, "patch")) break; /* already closed */ + s->source = pd->source; if (!s->arch) s->arch = ARCH_NOARCH; if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) diff --git a/tools/source_rpmdb.c b/tools/source_rpmdb.c index 6ffd339..b3f4d49 100644 --- a/tools/source_rpmdb.c +++ b/tools/source_rpmdb.c @@ -586,6 +586,7 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) memset(deps + asolv, 0, 256 * sizeof(*deps)); asolv += 256; } + pool->solvables[source->start + i].source = source; if (key.size != 4) { fprintf(stderr, "corrupt Packages database (key size)\n"); @@ -716,6 +717,7 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) s = pool->solvables + source->start; for (i = 0; i < nrpmids; i++, rp++, s++) { + s->source = source; dbid = rp->dbid; source->rpmdbid[i] = dbid; if (refhash) diff --git a/tools/source_rpmmd.c b/tools/source_rpmmd.c index c342c02..d18e068 100644 --- a/tools/source_rpmmd.c +++ b/tools/source_rpmmd.c @@ -374,13 +374,7 @@ endElement(void *userData, const char *name) switch (pd->state) { case STATE_PACKAGE: -#if 0 - { - const char *arch = id2str(pool, s->arch); - if (strcmp(arch, "noarch") && strcmp(arch, "i586") && strcmp(arch, "i686")) - break; - } -#endif + s->source = pd->source; if (!s->arch) s->arch = ARCH_NOARCH; if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) diff --git a/tools/source_susetags.c b/tools/source_susetags.c index 26830e1..215ea23 100644 --- a/tools/source_susetags.c +++ b/tools/source_susetags.c @@ -240,6 +240,7 @@ pool_addsource_susetags(Pool *pool, FILE *fp) memset(deps + pack, 0, (PACK_BLOCK + 1) * sizeof(struct deps)); } s = pool->solvables + source->start + pack; + s->source = source; dp = deps + pack; pack++; if (split(line + 5, sp, 5) != 4) -- 2.34.1