diff options
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/pool.c | 2 | ||||
-rw-r--r-- | src/pool.h | 1 | ||||
-rw-r--r-- | src/poolvendor.c | 62 | ||||
-rw-r--r-- | src/poolvendor.h | 8 | ||||
-rw-r--r-- | src/solver.c | 39 | ||||
-rw-r--r-- | src/solver.h | 1 |
7 files changed, 104 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6574926..6866a8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,10 @@ -SET(libsatsolver_SRCS bitmap.c poolarch.c poolid.c solver.c repo_solv.c -evr.c pool.c queue.c repo.c util.c) +SET(libsatsolver_SRCS bitmap.c poolarch.c poolvendor.c poolid.c +solver.c repo_solv.c evr.c pool.c queue.c repo.c util.c) ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS}) -SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h pool.h poolid.h pooltypes.h queue.h solvable.h solver.h repo.h repo_solv.h util.h ) +SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h poolvendor.h pool.h poolid.h pooltypes.h queue.h solvable.h solver.h repo.h repo_solv.h util.h ) INSTALL( FILES ${libsatsolver_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/satsolver" ) -INSTALL(TARGETS satsolver LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
\ No newline at end of file +INSTALL(TARGETS satsolver LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) @@ -96,6 +96,7 @@ pool_create(void) // pre-alloc space for a Solvable pool->solvables = (Solvable *)xcalloc(2, sizeof(Solvable)); pool->nsolvables = 2; + queue_init(&pool->vendormap); s = pool->solvables + SYSTEMSOLVABLE; s->name = SYSTEM_SYSTEM; s->arch = ARCH_NOARCH; @@ -127,6 +128,7 @@ pool_free(Pool *pool) xfree(pool->stringspace); xfree(pool->strings); xfree(pool->rels); + queue_free(&pool->vendormap); for (i = 0; i < DEP2STRBUF; i++) xfree(pool->dep2strbuf[i]); xfree(pool); @@ -80,6 +80,7 @@ struct _Pool { Id *id2arch; /* map arch ids to scores */ Id lastarch; /* last valid entry in id2arch */ + Queue vendormap; /* map vendor to vendorclasses mask */ /* providers data, as two-step indirect list * whatprovides[Id] -> Offset into whatprovidesdata for name diff --git a/src/poolvendor.c b/src/poolvendor.c new file mode 100644 index 0000000..b818445 --- /dev/null +++ b/src/poolvendor.c @@ -0,0 +1,62 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define _GNU_SOURCE 1 +#include <fnmatch.h> + +#include "pool.h" +#include "poolid.h" +#include "poolvendor.h" +#include "util.h" + +const char *vendors[] = { + "SUSE*", + "openSUSE*", + "SGI*", + "Novell*", + "Silicon Graphics*", + "Jpackage Project*", + "ATI Technologies Inc.*", + "Nvidia*", + 0, + 0, +}; + +Id pool_vendor2mask(Pool *pool, Id vendor) +{ + const char *vstr; + int i; + Id mask, m; + const char **v; + + if (vendor == 0) + return 0; + for (i = 0; i < pool->vendormap.count; i += 2) + if (pool->vendormap.elements[i] == vendor) + return pool->vendormap.elements[i + 1]; + vstr = id2str(pool, vendor); + m = 1; + mask = 0; + for (v = vendors; ; v++) + { + if (*v == 0) + { + v++; + if (*v == 0) + break; + if (m == (1 << 31)) + break; + m <<= 1; + } + if (fnmatch(*v, vstr, FNM_CASEFOLD) == 0) + { + mask |= m; + while (v[1]) + v++; + } + } + queue_push(&pool->vendormap, vendor); + queue_push(&pool->vendormap, mask); + return mask; +} diff --git a/src/poolvendor.h b/src/poolvendor.h new file mode 100644 index 0000000..2596a43 --- /dev/null +++ b/src/poolvendor.h @@ -0,0 +1,8 @@ +#ifndef POOLVENDOR_H +#define POOLVENDOR_H + +#include "pool.h" + +Id pool_vendor2mask(Pool *pool, Id vendor); + +#endif /* POOLVENDOR_H */ diff --git a/src/solver.c b/src/solver.c index 8e5c56d..cf11b79 100644 --- a/src/solver.c +++ b/src/solver.c @@ -14,6 +14,7 @@ #include "pool.h" #include "util.h" #include "evr.h" +#include "poolvendor.h" #define RULES_BLOCK 63 @@ -1073,15 +1074,15 @@ archchanges(Pool *pool, Solvable *s1, Solvable *s2) return 0; } - static void -findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngrade, int allowarchchange) +findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngrade, int allowarchchange, int allowvendorchange) { /* installed packages get a special upgrade allowed rule */ Pool *pool = solv->pool; Id p, *pp, n, p2, *pp2; Id obs, *obsp; Solvable *ps; + Id vendormask; queue_empty(qs); /* @@ -1089,6 +1090,8 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr * n = solvable Id */ n = s - pool->solvables; + vendormask = pool_vendor2mask(pool, s->vendor); + if (m && !MAPTST(m, n)) /* add rule for s if not already done */ addrulesforsolvable(solv, s, m); @@ -1109,6 +1112,8 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr /* XXX */ if (!allowarchchange && archchanges(pool, s, ps)) continue; + if (!allowvendorchange && s->vendor != ps->vendor && vendormask && (vendormask & pool_vendor2mask(pool, ps->vendor)) == 0) + continue; } else if (!solv->noupdateprovide && ps->obsoletes) /* provides/obsoletes combination ? */ { @@ -1156,7 +1161,7 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr */ static void -addupdaterule(Solver *solv, Solvable *s, Map *m, int allowdowngrade, int allowarchchange, int dontaddrule) +addupdaterule(Solver *solv, Solvable *s, Map *m, int allowdowngrade, int allowarchchange, int allowvendorchange, int dontaddrule) { /* installed packages get a special upgrade allowed rule */ Pool *pool = solv->pool; @@ -1166,7 +1171,7 @@ addupdaterule(Solver *solv, Solvable *s, Map *m, int allowdowngrade, int allowar Id qsbuf[64]; queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf)); - findupdatepackages(solv, s, &qs, m, allowdowngrade, allowarchchange); + findupdatepackages(solv, s, &qs, m, allowdowngrade, allowarchchange, allowvendorchange); p = s - pool->solvables; if (dontaddrule) /* we consider update candidates but dont force them */ { @@ -2737,7 +2742,7 @@ solve(Solver *solv, Queue *job) break; case SOLVER_INSTALL_SOLVABLE_UPDATE: /* dont allow downgrade */ - addupdaterule(solv, pool->solvables + what, &addedmap, 0, 0, 1); + addupdaterule(solv, pool->solvables + what, &addedmap, 0, 0, 0, 1); break; } } @@ -2754,11 +2759,11 @@ solve(Solver *solv, Queue *job) { /* add update rule for every installed package */ for (i = solv->installed->start; i < solv->installed->start + solv->installed->nsolvables; i++) - addupdaterule(solv, pool->solvables + i, &addedmap, solv->allowdowngrade, solv->allowarchchange, 1); + addupdaterule(solv, pool->solvables + i, &addedmap, solv->allowdowngrade, solv->allowarchchange, solv->allowvendorchange, 1); } #else /* this is just to add the needed rpm rules to our set */ for (i = solv->installed->start; i < solv->installed->start + solv->installed->nsolvables; i++) - addupdaterule(solv, pool->solvables + i, &addedmap, 1, 1, 1); + addupdaterule(solv, pool->solvables + i, &addedmap, 1, 1, 1, 1); #endif addrulesforweak(solv, &addedmap); @@ -2855,7 +2860,7 @@ solve(Solver *solv, Queue *job) } break; case SOLVER_INSTALL_SOLVABLE_UPDATE: /* find update for solvable */ - addupdaterule(solv, pool->solvables + what, &addedmap, 0, 0, 0); + addupdaterule(solv, pool->solvables + what, &addedmap, 0, 0, 0, 0); queue_push(&solv->ruletojob, i); break; } @@ -2885,7 +2890,7 @@ solve(Solver *solv, Queue *job) for (i = solv->installed->start; i < solv->installed->start + solv->installed->nsolvables; i++) { if (!MAPTST(&noupdaterule, i)) /* if not marked as 'noupdate' */ - addupdaterule(solv, pool->solvables + i, &addedmap, solv->allowdowngrade, solv->allowarchchange, 0); + addupdaterule(solv, pool->solvables + i, &addedmap, solv->allowdowngrade, solv->allowarchchange, solv->allowvendorchange, 0); else addrule(solv, 0, 0); /* place holder */ } @@ -2904,7 +2909,7 @@ solve(Solver *solv, Queue *job) { if (MAPTST(&noupdaterule, solv->installed->start + i)) continue; - findupdatepackages(solv, pool->solvables + solv->installed->start + i, &q, (Map *)0, 1, 1); + findupdatepackages(solv, pool->solvables + solv->installed->start + i, &q, (Map *)0, 1, 1, 1); if (q.count) solv->weaksystemrules[i] = pool_queuetowhatprovides(pool, &q); } @@ -3098,11 +3103,19 @@ solve(Solver *solv, Queue *job) printf("- allow downgrade of %s-%s.%s to %s-%s.%s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), id2str(pool, sd->name), id2str(pool, sd->evr), id2str(pool, sd->arch)); gotone = 1; } - if (!solv->allowarchchange && archchanges(pool, sd, s)) + if (!solv->allowarchchange && s->name == sd->name && archchanges(pool, sd, s)) { printf("- allow architecture change of %s-%s.%s to %s-%s.%s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), id2str(pool, sd->name), id2str(pool, sd->evr), id2str(pool, sd->arch)); gotone = 1; } + if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && pool_vendor2mask(pool, s->vendor) && (pool_vendor2mask(pool, s->vendor) & pool_vendor2mask(pool, sd->vendor)) == 0) + { + if (sd->vendor) + printf("- allow vendor change from '%s' (%s-%s.%s) to '%s' (%s-%s.%s)\n", id2str(pool, s->vendor), id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), id2str(pool, sd->vendor), id2str(pool, sd->name), id2str(pool, sd->evr), id2str(pool, sd->arch)); + else + printf("- allow vendor change from '%s' (%s-%s.%s) to no vendor (%s-%s.%s)\n", id2str(pool, s->vendor), id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), id2str(pool, sd->name), id2str(pool, sd->evr), id2str(pool, sd->arch)); + gotone = 1; + } if (!gotone) printf("- allow replacement of %s-%s.%s with %s-%s.%s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), id2str(pool, sd->name), id2str(pool, sd->evr), id2str(pool, sd->arch)); } @@ -3117,9 +3130,9 @@ solve(Solver *solv, Queue *job) } } printf("------------------------------------\n"); - queue_free(&problems); - queue_free(&solution); } + queue_free(&solution); + queue_free(&problems); return; } diff --git a/src/solver.h b/src/solver.h index 9e23f40..fb0c8b9 100644 --- a/src/solver.h +++ b/src/solver.h @@ -44,6 +44,7 @@ typedef struct solver { 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 */ |