From 5b22f958ddfdf43953f07538bf07027f2308424c Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 6 Mar 2013 17:53:06 +0100 Subject: [PATCH] get rid of the ugly policy callbacks while we're breaking the ABI, add new pool_set_custom_vendorcheck function --- src/libsolv.ver | 1 + src/policy.c | 22 +++------------------- src/pool.c | 7 +++++++ src/pool.h | 3 ++- src/solver.h | 50 +------------------------------------------------ 5 files changed, 14 insertions(+), 69 deletions(-) diff --git a/src/libsolv.ver b/src/libsolv.ver index aa23112a..52b51da2 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -90,6 +90,7 @@ SOLV_1.0 { pool_rel2id; pool_search; pool_selection2str; + pool_set_custom_vendorcheck; pool_set_flag; pool_set_installed; pool_set_languages; diff --git a/src/policy.c b/src/policy.c index 6243e090..916590c0 100644 --- a/src/policy.c +++ b/src/policy.c @@ -601,11 +601,6 @@ prune_to_best_version(Pool *pool, Queue *plist) static void prune_best_arch_name_version(const Solver *solv, Pool *pool, Queue *plist) { - if (solv && solv->bestSolvableCb) - { /* The application is responsible for */ - return solv->bestSolvableCb(solv->pool, plist); - } - if (plist->count > 1) prune_to_best_arch(pool, plist); if (plist->count > 1) @@ -675,11 +670,6 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2) Pool *pool = solv->pool; Id a1 = s1->arch, a2 = s2->arch; - if (solv && solv->archCheckCb) - { /* The application is responsible for */ - return solv->archCheckCb(solv->pool, s1, s2); - } - /* we allow changes to/from noarch */ if (a1 == a2 || a1 == pool->noarchid || a2 == pool->noarchid) return 0; @@ -701,10 +691,9 @@ policy_illegal_vendorchange(Solver *solv, Solvable *s1, Solvable *s2) Id v1, v2; Id vendormask1, vendormask2; - if (solv->vendorCheckCb) - { /* The application is responsible for */ - return solv->vendorCheckCb(pool, s1, s2); - } + if (pool->custom_vendorcheck) + return pool->custom_vendorcheck(pool, s1, s2); + /* treat a missing vendor as empty string */ v1 = s1->vendor ? s1->vendor : ID_EMPTY; v2 = s2->vendor ? s2->vendor : ID_EMPTY; @@ -869,11 +858,6 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all) queue_empty(qs); - if (solv && solv->updateCandidateCb) - { /* The application is responsible for */ - return solv->updateCandidateCb(solv->pool, s, qs); - } - n = s - pool->solvables; /* diff --git a/src/pool.c b/src/pool.c index b65a1c21..3b273189 100644 --- a/src/pool.c +++ b/src/pool.c @@ -2199,4 +2199,11 @@ pool_get_rootdir(Pool *pool) return pool->rootdir; } +/* only used in libzypp */ +void +pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *)) +{ + pool->custom_vendorcheck = vendorcheck; +} + /* EOF */ diff --git a/src/pool.h b/src/pool.h index e785cd8c..482aefb4 100644 --- a/src/pool.h +++ b/src/pool.h @@ -148,8 +148,8 @@ struct _Pool { char *rootdir; + int (*custom_vendorcheck)(struct _Pool *, Solvable *, Solvable *); #endif - }; #define DISTTYPE_RPM 0 @@ -223,6 +223,7 @@ extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribut extern void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata); extern void pool_setdebugmask(Pool *pool, int mask); extern void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata); +extern void pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(struct _Pool *, Solvable *, Solvable *)); extern char *pool_alloctmpspace(Pool *pool, int len); diff --git a/src/solver.h b/src/solver.h index a51b1738..b735329a 100644 --- a/src/solver.h +++ b/src/solver.h @@ -26,15 +26,6 @@ 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); - struct _Solver { Pool *pool; /* back pointer to pool */ @@ -43,46 +34,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 */ + int pooljobcnt; /* number of pooljob entries in job queue */ #ifdef LIBSOLV_INTERNAL Repo *installed; /* copy of pool->installed */ -- 2.47.2