]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Do not autouninstall packages because of forcebest updates
authorMichael Schroeder <mls@suse.de>
Fri, 30 Nov 2018 14:05:33 +0000 (15:05 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 30 Nov 2018 14:05:33 +0000 (15:05 +0100)
src/problems.c
test/testcases/allowuninstall/forcebest.t [new file with mode: 0644]

index 68ff61d7ba34b7f14238f5beb42cf62a21672823..2b5cefda3ca00956ec7057eeebd1f73b51632bd4 100644 (file)
@@ -247,10 +247,23 @@ solver_autouninstall(Solver *solv, int start)
       if (v >= solv->updaterules && v < solv->updaterules_end)
        {
          Rule *r;
+         Id p = solv->installed->start + (v - solv->updaterules);
          if (m && !MAPTST(m, v - solv->updaterules))
            continue;
-         if (pool->considered && !MAPTST(pool->considered, solv->installed->start + (v - solv->updaterules)))
+         if (pool->considered && !MAPTST(pool->considered, p))
            continue;   /* do not uninstalled disabled packages */
+         if (solv->bestrules_pkg && solv->bestrules_end > solv->bestrules)
+           {
+             int j;
+             for (j = start + 1; j < solv->problems.count - 1; j++)
+               {
+                 Id vv = solv->problems.elements[j];
+                 if (vv >= solv->bestrules && vv < solv->bestrules_end && solv->bestrules_pkg[vv - solv->bestrules] == p)
+                   break;
+               }
+             if (j < solv->problems.count - 1)
+               continue;       /* best rule involved, do not uninstall */
+           }
          /* check if identical to feature rule, we don't like that (except for orphans) */
          r = solv->rules + solv->featurerules + (v - solv->updaterules);
          if (!r->p)
@@ -262,7 +275,7 @@ solver_autouninstall(Solver *solv, int start)
              if (solv->keep_orphans)
                {
                  r = solv->rules + v;
-                 if (!r->d && !r->w2 && r->p == (solv->installed->start + (v - solv->updaterules)))
+                 if (!r->d && !r->w2 && r->p == p)
                    {
                      lastfeature = v;
                      lastupdate = 0;
diff --git a/test/testcases/allowuninstall/forcebest.t b/test/testcases/allowuninstall/forcebest.t
new file mode 100644 (file)
index 0000000..38ade6f
--- /dev/null
@@ -0,0 +1,19 @@
+repo system 0 testtags <inline>
+#>=Pkg: a 1 1 noarch
+#>=Req: b = 1-1
+#>=Pkg: b 1 1 noarch
+repo available 0 testtags <inline>
+#>=Pkg: a 2 1 noarch
+#>=Req: b = 2-1
+#>=Pkg: b 2 1 noarch
+
+system x86_64 rpm system
+disable pkg b-1-1.noarch@system
+disable pkg b-2-1.noarch@available
+job allowuninstall pkg a-1-1.noarch@system
+job allowuninstall pkg b-1-1.noarch@system
+job update name a [forcebest]
+result transaction,problems <inline>
+#>problem e6d3911d info nothing provides b = 2-1 needed by a-2-1.noarch
+#>problem e6d3911d solution 0011b04f allow a-1-1.noarch@system
+#>problem e6d3911d solution 44d189a0 erase a-1-1.noarch@system