- 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 495c3e7caf5c4f93c7933e553122a37af1e58bb5..5f1d844f3b7e975a1314809e791b8ae8eb0bcb50 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 e5c71ecd7eb29e8f712c1efbf90797910200e3af..509ba4f3da5fb9a287234cc0c23d9c4e91f25e0a 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 aaecd710a522fae754b5f2db309315bd5e666d2d..48402985a5150b11b493c5aa3a88d730ea85be26 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 0f592a34183c3fbefc4e1ea08df24f5a3f71a43b..a254046f38ae7edcf9b46f18d022a80d35e4279d 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 2d6ddd6f95a3e66a9d54b40a678b8f49934f5ce9..706d3b9942007ffd3ac21c443e8c3eacfed987aa 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 c939ca8001aef0a7fb71f4bd835f5b6d83cedfb1..a89be60f7035bdc7c2965e4696352c29c23b4d28 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 b879c73937d9a01f4710893f6297b8db6e6d8b5a..5b1bad120256906d12371c73ac2cd8bc4c910b99 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 1f62c567bef07821f8d2d1201fc67e6ca0517d99..38d3f698f638a0b86869d6bfff7bac045fe038a0 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 6ffd339c9d1d8a5fbea9f76025c7ae770c0276d7..b3f4d494b11fca41b34164bfde607578e5992b91 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 c342c02dd25152c3fd96db16e1d9615f193e3678..d18e0686bb97b37c07547749e3516898fb7cb13f 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 26830e1c515b0bde31a12d0f193a962db39da713..215ea23a48bcd2b848f53ff36cfb7551c120e8cf 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)