- add support for namespace callbacks
authorMichael Schroeder <mls@suse.de>
Thu, 25 Oct 2007 16:42:16 +0000 (16:42 +0000)
committerMichael Schroeder <mls@suse.de>
Thu, 25 Oct 2007 16:42:16 +0000 (16:42 +0000)
- implement rpmlib test in relation expansion
- implement modalias() globbing

src/pool.c
src/pool.h
src/solver.c

index 24362b7..4ccddc4 100644 (file)
@@ -53,6 +53,7 @@ static char *initpool_data[] = {
   "solvable:filemarker",
   "namespace:installed",
   "namespace:modalias",
+  "system:system",
   "src",
   "nosrc",
   "noarch"
@@ -65,6 +66,7 @@ pool_create(void)
 {
   int count, totalsize = 0;
   Pool *pool;
+  Solvable *s;
 
   pool = (Pool *)xcalloc(1, sizeof(*pool));
 
@@ -91,9 +93,12 @@ pool_create(void)
   pool->nrels = 1;
 
   // pre-alloc space for a Solvable
-  pool->solvables = (Solvable *)xcalloc(1, sizeof(Solvable));
-  pool->nsolvables = 1;
-
+  pool->solvables = (Solvable *)xcalloc(2, sizeof(Solvable));
+  pool->nsolvables = 2;
+  s = pool->solvables + SYSTEMSOLVABLE;
+  s->name = SYSTEM_SYSTEM;
+  s->arch = ARCH_NOARCH;
+  s->evr = ID_EMPTY;
   return pool;
 }
 
@@ -350,6 +355,7 @@ pool_prepare(Pool *pool)
   pool_shrink_whatprovides(pool);
 }
 
+
 /******************************************************************************/
 
 /*
@@ -392,6 +398,8 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)
 }
 
 
+/******************************************************************************/
+
 /*
  * addrangedep
  * 
@@ -440,12 +448,18 @@ pool_addrelproviders(Pool *pool, Id d)
        queuepushunique(&plist, p);
       break;
     case REL_NAMESPACE:
-#if 0
-      /* unknown namespace, just pass through */
-      pp = GET_PROVIDESP(evr, p);
-      while ((p = *pp++) != 0)
-       queuepush(&plist, p);
-#endif
+      if (pool->nscallback)
+       {
+         p = pool->nscallback(pool, pool->nscallbackdata, name, evr);
+         if (p > 1)
+           {
+             queuefree(&plist);
+             pool->whatprovides[d] = p;
+             return pool->whatprovidesdata + p;
+           }
+         if (p == 1)
+           queuepush(&plist, SYSTEMSOLVABLE);
+       }
       break;
     default:
       break;
@@ -503,6 +517,9 @@ pool_addrelproviders(Pool *pool, Id d)
            continue;   /* no rel match */
          queuepush(&plist, p);
        }
+      /* make our system solvable provide all unknown rpmlib() stuff */
+      if (plist.count == 0 && !strncmp(id2str(pool, name), "rpmlib(", 7))
+       queuepush(&plist, SYSTEMSOLVABLE);
     }
   /* add providers to whatprovides */
 #if 0
index 509ba4f..1a5ec5d 100644 (file)
@@ -43,9 +43,13 @@ typedef _Bool bool;
 #define SOLVABLE_FILEMARKER    16              // normal provides before this, generated file provides after this
 #define NAMESPACE_INSTALLED    17
 #define NAMESPACE_MODALIAS     18
-#define ARCH_SRC               19
-#define ARCH_NOSRC             20
-#define ARCH_NOARCH            21
+#define SYSTEM_SYSTEM          19
+#define ARCH_SRC               20
+#define ARCH_NOSRC             21
+#define ARCH_NOARCH            22
+
+/* well known solvable */
+#define SYSTEMSOLVABLE         1
 
 //-----------------------------------------------
 
@@ -84,6 +88,9 @@ struct _Pool {
   Id *whatprovidesdata;                /* Ids of solvable providing Id */
   Offset whatprovidesdataoff;  /* next free slot within whatprovidesdata */
   int whatprovidesdataleft;    /* number of 'free slots' within whatprovidesdata */
+
+  Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
+  void *nscallbackdata;
 };
 
 #define TYPE_ID                        1
index 40012b0..059df13 100644 (file)
@@ -850,12 +850,6 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
 
              dp = GET_PROVIDESP(req, p);      /* get providers of req */
 
-             if (!*dp                       /* dont care if noone provides rpmlib() */
-                 && !strncmp(id2str(pool, req), "rpmlib(", 7))
-               {
-                 continue;
-               }
-
              if (dontfix)             /* dont care about breakage */
                {
                  /* the strategy here is to not insist on dependencies
@@ -2404,6 +2398,8 @@ printdecisions(Solver *solv)
       n = solv->decisionq.elements[i];
       if (n < 0)
        continue;
+      if (n == SYSTEMSOLVABLE)
+       continue;
       if (n >= solv->system->start && n < solv->system->start + solv->system->nsolvables)
        continue;
       s = pool->solvables + n;
@@ -2462,6 +2458,8 @@ printdecisions(Solver *solv)
       p = solv->decisionq.elements[i];
       if (p < 0)
        continue;
+      if (p == SYSTEMSOLVABLE)
+       continue;
       if (p >= solv->system->start && p < solv->system->start + solv->system->nsolvables)
        continue;
       s = pool->solvables + p;
@@ -2631,6 +2629,14 @@ solve(Solver *solv, Queue *job)
   queueinit(&q);
 
   /*
+   * always install our system solvable
+   */
+  MAPSET(&addedmap, SYSTEMSOLVABLE);
+  queuepush(&solv->decisionq, SYSTEMSOLVABLE);
+  queuepush(&solv->decisionq_why, 0);
+  solv->decisionmap[SYSTEMSOLVABLE] = 1;
+
+  /*
    * create rules for installed solvables -> keep them installed
    * so called: rpm rules
    *