summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-01-09 14:35:26 +0100
committerMichael Schroeder <mls@suse.de>2012-01-09 14:35:26 +0100
commit4c6908cd35063f06478338d66072b6823ff1ac17 (patch)
treecd10837d64a8ebb76636ad7ba859d2e3fbf6e6d0 /src
parent80445cc0bda870adb1c44aae2a85a2755526de4a (diff)
downloadlibsolv-4c6908cd35063f06478338d66072b6823ff1ac17.tar.gz
libsolv-4c6908cd35063f06478338d66072b6823ff1ac17.tar.bz2
libsolv-4c6908cd35063f06478338d66072b6823ff1ac17.zip
- hide solver internals
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/libsolv.ver1
-rw-r--r--src/repo.h2
-rw-r--r--src/rules.c24
-rw-r--r--src/rules.h1
-rw-r--r--src/solver.c2
-rw-r--r--src/solver.h90
-rw-r--r--src/solver_private.h181
-rw-r--r--src/transaction.h2
9 files changed, 79 insertions, 226 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6fe169d..e118dc7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,6 +11,8 @@ IF (HAVE___QSORT_R)
ADD_DEFINITIONS (-DHAVE___QSORT_R=1)
ENDIF (HAVE___QSORT_R)
+ADD_DEFINITIONS (-DLIBSOLV_INTERNAL=1)
+
SET (libsolv_SRCS
bitmap.c poolarch.c poolvendor.c poolid.c strpool.c dirpool.c
solver.c solverdebug.c repo_solv.c evr.c pool.c
diff --git a/src/libsolv.ver b/src/libsolv.ver
index c6e399d..4a0fc25 100644
--- a/src/libsolv.ver
+++ b/src/libsolv.ver
@@ -279,6 +279,7 @@ SOLV_1.0 {
solver_problemruleinfo2str;
solver_rule2job;
solver_rule2jobidx;
+ solver_ruleclass;
solver_ruleinfo;
solver_ruleliterals;
solver_samerule;
diff --git a/src/repo.h b/src/repo.h
index ed52d0c..ffc71d8 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -43,6 +43,7 @@ typedef struct _Repo {
Id *rpmdbid; /* solvable side data: rpm database id */
+#ifdef LIBSOLV_INTERNAL
Offset lastoff; /* start of last array in idarraydata */
Hashtable lastidhash; /* hash to speed up repo_addid_dep */
@@ -50,6 +51,7 @@ typedef struct _Repo {
int lastidhash_idarraysize;
int lastmarker;
Offset lastmarkerpos;
+#endif /* LIBSOLV_INTERNAL */
} Repo;
extern Repo *repo_create(Pool *pool, const char *name);
diff --git a/src/rules.c b/src/rules.c
index a423600..83426f8 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -1921,6 +1921,30 @@ solver_ruleinfo(Solver *solv, Id rid, Id *fromp, Id *top, Id *depp)
return SOLVER_RULE_UNKNOWN;
}
+SolverRuleinfo
+solver_ruleclass(Solver *solv, Id rid)
+{
+ if (rid <= 0)
+ return SOLVER_RULE_UNKNOWN;
+ if (rid > 0 && rid < solv->rpmrules_end)
+ return SOLVER_RULE_RPM;
+ if (rid >= solv->jobrules && rid < solv->jobrules_end)
+ return SOLVER_RULE_JOB;
+ if (rid >= solv->updaterules && rid < solv->updaterules_end)
+ return SOLVER_RULE_UPDATE;
+ if (rid >= solv->featurerules && rid < solv->featurerules_end)
+ return SOLVER_RULE_FEATURE;
+ if (rid >= solv->duprules && rid < solv->duprules_end)
+ return SOLVER_RULE_DISTUPGRADE;
+ if (rid >= solv->infarchrules && rid < solv->infarchrules_end)
+ return SOLVER_RULE_INFARCH;
+ if (rid >= solv->choicerules && rid < solv->choicerules_end)
+ return SOLVER_RULE_CHOICE;
+ if (rid >= solv->learntrules)
+ return SOLVER_RULE_LEARNT;
+ return SOLVER_RULE_UNKNOWN;
+}
+
void
solver_ruleliterals(Solver *solv, Id rid, Queue *q)
{
diff --git a/src/rules.h b/src/rules.h
index d954a95..43a1786 100644
--- a/src/rules.h
+++ b/src/rules.h
@@ -125,6 +125,7 @@ extern void solver_reenablepolicyrules(struct _Solver *solv, int jobidx);
/* rule info */
extern int solver_allruleinfos(struct _Solver *solv, Id rid, Queue *rq);
extern SolverRuleinfo solver_ruleinfo(struct _Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
+extern SolverRuleinfo solver_ruleclass(struct _Solver *solv, Id rid);
extern void solver_ruleliterals(struct _Solver *solv, Id rid, Queue *q);
extern int solver_rule2jobidx(struct _Solver *solv, Id rid);
extern Id solver_rule2job(struct _Solver *solv, Id rid, Id *whatp);
diff --git a/src/solver.c b/src/solver.c
index 10d3069..fd80677 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -3373,7 +3373,7 @@ solver_describe_weakdep_decision(Solver *solv, Id p, Queue *whyq)
}
if (!found)
{
- /* hard case, just note with no package */
+ /* hard case, just note dependency with no package */
queue_push(whyq, SOLVER_REASON_SUPPLEMENTED);
queue_push2(whyq, 0, sup);
}
diff --git a/src/solver.h b/src/solver.h
index 0e6722a..70beff7 100644
--- a/src/solver.h
+++ b/src/solver.h
@@ -30,17 +30,59 @@ extern "C" {
* 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);
-#if 1
struct _Solver {
Pool *pool; /* back pointer to pool */
Queue job; /* copy of the job we're solving */
+ 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
@@ -118,9 +160,6 @@ struct _Solver {
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 */
@@ -163,44 +202,6 @@ struct _Solver {
int noinfarchcheck; /* true: do not forbid inferior architectures */
- /* 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;
Map dupmap; /* dup these packages*/
int dupmap_all; /* dup all packages */
@@ -212,10 +213,9 @@ struct _Solver {
Map cleandepsmap; /* try to drop these packages as of cleandeps erases */
Queue *ruleinfoq; /* tmp space for solver_ruleinfo() */
+#endif /* LIBSOLV_INTERNAL */
};
-#endif
-
typedef struct _Solver Solver;
/*
diff --git a/src/solver_private.h b/src/solver_private.h
index cbe3272..8aeea18 100644
--- a/src/solver_private.h
+++ b/src/solver_private.h
@@ -6,192 +6,13 @@
*/
/*
- * solver_p.h - private functions
+ * solver_private.h - private functions
*
*/
#ifndef LIBSOLV_SOLVER_P_H
#define LIBSOLV_SOLVER_P_H
-#if 0
-struct _Solver {
- Pool *pool; /* back pointer to pool */
- Queue job; /* copy of the job we're solving */
-
- Repo *installed; /* copy of pool->installed */
-
- /* list of rules, ordered
- * rpm rules first, then features, updates, jobs, learnt
- * see start/end offsets below
- */
- Rule *rules; /* all rules */
- Id nrules; /* [Offset] index of the last rule */
-
- Queue ruleassertions; /* Queue of all assertion rules */
-
- /* start/end offset for rule 'areas' */
-
- Id rpmrules_end; /* [Offset] rpm rules end */
-
- Id featurerules; /* feature rules start/end */
- Id featurerules_end;
-
- Id updaterules; /* policy rules, e.g. keep packages installed or update. All literals > 0 */
- Id updaterules_end;
-
- Id jobrules; /* user rules */
- Id jobrules_end;
-
- Id infarchrules; /* inferior arch rules */
- Id infarchrules_end;
-
- Id duprules; /* dist upgrade rules */
- Id duprules_end;
-
- Id choicerules; /* choice rules (always weak) */
- Id choicerules_end;
- Id *choicerules_ref;
-
- Id learntrules; /* learnt rules, (end == nrules) */
-
- Map noupdate; /* don't try to update these
- installed solvables */
- Map noobsoletes; /* 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 fixmap; /* fix these packages */
- int fixmap_all; /* fix all packages */
-
- Queue weakruleq; /* index into 'rules' for weak ones */
- Map weakrulemap; /* map rule# to '1' for weak rules, 1..learntrules */
-
- 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
- */
-
- Queue ruletojob; /* index into job queue: jobs for which a rule exits */
-
- /* our decisions: */
- Queue decisionq; /* >0:install, <0:remove/conflict */
- Queue decisionq_why; /* index of rule, Offset into rules */
-
- Id *decisionmap; /* map for all available solvables,
- * = 0: undecided
- * > 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 */
-
- int stats_learned; /* statistic */
- int stats_unsolvable; /* statistic */
-
- Map recommendsmap; /* recommended packages from decisionmap */
- Map suggestsmap; /* suggested packages from decisionmap */
- int recommends_index; /* recommendsmap/suggestsmap is created up to this level */
-
- Id *obsoletes; /* obsoletes for each installed solvable */
- Id *obsoletes_data; /* data area for obsoletes */
- Id *multiversionupdaters; /* updaters for multiversion packages in updatesystem mode */
-
- /*-------------------------------------------------------------------------------------------------------------
- * Solver configuration
- *-------------------------------------------------------------------------------------------------------------*/
-
- 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 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 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 */
-
- /* 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;
-
- Map dupmap; /* dup these packages*/
- int dupmap_all; /* dup all packages */
- Map dupinvolvedmap; /* packages involved in dup process */
-
- 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() */
-};
-#endif
-
extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
extern void solver_reset(Solver *solv);
diff --git a/src/transaction.h b/src/transaction.h
index a5d3015..2b55331 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -30,12 +30,14 @@ typedef struct _Transaction {
Queue steps; /* the transaction steps */
+#ifdef LIBSOLV_INTERNAL
Queue transaction_info;
Id *transaction_installed;
Map transactsmap;
Map noobsmap;
struct _TransactionOrderdata *orderdata;
+#endif
} Transaction;