]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
cleanup code now that the vendorcheck callback is in the pool
authorMichael Schroeder <mls@suse.de>
Wed, 6 Mar 2013 17:35:44 +0000 (18:35 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 6 Mar 2013 17:35:44 +0000 (18:35 +0100)
src/pool.h
src/solvable.c
src/solver.c

index 482aefb4cb6bfecbd99f0cf61cb01420b344d7ae..8e1a951db4d1d1d931b0021a2f2f2ea2c40d2822 100644 (file)
@@ -266,8 +266,7 @@ Id pool_id2langid(Pool *pool, Id id, const char *lang, int create);
 int solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap, Map *noobsoletesmap);
 int solvable_trivial_installable_repo(Solvable *s, struct _Repo *installed, Map *noobsoletesmap);
 int solvable_trivial_installable_queue(Solvable *s, Queue *installed, Map *noobsoletesmap);
-struct _Solver; /* argh, needed for vendorchange callback FIXME */
-int solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, struct _Solver *solv);
+int solvable_is_irrelevant_patch(Solvable *s, Map *installedmap);
 
 void pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap);
 
index 45945443211ad8fa26380eaabd5e5cd4ed899646..7ac79eee3582aec844907e4759db4cedd0610b7d 100644 (file)
@@ -462,7 +462,7 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm
        {
          if (providedbyinstalled(pool, installedmap, con, ispatch, noobsoletesmap))
            {
-             if (ispatch && solvable_is_irrelevant_patch(s, installedmap, 0))
+             if (ispatch && solvable_is_irrelevant_patch(s, installedmap))
                return -1;
              return 0;
            }
@@ -473,7 +473,7 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm
                interesting = 1;
            }
        }
-      if (ispatch && interesting && solvable_is_irrelevant_patch(s, installedmap, 0))
+      if (ispatch && interesting && solvable_is_irrelevant_patch(s, installedmap))
        interesting = 0;
     }
 #if 0
@@ -575,11 +575,33 @@ solvable_trivial_installable_repo(Solvable *s, Repo *installed, Map *noobsoletes
   return r;
 }
 
+/* FIXME: this mirrors policy_illegal_vendorchange */
+static int
+pool_illegal_vendorchange(Pool *pool, Solvable *s1, Solvable *s2)
+{
+  Id v1, v2; 
+  Id vendormask1, vendormask2;
+
+  if (pool->custom_vendorcheck)
+    return pool->custom_vendorcheck(pool, s1, s2);
+  /* treat a missing vendor as empty string */
+  v1 = s1->vendor ? s1->vendor : ID_EMPTY;
+  v2 = s2->vendor ? s2->vendor : ID_EMPTY;
+  if (v1 == v2) 
+    return 0;
+  vendormask1 = pool_vendor2mask(pool, v1);
+  if (!vendormask1)
+    return 1;   /* can't match */
+  vendormask2 = pool_vendor2mask(pool, v2);
+  if ((vendormask1 & vendormask2) != 0)
+    return 0;
+  return 1;     /* no class matches */
+}
 
 /* check if this patch is relevant according to the vendor. To bad that patches
  * don't have a vendor, so we need to do some careful repo testing. */
 int
-solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, Solver *solv)
+solvable_is_irrelevant_patch(Solvable *s, Map *installedmap)
 {
   Pool *pool = s->repo->pool;
   Id con, *conp;
@@ -618,23 +640,8 @@ solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, Solver *solv)
                  /* ok, we have a package from the patch repo that solves the conflict. check vendor */
                  if (si->vendor == s2->vendor)
                    return 0;
-                 /* FIXME: solv is only needed for the vendorchange callback */
-                 if (solv)
-                   {
-                     if (!policy_illegal_vendorchange(solv, si, s2))
-                       return 0;
-                   }
-                 else
-                   {
-                     Id v1 = si->vendor ? si->vendor : ID_EMPTY;
-                     Id v2 = s2->vendor ? s2->vendor : ID_EMPTY;
-                     if (v1 == v2)
-                       return 0;
-                     v1 = pool_vendor2mask(pool, v1);
-                     v2 = pool_vendor2mask(pool, v2);
-                     if ((v1 & v2) != 0)
-                       return 0;
-                   }
+                 if (!pool_illegal_vendorchange(pool, si, s2))
+                   return 0;
                  /* vendor change was illegal, ignore conflict */
                }
            }
index 38b53c22dc3fa564ad11050905adf5793bc15342..c1518db67995b23f4fc292a0cb082a1eae835b1c 100644 (file)
@@ -3911,7 +3911,7 @@ solver_trivial_installable(Solver *solv, Queue *pkgs, Queue *res)
     if (res->elements[i] != -1)
       {
        Solvable *s = pool->solvables + pkgs->elements[i];
-       if (!strncmp("patch:", pool_id2str(pool, s->name), 6) && solvable_is_irrelevant_patch(s, &installedmap, solv))
+       if (!strncmp("patch:", pool_id2str(pool, s->name), 6) && solvable_is_irrelevant_patch(s, &installedmap))
          res->elements[i] = -1;
       }
   map_free(&installedmap);