* Callback definitions in order to "overwrite" the policies by an external application.
*/
-typedef void (*BestSolvableCb) (Pool *pool, Queue *canditates);
+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);
-struct _Solver;
-
-typedef struct _Solver {
+struct _Solver {
Pool *pool; /* back pointer to pool */
Queue job; /* copy of the job we're solving */
- Transaction trans; /* calculated transaction */
+ 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;
+#ifdef LIBSOLV_INTERNAL
Repo *installed; /* copy of pool->installed */
/* list of rules, ordered
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;
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 */
* > 0: level of decision when installed,
* < 0: level of decision when conflict */
+ int decisioncnt_update;
+ int decisioncnt_keep;
+ int decisioncnt_resolve;
+ int decisioncnt_weak;
+ int decisioncnt_orphan;
+
/* learnt rule history */
Queue learnt_why;
Queue learnt_pool;
Queue branches;
- int (*solution_callback)(struct _Solver *solv, void *data);
- void *solution_callback_data;
-
int propagate_index; /* index into decisionq for non-propagated decisions */
Queue problems; /* list of lists of conflicting rules, < 0 for job rules */
Queue solutions; /* refined problem storage space */
- Queue recommendations; /* recommended packages */
- Queue suggestions; /* suggested packages */
- Queue orphaned; /* orphaned packages */
+ Queue orphaned; /* orphaned packages (to be removed?) */
int stats_learned; /* statistic */
int stats_unsolvable; /* statistic */
* Solver configuration
*-------------------------------------------------------------------------------------------------------------*/
- int fixsystem; /* repair errors in rpm dependency graph */
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 */
- int updatesystem; /* update all packages to the newest version */
int noupdateprovide; /* true: update packages needs not to provide old package */
int dosplitprovides; /* true: consider legacy split provides */
int dontinstallrecommended; /* true: do not install recommended packages */
- int ignorealreadyrecommended; /* true: ignore recommended packages that were already recommended by the installed packages */
+ int addalreadyrecommended; /* true: also install recommended packages that were already recommended by the installed packages */
int dontshowinstalledrecommended; /* true: do not show recommended packages that are already installed */
- /* distupgrade also needs updatesystem and dosplitprovides */
- int distupgrade;
- int distupgrade_removeunsupported;
-
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 */
- /* Callbacks for defining the bahaviour of the SAT 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 pdateCandidateCb (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;
-
- /* some strange queue that doesn't belong here */
- Queue covenantq; /* Covenants honored by this solver (generic locks) */
-
-
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 */
Map droporphanedmap; /* packages to drop in dup mode */
int droporphanedmap_all;
Map cleandepsmap; /* try to drop these packages as of cleandeps erases */
Queue *ruleinfoq; /* tmp space for solver_ruleinfo() */
-} 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 */
+};
+
+typedef struct _Solver Solver;
/*
* queue commands
#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
#define SOLVER_SETVENDOR 0x08000000
#define SOLVER_SETREPO 0x10000000
#define SOLVER_NOAUTOSET 0x20000000
-
-#define SOLVER_SETMASK 0x2f000000
-
-/* old API compatibility, do not use in new code */
-#ifdef OBSOLETE_INTERFACE
-
-#define SOLVER_INSTALL_SOLVABLE (SOLVER_INSTALL|SOLVER_SOLVABLE)
-#define SOLVER_ERASE_SOLVABLE (SOLVER_ERASE|SOLVER_SOLVABLE)
-#define SOLVER_INSTALL_SOLVABLE_NAME (SOLVER_INSTALL|SOLVER_SOLVABLE_NAME)
-#define SOLVER_ERASE_SOLVABLE_NAME (SOLVER_ERASE|SOLVER_SOLVABLE_NAME)
-#define SOLVER_INSTALL_SOLVABLE_PROVIDES (SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES)
-#define SOLVER_ERASE_SOLVABLE_PROVIDES (SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES)
-#define SOLVER_INSTALL_SOLVABLE_UPDATE (SOLVER_UPDATE|SOLVER_SOLVABLE)
-#define SOLVER_INSTALL_SOLVABLE_ONE_OF (SOLVER_INSTALL|SOLVER_SOLVABLE_ONE_OF)
-#define SOLVER_WEAKEN_SOLVABLE_DEPS (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE)
-#define SOLVER_NOOBSOLETES_SOLVABLE (SOLVER_NOOBSOLETES|SOLVER_SOLVABLE)
-#define SOLVER_NOOBSOLETES_SOLVABLE_NAME (SOLVER_NOOBSOLETES|SOLVER_SOLVABLE_NAME)
-#define SOLVER_NOOBSOLETES_SOLVABLE_PROVIDES (SOLVER_NOOBSOLETES|SOLVER_SOLVABLE_PROVIDES)
-
-/* backward compatibility */
-#define SOLVER_PROBLEM_UPDATE_RULE SOLVER_RULE_UPDATE
-#define SOLVER_PROBLEM_JOB_RULE SOLVER_RULE_JOB
-#define SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP
-#define SOLVER_PROBLEM_NOT_INSTALLABLE SOLVER_RULE_RPM_NOT_INSTALLABLE
-#define SOLVER_PROBLEM_NOTHING_PROVIDES_DEP SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP
-#define SOLVER_PROBLEM_SAME_NAME SOLVER_RULE_RPM_SAME_NAME
-#define SOLVER_PROBLEM_PACKAGE_CONFLICT SOLVER_RULE_RPM_PACKAGE_CONFLICT
-#define SOLVER_PROBLEM_PACKAGE_OBSOLETES SOLVER_RULE_RPM_PACKAGE_OBSOLETES
-#define SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE SOLVER_RULE_RPM_PACKAGE_REQUIRES
-#define SOLVER_PROBLEM_SELF_CONFLICT SOLVER_RULE_RPM_SELF_CONFLICT
-#define SOLVER_PROBLEM_RPM_RULE SOLVER_RULE_RPM
-#define SOLVER_PROBLEM_DISTUPGRADE_RULE SOLVER_RULE_DISTUPGRADE
-#define SOLVER_PROBLEM_INFARCH_RULE SOLVER_RULE_INFARCH
-
-#endif
-
+#define SOLVER_SETNAME 0x40000000
+
+#define SOLVER_SETMASK 0x7f000000
+
+#define SOLVER_REASON_UNRELATED 0
+#define SOLVER_REASON_UNIT_RULE 1
+#define SOLVER_REASON_KEEP_INSTALLED 2
+#define SOLVER_REASON_RESOLVE_JOB 3
+#define SOLVER_REASON_UPDATE_INSTALLED 4
+#define SOLVER_REASON_CLEANDEPS_ERASE 5
+#define SOLVER_REASON_RESOLVE 6
+#define SOLVER_REASON_WEAKDEP 7
+#define SOLVER_REASON_RESOLVE_ORPHAN 8
+
+#define SOLVER_REASON_RECOMMENDED 16
+#define SOLVER_REASON_SUPPLEMENTED 17
+
+
+#define SOLVER_FLAG_ALLOW_DOWNGRADE 1
+#define SOLVER_FLAG_ALLOW_ARCHCHANGE 2
+#define SOLVER_FLAG_ALLOW_VENDORCHANGE 3
+#define SOLVER_FLAG_ALLOW_UNINSTALL 4
+#define SOLVER_FLAG_NO_UPDATEPROVIDE 5
+#define SOLVER_FLAG_SPLITPROVIDES 6
+#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);
-extern void solver_solve(Solver *solv, Queue *job);
+extern int solver_solve(Solver *solv, Queue *job);
+extern Transaction *solver_create_transaction(Solver *solv);
+extern int solver_set_flag(Solver *solv, int flag, int value);
+extern int solver_get_flag(Solver *solv, int flag);
-extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
-extern void solver_reset(Solver *solv);
+extern int solver_get_decisionlevel(Solver *solv, Id p);
+extern void solver_get_decisionqueue(Solver *solv, Queue *decisionq);
+extern int solver_get_lastdecisionblocklevel(Solver *solv);
+extern void solver_get_decisionblock(Solver *solv, int level, Queue *decisionq);
-extern int solver_dep_installed(Solver *solv, Id dep);
-extern int solver_splitprovides(Solver *solv, Id dep);
+extern void solver_get_orphaned(Solver *solv, Queue *orphanedq);
+extern void solver_get_recommendations(Solver *solv, Queue *recommendationsq, Queue *suggestionsq, int noselected);
+extern void solver_get_unneeded(Solver *solv, Queue *unneededq, int filtered);
+
+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);
-/* obsolete */
-extern SolverRuleinfo solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, Id *targetp);
+extern void solver_calculate_noobsmap(Pool *pool, Queue *job, Map *noobsmap);
+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);
-static inline int
-solver_dep_fulfilled(Solver *solv, Id dep)
-{
- Pool *pool = solv->pool;
- Id p, pp;
-
- if (ISRELDEP(dep))
- {
- Reldep *rd = GETRELDEP(pool, dep);
- if (rd->flags == REL_AND)
- {
- if (!solver_dep_fulfilled(solv, rd->name))
- return 0;
- return solver_dep_fulfilled(solv, rd->evr);
- }
- if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
- return solver_splitprovides(solv, rd->evr);
- if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
- return solver_dep_installed(solv, rd->evr);
- }
- FOR_PROVIDES(p, pp, dep)
- {
- if (solv->decisionmap[p] > 0)
- return 1;
- }
- return 0;
-}
-
-static inline int
-solver_is_supplementing(Solver *solv, Solvable *s)
-{
- Id sup, *supp;
- if (!s->supplements)
- return 0;
- supp = s->repo->idarraydata + s->supplements;
- while ((sup = *supp++) != 0)
- if (solver_dep_fulfilled(solv, sup))
- return 1;
- return 0;
-}
-
-static inline int
-solver_is_enhancing(Solver *solv, Solvable *s)
-{
- Id enh, *enhp;
- if (!s->enhances)
- return 0;
- enhp = s->repo->idarraydata + s->enhances;
- while ((enh = *enhp++) != 0)
- if (solver_dep_fulfilled(solv, enh))
- return 1;
- return 0;
-}
-
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);
-
-static inline void
-solver_create_state_maps(Solver *solv, Map *installedmap, Map *conflictsmap)
-{
- pool_create_state_maps(solv->pool, &solv->decisionq, installedmap, conflictsmap);
-}
+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) \
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
}