/* legacy, do not use anymore! */
void
-prune_best_version_arch(Pool *pool, Queue *plist)
+prune_best_version_arch(Solver *solv, Pool *pool, Queue *plist)
{
+ if (solv && solv->bestSolvableCb)
+ { /* The application is responsible for */
+ return solv->bestSolvableCb (plist);
+ }
+
if (plist->count > 1)
prune_to_best_arch(pool, plist);
if (plist->count > 1)
/* FIXME: do this different! */
if (inst)
queue_push(plist, inst);
- if (plist->count > 1)
- prune_to_best_arch(pool, plist);
- if (plist->count > 1)
- prune_to_best_version(pool, plist);
+
+ prune_best_version_arch (solv, pool, plist);
}
int
-policy_illegal_archchange(Pool *pool, Solvable *s1, Solvable *s2)
+policy_illegal_archchange(Solver *solv, Pool *pool, Solvable *s1, Solvable *s2)
{
Id a1 = s1->arch, a2 = s2->arch;
+ if (solv && solv->archCheckCb)
+ { /* The application is responsible for */
+ return solv->archCheckCb (s1, s2);
+ }
+
/* we allow changes to/from noarch */
if (a1 == a2 || a1 == ARCH_NOARCH || a2 == ARCH_NOARCH)
return 0;
}
int
-policy_illegal_vendorchange(Pool *pool, Solvable *s1, Solvable *s2)
+policy_illegal_vendorchange(Solver *solv, Pool *pool, Solvable *s1, Solvable *s2)
{
Id vendormask1, vendormask2;
+
+ if (solv && solv->vendorCheckCb)
+ { /* The application is responsible for */
+ return solv->vendorCheckCb (s1, s2);
+ }
+
if (s1->vendor == s2->vendor)
return 0;
vendormask1 = pool_vendor2mask(pool, s1->vendor);
Id vendormask;
queue_empty(qs);
+
+ if (solv && solv->updateCandidateCb)
+ { /* The application is responsible for */
+ return solv->updateCandidateCb (s, qs);
+ }
+
/*
* s = solvable ptr
* n = solvable Id
{
if (!solv->allowdowngrade && evrcmp(pool, s->evr, ps->evr, EVRCMP_MATCH_RELEASE) > 0)
continue;
- if (!solv->allowarchchange && s->arch != ps->arch && policy_illegal_archchange(pool, s, ps))
+ if (!solv->allowarchchange && s->arch != ps->arch && policy_illegal_archchange(solv, pool, s, ps))
continue;
- if (!solv->allowvendorchange && s->vendor != ps->vendor && policy_illegal_vendorchange(pool, s, ps))
+ if (!solv->allowvendorchange && s->vendor != ps->vendor && policy_illegal_vendorchange(solv, pool, s, ps))
continue;
}
}
#define POLICY_MODE_RECOMMEND 1
#define POLICY_MODE_SUGGEST 2
-/* legacy, do not use! */
-extern void prune_best_version_arch(Pool *pool, Queue *plist);
+extern void prune_best_version_arch(Solver *solv, Pool *pool, Queue *plist);
extern void policy_filter_unwanted(Solver *solv, Queue *plist, Id inst, int mode);
-extern int policy_illegal_archchange(Pool *pool, Solvable *s1, Solvable *s2);
-extern int policy_illegal_vendorchange(Pool *pool, Solvable *s1, Solvable *s2);
+extern int policy_illegal_archchange(Solver *solv, Pool *pool, Solvable *s1, Solvable *s2);
+extern int policy_illegal_vendorchange(Solver *solv, Pool *pool, Solvable *s1, Solvable *s2);
extern void policy_findupdatepackages(Solver *solv,
Solvable *s,
Queue *qs,
int allowall); /* do not regard policies for vendor,architecuture,... change */
+
#include "evr.h"
#include "policy.h"
+
+
#define RULES_BLOCK 63
#define REGARD_RECOMMENDS_OF_INSTALLED_ITEMS 0
POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;
}
- if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(pool, s, sd))
+ if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(solv, pool, s, sd))
{
POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;
}
- if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(pool, s, sd))
+ if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(solv,pool, s, sd))
{
if (sd->vendor)
POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to '%s' (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), id2str(pool, sd->vendor), solvable2str(pool, sd));
#include "repo.h"
#include "queue.h"
#include "bitmap.h"
+/*
+ * Callback definitions in order to "overwrite" the policies by an external application.
+ */
+
+typedef void (*BestSolvableCb) (Queue *canditates);
+typedef int (*ArchCheckCb) (Solvable *solvable1, Solvable *solvable2);
+typedef int (*VendorCheckCb) (Solvable *solvable1, Solvable *solvable2);
+typedef void (*UpdateCandidateCb) (Solvable *solvable, Queue *canditates);
+
/* ----------------------------------------------
* Rule
typedef struct solver {
Pool *pool;
Repo *installed;
-
- 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; /* distupgrade */
- int allowvirtualconflicts; /* false: conflicts on package name, true: conflicts on package provides */
- int noupdateprovide; /* true: update packages needs not to provide old package */
- int dosplitprovides; /* true: consider legacy split provides */
Rule *rules; /* all rules */
Id nrules; /* index of the last rule */
Id *obsoletes_data; /* data area for obsoletes */
Queue covenantq; /* Covenants honored by this solver (generic locks) */
+
+ /*-------------------------------------------------------------------------------------------------------------
+ * 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; /* distupgrade */
+ int allowvirtualconflicts; /* false: conflicts on package name, true: conflicts on package provides */
+ int noupdateprovide; /* true: update packages needs not to provide old package */
+ int dosplitprovides; /* true: consider legacy split provides */
+
+ /* Callbacks for defining the bahaviour of the SAT solver */
+
+ /* Finding best candidate
+ *
+ * Callback definition:
+ * void bestSolvable (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 (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 (Solvable *solvable1, Solvable *solvable2);
+ *
+ * return 0 it the two solvables has compatible architectures
+ */
+ VendorCheckCb vendorCheckCb;
+
+ /* Evaluate update candidate
+ *
+ * Callback definition:
+ * void pdateCandidateCb (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;
+
} Solver;