Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7535 - in /trunk/sat-solver/src: bitmap.c solver.c solver.h
  • From: mlschroe@xxxxxxxxxxxxxxxx
  • Date: Mon, 15 Oct 2007 11:06:02 -0000
  • Message-id: <20071015110602.CF9BD45688@xxxxxxxxxxxxxxxx>
Author: mlschroe
Date: Mon Oct 15 13:06:02 2007
New Revision: 7535

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7535&view=rev
Log:
make prune_to_recommended look at recommends, too.

Modified:
    trunk/sat-solver/src/bitmap.c
    trunk/sat-solver/src/solver.c
    trunk/sat-solver/src/solver.h

Modified: trunk/sat-solver/src/bitmap.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/bitmap.c?rev=7535&r1=7534&r2=7535&view=diff
==============================================================================
--- trunk/sat-solver/src/bitmap.c (original)
+++ trunk/sat-solver/src/bitmap.c Mon Oct 15 13:06:02 2007
@@ -7,20 +7,20 @@
 #include <string.h>
 
 #include "bitmap.h"
+#include "util.h"
 
 void
 mapinit(Map *m, int n)
 {
   m->size = (n + 7) >> 3;
-  m->map = calloc(m->size, 1);
+  m->map = xcalloc(m->size, 1);
 }
 
 // free space allocated
 void
 mapfree(Map *m)
 {
-  free(m->map);
-  m->map = 0;
+  m->map = xfree(m->map);
   m->size = 0;
 }
 
@@ -29,7 +29,7 @@
 clonemap(Map *t, Map *s)
 {
   t->size = s->size;
-  t->map = malloc(s->size);
+  t->map = xmalloc(s->size);
   memcpy(t->map, s->map, t->size);
 }
 

Modified: trunk/sat-solver/src/solver.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=7535&r1=7534&r2=7535&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Mon Oct 15 13:06:02 2007
@@ -117,11 +117,34 @@
   Pool *pool = solv->pool;
   int i, j;
   Solvable *s;
-  Id sup, *supp;
+  Id p, *pp, sup, *supp, rec, *recp;
 
+  if (solv->recommends_index < 0)
+    {
+      MAPZERO(&solv->recommends);
+      solv->recommends_index = 0;
+    }
+  while (solv->recommends_index < solv->decisionq.count)
+    {
+      p = solv->decisionq.elements[solv->recommends_index++];
+      if (p < 0)
+       continue;
+      s = pool->solvables + p;
+      if (!(recp = s->recommends))
+       continue;
+      while ((rec = *recp++) != 0)
+       FOR_PROVIDES(p, pp, rec)
+         MAPSET(&solv->recommends, p);
+    }
   for (i = j = 0; i < plist->count; i++)
     {
-      s = pool->solvables + plist->elements[i];
+      p = plist->elements[i];
+      if (MAPTST(&solv->recommends, p))
+       {
+         plist->elements[j++] = p;
+         continue;
+       }
+      s = pool->solvables + p;
       if (!s->supplements && !s->freshens)
        continue;
       if ((supp = s->supplements) != 0)
@@ -621,10 +644,8 @@
            return r;
          /* direct conflict! */
          for (i = 0; i < solv->decisionq.count; i++)
-         {
            if (solv->decisionq.elements[i] == -p)
              break;
-         }
          if (i == solv->decisionq.count)
            abort();
          if (solv->decisionq_why.elements[i] == 0)
@@ -1362,6 +1383,7 @@
 
   solv->decisionq_why.count = i;
   solv->decisionq.count = i;
+  solv->recommends_index = -1;
   if (i < solv->propagate_index)
     solv->propagate_index = i;
   /* make direct decisions from enabled unary rules */
@@ -1542,6 +1564,7 @@
       solv->decisionq_why.count--;
       solv->propagate_index = solv->decisionq.count;
     }
+  solv->recommends_index = -1;
 }
 
 
@@ -1669,6 +1692,9 @@
   queueinit(&solv->learnt_why);
   queueinit(&solv->learnt_pool);
 
+  mapinit(&solv->recommends, pool->nsolvables);
+  solv->recommends_index = 0;
+
   solv->decisionmap = (Id *)xcalloc(pool->nsolvables, sizeof(Id));
   solv->rules = (Rule *)xmalloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule));
   memset(solv->rules, 0, sizeof(Rule));
@@ -1689,6 +1715,7 @@
   queuefree(&solv->decisionq_why);
   queuefree(&solv->learnt_why);
   queuefree(&solv->learnt_pool);
+  mapfree(&solv->recommends);
   xfree(solv->decisionmap);
   xfree(solv->rules);
   xfree(solv->watches);

Modified: trunk/sat-solver/src/solver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.h?rev=7535&r1=7534&r2=7535&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.h (original)
+++ trunk/sat-solver/src/solver.h Mon Oct 15 13:06:02 2007
@@ -10,6 +10,7 @@
 #include "pool.h"
 #include "source.h"
 #include "queue.h"
+#include "bitmap.h"
 
 /* ----------------------------------------------
  * Rule
@@ -40,32 +41,32 @@
   Pool *pool;
   Source *system;
 
-  int fixsystem;                      /* repair errors in rpm dependency graph */
-  int allowdowngrade;                 /* allow to downgrade installed solvable */
-  int allowarchchange;                /* allow to change architecture of installed solvables */
-  int allowuninstall;                 /* allow removal of system solvables, else keep all installed solvables */
-  int updatesystem;                   /* distupgrade */
-  int allowvirtualconflicts;           /* false: conflicts on package name, true: conflicts on package provides */
+  int fixsystem;                       /* repair errors in rpm dependency graph */
+  int allowdowngrade;                  /* allow to downgrade installed solvable */
+  int allowarchchange;                 /* allow to change architecture of installed solvables */
+  int allowuninstall;                  /* allow removal of system solvables, else keep all installed solvables */
+  int updatesystem;                    /* distupgrade */
+  int allowvirtualconflicts;           /* false: conflicts on package name, true: conflicts on package provides */
   
-  Rule *rules;                        /* all rules */
-  Id nrules;                          /* rpm rules */
+  Rule *rules;                         /* all rules */
+  Id nrules;                           /* rpm rules */
 
-  Id jobrules;                        /* user rules */
-  Id systemrules;                     /* policy rules, e.g. keep packages installed or update. All literals > 0 */
-  Id learntrules;                     /* learnt rules */
-
-  Id *weaksystemrules;                 /* please try to install (r->d) */
-
-  Id *watches;                        /* Array of rule offsets
-                                       * watches has nsolvables*2 entries and is addressed from the middle
-                                       * middle-solvable : decision to conflict, offset point to linked-list of rules
-                                       * middle+solvable : decision to install: offset point to linked-list of rules
-                                       */
+  Id jobrules;                         /* user rules */
+  Id systemrules;                      /* policy rules, e.g. keep packages installed or update. All literals > 0 */
+  Id learntrules;                      /* learnt rules */
+
+  Id *weaksystemrules;                 /* please try to install (r->d) */
+
+  Id *watches;                         /* Array of rule offsets
+                                        * watches has nsolvables*2 entries and is addressed from the middle
+                                        * middle-solvable : decision to conflict, offset point to linked-list of rules
+                                        * middle+solvable : decision to install: offset point to linked-list of rules
+                                        */
 
   /* our decisions: */
   Queue decisionq;
-  Queue decisionq_why;                /* index of rule, Offset into rules */
-  Id *decisionmap;                    /* map for all available solvables, > 0: level of decision when installed, < 0 level of decision when conflict */
+  Queue decisionq_why;                 /* index of rule, Offset into rules */
+  Id *decisionmap;                     /* map for all available solvables, > 0: level of decision when installed, < 0 level of decision when conflict */
 
   /* learnt rule history */
   Queue learnt_why;
@@ -75,7 +76,10 @@
 
   Queue problems;
 
-  int rc_output;                      /* output result compatible to redcarpet/zypp testsuite, set == 2 for pure rc (will suppress architecture) */
+  Map recommends;                      /* recommended packages from decisionmap */
+  int recommends_index;                        /* recommended level */
+
+  int rc_output;                       /* output result compatible to redcarpet/zypp testsuite, set == 2 for pure rc (will suppress architecture) */
 } Solver;
 
 /*

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages