oops, fix last commit
[platform/upstream/libsolv.git] / src / solver.h
index 84ffb8e..5fa0a12 100644 (file)
 #ifndef LIBSOLV_SOLVER_H
 #define LIBSOLV_SOLVER_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "pooltypes.h"
 #include "pool.h"
 #include "repo.h"
@@ -26,15 +22,9 @@ extern "C" {
 #include "rules.h"
 #include "problems.h"
 
-/*
- * Callback definitions in order to "overwrite" the policies by an external application.
- */
-typedef void (*BestSolvableCb) (Pool *pool, Queue *canditates);
-typedef int  (*ArchCheckCb) (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-typedef int  (*VendorCheckCb) (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-typedef void (*UpdateCandidateCb) (Pool *pool, Solvable *solvable, Queue *canditates);
-
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 struct _Solver {
   Pool *pool;                          /* back pointer to pool */
@@ -43,44 +33,7 @@ struct _Solver {
   int (*solution_callback)(struct _Solver *solv, void *data);
   void *solution_callback_data;
 
-  /* Callbacks for defining the bahaviour of the solver */
-
-  /* Finding best candidate
-   *
-   * Callback definition:
-   * void  bestSolvable (Pool *pool, Queue *canditates)
-   *     candidates       : List of canditates which has to be sorted by the function call
-   *     return candidates: Sorted list of the candidates(first is the best).
-   */
-  BestSolvableCb bestSolvableCb;
-
-  /* Checking if two solvables has compatible architectures
-   *
-   * Callback definition:
-   *     int  archCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-   *     
-   *     return 0 it the two solvables has compatible architectures
-   */
-  ArchCheckCb archCheckCb;
-
-  /* Checking if two solvables has compatible vendors
-   *
-   * Callback definition:
-   *     int  vendorCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
-   *     
-   *     return 0 it the two solvables has compatible architectures
-   */
-  VendorCheckCb vendorCheckCb;
-    
-  /* Evaluate update candidate
-   *
-   * Callback definition:
-   * void UpdateCandidateCb (Pool *pool, Solvable *solvable, Queue *canditates)
-   *     solvable   : for which updates should be search
-   *     candidates : List of candidates (This list depends on other
-   *                  restrictions like architecture and vendor policies too)
-   */
-  UpdateCandidateCb   updateCandidateCb;
+  int pooljobcnt;                      /* number of pooljob entries in job queue */
 
 #ifdef LIBSOLV_INTERNAL
   Repo *installed;                     /* copy of pool->installed */
@@ -113,6 +66,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;
@@ -121,11 +78,14 @@ struct _Solver {
 
   Map noupdate;                                /* don't try to update these
                                            installed solvables */
-  Map noobsoletes;                     /* ignore obsoletes for these (multiinstall) */
+  Map multiversion;                    /* ignore obsoletes for these (multiinstall) */
 
   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 */
 
@@ -194,6 +154,9 @@ 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 */
+  int noautotarget;                    /* true: do not assume targeted for up/dup jobs that contain no installed solvable */
 
     
   Map dupmap;                          /* dup these packages*/
@@ -213,6 +176,12 @@ struct _Solver {
 
   Queue *cleandeps_updatepkgs;         /* packages we update in cleandeps mode */
   Queue *cleandeps_mistakes;           /* mistakes we made */
+
+  Queue *update_targets;               /* update to specific packages */
+
+  Queue *installsuppdepq;              /* deps from the install namespace provides hack */
+
+  Queue addedmap_deduceq;              /* deduce addedmap from rpm rules */
 #endif /* LIBSOLV_INTERNAL */
 };
 
@@ -236,7 +205,7 @@ typedef struct _Solver Solver;
 #define SOLVER_ERASE                   0x0200
 #define SOLVER_UPDATE                  0x0300
 #define SOLVER_WEAKENDEPS                      0x0400
-#define SOLVER_NOOBSOLETES             0x0500
+#define SOLVER_MULTIVERSION            0x0500
 #define SOLVER_LOCK                    0x0600
 #define SOLVER_DISTUPGRADE             0x0700
 #define SOLVER_VERIFY                  0x0800
@@ -248,6 +217,20 @@ 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
+/* TARGETED is used in up/dup jobs to make the solver
+ * treat the specified selection as target packages.
+ * It is automatically assumed if the selection does not
+ * contain an "installed" package unless the
+ * NO_AUTOTARGET solver flag is set */
+#define SOLVER_TARGETED                        0x200000
 
 #define SOLVER_SETEV                   0x01000000
 #define SOLVER_SETEVR                  0x02000000
@@ -259,6 +242,9 @@ typedef struct _Solver Solver;
 
 #define SOLVER_SETMASK                 0x7f000000
 
+/* legacy */
+#define SOLVER_NOOBSOLETES             SOLVER_MULTIVERSION
+
 #define SOLVER_REASON_UNRELATED                0
 #define SOLVER_REASON_UNIT_RULE                1
 #define SOLVER_REASON_KEEP_INSTALLED   2
@@ -283,6 +269,9 @@ typedef struct _Solver Solver;
 #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
+#define SOLVER_FLAG_NO_AUTOTARGET              13
 
 extern Solver *solver_create(Pool *pool);
 extern void solver_free(Solver *solv);
@@ -304,25 +293,31 @@ extern int  solver_describe_decision(Solver *solv, Id p, Id *infop);
 extern void solver_describe_weakdep_decision(Solver *solv, Id p, Queue *whyq);
 
 
-extern void solver_calculate_noobsmap(Pool *pool, Queue *job, Map *noobsmap);
+extern void solver_calculate_multiversionmap(Pool *pool, Queue *job, Map *multiversionmap);
+extern void solver_calculate_noobsmap(Pool *pool, Queue *job, Map *multiversionmap);   /* obsolete */
 extern void solver_create_state_maps(Solver *solv, Map *installedmap, Map *conflictsmap);
 
-/* XXX: why is this not static? */
-Id *solver_create_decisions_obsoletesmap(Solver *solv);
+extern void solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps);
+extern int solver_calc_installsizechange(Solver *solv);
+extern void solver_trivial_installable(Solver *solv, Queue *pkgs, Queue *res);
 
-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);
+extern void pool_job2solvables(Pool *pool, Queue *pkgs, Id how, Id what);
+extern int  pool_isemptyupdatejob(Pool *pool, Id how, Id what);
 
-void solver_find_involved(Solver *solv, Queue *installedq, Solvable *s, Queue *q);
+extern const char *solver_select2str(Pool *pool, Id select, Id what);
+extern const char *pool_job2str(Pool *pool, Id how, Id what, Id flagmask);
 
 /* 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)                                    \
@@ -331,8 +326,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
 }