]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add POOL_FLAG_WHATPROVIDESWITHDISABLED pool flag
authorMichael Schroeder <mls@suse.de>
Mon, 30 Sep 2019 12:35:57 +0000 (14:35 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 30 Sep 2019 12:35:57 +0000 (14:35 +0200)
This makes libsolv keep disabled packages (i.e. packages
not in the considered map) in the whatprovides hash.

It is useful if you want to modify the considered map after
the whatprovides hash is generated.

Note that using the flag will change the reported problems
as disabled packages are now seen by the solver but
considered uninstallable.

ext/testcase.c
src/policy.c
src/pool.c
src/pool.h
src/repo.h
src/rules.c

index fcebcfa383fcfc454278b20b71fc81437f32af11..bd0643a8a8a5d8bf547f3c39ea3fa14c3721b6a7 100644 (file)
@@ -152,6 +152,7 @@ static struct poolflags2str {
   { POOL_FLAG_NOOBSOLETESMULTIVERSION,      "noobsoletesmultiversion", 0 },
   { POOL_FLAG_ADDFILEPROVIDESFILTERED,      "addfileprovidesfiltered", 0 },
   { POOL_FLAG_NOWHATPROVIDESAUX,            "nowhatprovidesaux", 0 },
+  { POOL_FLAG_WHATPROVIDESWITHDISABLED,     "whatprovideswithdisabled", 0 },
   { 0, 0, 0 }
 };
 
index 823a00878e9c7534da3a503b6e88eef48a086432..10a2c4df6a0c34e3da0eb717e4a01de01e975ad5 100644 (file)
@@ -1579,6 +1579,8 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all)
        continue;
 
       ps = pool->solvables + p;
+      if (pool->considered && pool->whatprovideswithdisabled && ps->repo != pool->installed && pool_disabled_solvable(pool, ps)) 
+       continue;
       if (s->name == ps->name) /* name match */
        {
          if (pool->implicitobsoleteusescolors && !pool_colormatch(pool, s, ps))
index 4b6372784989ccdd4e4b533807f2a34e26177b74..d2053b9c8cb6675c520eeb243ec29f8ba7573af0 100644 (file)
@@ -202,6 +202,8 @@ pool_get_flag(Pool *pool, int flag)
       return pool->addfileprovidesfiltered;
     case POOL_FLAG_NOWHATPROVIDESAUX:
       return pool->nowhatprovidesaux;
+    case POOL_FLAG_WHATPROVIDESWITHDISABLED:
+      return pool->whatprovideswithdisabled;
     default:
       break;
     }
@@ -247,6 +249,9 @@ pool_set_flag(Pool *pool, int flag, int value)
     case POOL_FLAG_NOWHATPROVIDESAUX:
       pool->nowhatprovidesaux = value;
       break;
+    case POOL_FLAG_WHATPROVIDESWITHDISABLED:
+      pool->whatprovideswithdisabled = value;
+      break;
     default:
       break;
     }
@@ -473,9 +478,7 @@ pool_createwhatprovides(Pool *pool)
       s = pool->solvables + i;
       if (!s->provides || !s->repo || s->repo->disabled)
        continue;
-      /* we always need the installed solvable in the whatprovides data,
-         otherwise obsoletes/conflicts on them won't work */
-      if (s->repo != installed && !pool_installable(pool, s))
+      if (!pool_installable_whatprovides(pool, s))
        continue;
       pp = s->repo->idarraydata + s->provides;
       while ((id = *pp++) != 0)
@@ -534,9 +537,8 @@ pool_createwhatprovides(Pool *pool)
       s = pool->solvables + i;
       if (!s->provides || !s->repo || s->repo->disabled)
        continue;
-      if (s->repo != installed && !pool_installable(pool, s))
+      if (!pool_installable_whatprovides(pool, s))
        continue;
-
       /* for all provides of this solvable */
       pp = s->repo->idarraydata + s->provides;
       while ((id = *pp++) != 0)
@@ -963,7 +965,7 @@ pool_addstdproviders(Pool *pool, Id d)
        * and those should not use filelist entries */
       if (s->repo->disabled)
        continue;
-      if (s->repo != pool->installed && !pool_installable(pool, s))
+      if (!pool_installable_whatprovides(pool, s))
        continue;
       queue_push(&q, di.solvid);
     }
@@ -1243,7 +1245,7 @@ pool_addrelproviders(Pool *pool, Id d)
              FOR_POOL_SOLVABLES(p)
                {
                  Solvable *s = pool->solvables + p;
-                 if (s->repo != pool->installed && !pool_installable(pool, s))
+                 if (!pool_installable_whatprovides(pool, s))
                    continue;
                  if (s->arch == evr)
                    queue_push(&plist, p);
index c90c29ae91529f23b1dd18cdebc14872a25e170d..aa173ea171cc0e67ca0f7563ee806a32356aeb78 100644 (file)
@@ -166,6 +166,7 @@ struct s_Pool {
   Id *whatprovidesauxdata;
   Offset whatprovidesauxdataoff;
 
+  int whatprovideswithdisabled;
 #endif
 };
 
@@ -204,6 +205,7 @@ struct s_Pool {
 #define POOL_FLAG_ADDFILEPROVIDESFILTERED              9
 #define POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS           10
 #define POOL_FLAG_NOWHATPROVIDESAUX                    11
+#define POOL_FLAG_WHATPROVIDESWITHDISABLED             12
 
 /* ----------------------------------------------- */
 
index 58704f16724acbc35f6ff23fd7fe7c5dc42b3cf3..9a5e9818d4cbe0f52b05919d1814f0141092c589 100644 (file)
@@ -123,6 +123,26 @@ static inline int pool_installable(const Pool *pool, Solvable *s)
   return 1;
 }
 
+#ifdef LIBSOLV_INTERNAL
+static inline int pool_installable_whatprovides(const Pool *pool, Solvable *s)
+{
+  /* we always need the installed solvable in the whatprovides data,
+     otherwise obsoletes/conflicts on them won't work */
+  if (s->repo != pool->installed)
+    {
+      if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC || pool_badarch_solvable(pool, s))
+       return 0;
+      if (pool->considered && !pool->whatprovideswithdisabled)
+       {
+         Id id = s - pool->solvables;
+         if (!MAPTST(pool->considered, id))
+           return 0;
+       }
+    }
+  return 1;
+}
+#endif
+
 /* not in solvable.h because we need the repo definition */
 static inline Solvable *solvable_free(Solvable *s, int reuseids)
 {
index 3aef6ee524687218bbe21e1a05e7fce1c19ef725..4075b9d021089ed7c103158a828dfc60b8931e29 100644 (file)
@@ -3323,6 +3323,21 @@ prune_best_update(Solver *solv, Id p, Queue *q)
   policy_filter_unwanted(solv, q, POLICY_MODE_RECOMMEND);
 }
 
+static void
+prune_disabled(Pool *pool, Queue *q)
+{
+  int i, j;
+  for (i = j = 0; i < q->count; i++)
+    {
+      Id p = q->elements[i];
+      Solvable *s = pool->solvables + p;
+      if (s->repo && s->repo != pool->installed && !MAPTST(pool->considered, p))
+       continue;
+      q->elements[j++] = p;
+    }
+  queue_truncate(q, j);
+}
+
 void
 solver_addbestrules(Solver *solv, int havebestinstalljobs, int haslockjob)
 {
@@ -3377,6 +3392,8 @@ solver_addbestrules(Solver *solv, int havebestinstalljobs, int haslockjob)
                      else if (p2 < 0)
                        queue_push(&q2, p2);
                    }
+                 if (pool->considered && pool->whatprovideswithdisabled)
+                   prune_disabled(pool, &q);
                  if (!q.count)
                    continue;   /* orphaned */
                  /* select best packages, just look at prio and version */
@@ -3386,6 +3403,8 @@ solver_addbestrules(Solver *solv, int havebestinstalljobs, int haslockjob)
                    continue;   /* nothing filtered */
                  if (lockedmap)
                    {
+                     queue_insertn(&q, 0, q2.count, q2.elements);
+                     queue_empty(&q2);
                      FOR_RULELITERALS(p2, pp2, r)
                        {
                          if (p2 <= 0)
@@ -3399,9 +3418,12 @@ solver_addbestrules(Solver *solv, int havebestinstalljobs, int haslockjob)
                            continue;
                          queue_push(&q2, p2);
                        }
+                     if (pool->considered && pool->whatprovideswithdisabled)
+                       prune_disabled(pool, &q2);
                      policy_filter_unwanted(solv, &q2, POLICY_MODE_RECOMMEND);
                      for (k = 0; k < q2.count; k++)
                        queue_pushunique(&q, q2.elements[k]);
+                     queue_empty(&q2);
                    }
                  if (q2.count)
                    queue_insertn(&q, 0, q2.count, q2.elements);