- first step in getting rid of dependency pointers:
authorMichael Schroeder <mls@suse.de>
Mon, 22 Oct 2007 18:01:35 +0000 (18:01 +0000)
committerMichael Schroeder <mls@suse.de>
Mon, 22 Oct 2007 18:01:35 +0000 (18:01 +0000)
  store back pointer to source in Solvable.

src/pool.c
src/pool.h
src/solvable.h
src/solver.c
src/source_solv.c
tools/source_content.c
tools/source_helix.c
tools/source_patchxml.c
tools/source_rpmdb.c
tools/source_rpmmd.c
tools/source_susetags.c

index 495c3e7..5f1d844 100644 (file)
@@ -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
index e5c71ec..509ba4f 100644 (file)
@@ -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)
index aaecd71..4840298 100644 (file)
@@ -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;
 
index 0f592a3..a254046 100644 (file)
@@ -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;
index 2d6ddd6..706d3b9 100644 (file)
@@ -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)
        {
index c939ca8..a89be60 100644 (file)
@@ -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++;
            }
index b879c73..5b1bad1 100644 (file)
@@ -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;
index 1f62c56..38d3f69 100644 (file)
@@ -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)
index 6ffd339..b3f4d49 100644 (file)
@@ -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)
index c342c02..d18e068 100644 (file)
@@ -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)
index 26830e1..215ea23 100644 (file)
@@ -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)