make FOR_RULELITERALS safe against whatprovides realloc
[platform/upstream/libsolv.git] / src / solver.h
index 033956c..5e3a162 100644 (file)
@@ -113,6 +113,10 @@ struct _Solver {
   Id duprules;                         /* dist upgrade rules */
   Id duprules_end;
     
+  Id bestrules;                                /* rules from SOLVER_FORCEBEST */
+  Id bestrules_end;
+  Id *bestrules_pkg;
+
   Id choicerules;                      /* choice rules (always weak) */
   Id choicerules_end;
   Id *choicerules_ref;
@@ -126,6 +130,9 @@ struct _Solver {
   Map updatemap;                       /* bring these installed packages to the newest version */
   int updatemap_all;                   /* bring all packages to the newest version */
 
+  Map bestupdatemap;                   /* create best rule for those packages */
+  int bestupdatemap_all;               /* bring all packages to the newest version */
+
   Map fixmap;                          /* fix these packages */
   int fixmap_all;                      /* fix all packages */
 
@@ -183,6 +190,7 @@ struct _Solver {
    *-------------------------------------------------------------------------------------------------------------*/
 
   int allowdowngrade;                  /* allow to downgrade installed solvable */
+  int allownamechange;                 /* allow to change name of installed solvables */
   int allowarchchange;                 /* allow to change architecture of installed solvables */
   int allowvendorchange;               /* allow to change vendor of installed solvables */
   int allowuninstall;                  /* allow removal of installed solvables */
@@ -193,12 +201,15 @@ struct _Solver {
   int dontshowinstalledrecommended;    /* true: do not show recommended packages that are already installed */
   
   int noinfarchcheck;                  /* true: do not forbid inferior architectures */
+  int keepexplicitobsoletes;           /* true: honor obsoletes during multiinstall */
+  int bestobeypolicy;                  /* true: stay in policy with the best rules */
 
     
   Map dupmap;                          /* dup these packages*/
   int dupmap_all;                      /* dup all packages */
   Map dupinvolvedmap;                  /* packages involved in dup process */
   int dup_allowdowngrade;              /* dup mode: allow to downgrade installed solvable */
+  int dup_allownamechange;             /* dup mode: allow to change name of installed solvable */
   int dup_allowarchchange;             /* dup mode: allow to change architecture of installed solvables */
   int dup_allowvendorchange;           /* dup mode: allow to change vendor of installed solvables */
 
@@ -211,6 +222,8 @@ struct _Solver {
 
   Queue *cleandeps_updatepkgs;         /* packages we update in cleandeps mode */
   Queue *cleandeps_mistakes;           /* mistakes we made */
+
+  Queue *update_targets;               /* update to specific packages */
 #endif /* LIBSOLV_INTERNAL */
 };
 
@@ -246,6 +259,14 @@ typedef struct _Solver Solver;
 #define SOLVER_WEAK                    0x010000
 #define SOLVER_ESSENTIAL               0x020000
 #define SOLVER_CLEANDEPS                0x040000
+/* ORUPDATE makes SOLVER_INSTALL not prune to installed
+ * packages, thus updating installed packages */
+#define SOLVER_ORUPDATE                        0x080000
+/* FORCEBEST makes the solver insist on best packages, so
+ * you will get problem reported if the best package is
+ * not installable. This can be used with INSTALL, UPDATE
+ * and DISTUPGRADE */
+#define SOLVER_FORCEBEST               0x100000
 
 #define SOLVER_SETEV                   0x01000000
 #define SOLVER_SETEVR                  0x02000000
@@ -253,8 +274,9 @@ typedef struct _Solver Solver;
 #define SOLVER_SETVENDOR               0x08000000
 #define SOLVER_SETREPO                 0x10000000
 #define SOLVER_NOAUTOSET               0x20000000
+#define SOLVER_SETNAME                 0x40000000
 
-#define SOLVER_SETMASK                 0x2f000000
+#define SOLVER_SETMASK                 0x7f000000
 
 #define SOLVER_REASON_UNRELATED                0
 #define SOLVER_REASON_UNIT_RULE                1
@@ -279,6 +301,9 @@ typedef struct _Solver Solver;
 #define SOLVER_FLAG_IGNORE_RECOMMENDED         7
 #define SOLVER_FLAG_ADD_ALREADY_RECOMMENDED    8
 #define SOLVER_FLAG_NO_INFARCHCHECK            9
+#define SOLVER_FLAG_ALLOW_NAMECHANGE           10
+#define SOLVER_FLAG_KEEP_EXPLICIT_OBSOLETES    11
+#define SOLVER_FLAG_BEST_OBEY_POLICY           12
 
 extern Solver *solver_create(Pool *pool);
 extern void solver_free(Solver *solv);
@@ -310,15 +335,20 @@ void solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps);
 int solver_calc_installsizechange(Solver *solv);
 void solver_trivial_installable(Solver *solv, Queue *pkgs, Queue *res);
 
-void solver_find_involved(Solver *solv, Queue *installedq, Solvable *s, Queue *q);
+void pool_job2solvables(Pool *pool, Queue *pkgs, Id how, Id what);
+int  pool_isemptyupdatejob(Pool *pool, Id how, Id what);
 
 /* iterate over all literals of a rule */
-/* WARNING: loop body must not relocate whatprovidesdata, e.g. by
- * looking up the providers of a dependency */
-#define FOR_RULELITERALS(l, dp, r)                             \
-    for (l = r->d < 0 ? -r->d - 1 : r->d,                      \
-         dp = !l ? &r->w2 : pool->whatprovidesdata + l,                \
-         l = r->p; l; l = (dp != &r->w2 + 1 ? *dp++ : 0))
+#define FOR_RULELITERALS(l, pp, r)                             \
+    for (pp = r->d < 0 ? -r->d - 1 : r->d,                     \
+         l = r->p; l; l = (pp <= 0 ? (pp-- ? 0 : r->w2) :      \
+         pool->whatprovidesdata[pp++]))
+
+
+
+
+/* XXX: this currently doesn't work correctly for SOLVER_SOLVABLE_REPO and
+   SOLVER_SOLVABLE_ALL */
 
 /* iterate over all packages selected by a job */
 #define FOR_JOB_SELECT(p, pp, select, what)                                    \
@@ -327,8 +357,12 @@ void solver_find_involved(Solver *solv, Queue *installedq, Solvable *s, Queue *q
     else for (pp = (select == SOLVER_SOLVABLE ? 0 :                            \
                select == SOLVER_SOLVABLE_ONE_OF ? what :                       \
                pool_whatprovides(pool, what)),                                 \
-         p = (select == SOLVER_SOLVABLE ? what : pool->whatprovidesdata[pp++]) ; p ; p = pool->whatprovidesdata[pp++]) \
-      if (select != SOLVER_SOLVABLE_NAME || pool_match_nevr(pool, pool->solvables + p, what))
+         p = (select == SOLVER_SOLVABLE ? what : pool->whatprovidesdata[pp++]); \
+                                        p ; p = pool->whatprovidesdata[pp++])  \
+      if (select == SOLVER_SOLVABLE_NAME &&                                    \
+                       pool_match_nevr(pool, pool->solvables + p, what) == 0)  \
+       continue;                                                               \
+      else
 
 #ifdef __cplusplus
 }