From 2f7a0546a4bcbd124a944cb6e32981055295b309 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 20 Feb 2012 15:25:18 +0100 Subject: [PATCH] - make pool flags private, allow self conflicts for rpm, add pool_set/get_flags --- bindings/python/CMakeLists.txt | 2 ++ bindings/solv.i | 6 +++++ ext/pool_fileconflicts.c | 5 ++-- src/libsolv.ver | 2 ++ src/pool.c | 58 +++++++++++++++++++++++++++++++++++++++++- src/pool.h | 25 ++++++++++++------ 6 files changed, 87 insertions(+), 11 deletions(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index c34a310..0b5a270 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -11,6 +11,8 @@ ADD_CUSTOM_COMMAND ( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${CMAKE_SOURCE_DIR}/bindings/solv.i ) + +ADD_DEFINITIONS(-Wno-unused) INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) ADD_LIBRARY (bindings_python SHARED solv_python.c) diff --git a/bindings/solv.i b/bindings/solv.i index 7b75536..1b080de 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -805,6 +805,12 @@ typedef struct { void set_debuglevel(int level) { pool_setdebuglevel($self, level); } + int set_flag(int flag, int value) { + return pool_set_flag($self, flag, value); + } + int get_flag(int flag) { + return pool_get_flag($self, flag); + } #if defined(SWIGPYTHON) %{ SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) { diff --git a/ext/pool_fileconflicts.c b/ext/pool_fileconflicts.c index cff0ef9..441743f 100644 --- a/ext/pool_fileconflicts.c +++ b/ext/pool_fileconflicts.c @@ -273,6 +273,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo unsigned int now, start; void *handle; Id p; + int obsoleteusescolors = pool_get_flag(pool, POOL_FLAG_OBSOLETEUSESCOLORS); queue_empty(conflicts); if (!pkgs->count) @@ -379,7 +380,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo int iterflags; iterflags = RPM_ITERATE_FILELIST_WITHMD5 | RPM_ITERATE_FILELIST_NOGHOSTS; - if (pool->obsoleteusescolors) + if (obsoleteusescolors) iterflags |= RPM_ITERATE_FILELIST_WITHCOL; p = pkgs->elements[pidx]; hx = cbdata.lookat.elements[i]; @@ -417,7 +418,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo continue; /* different file names */ if (!strcmp(fsi, fsj)) continue; /* md5 sum matches */ - if (pool->obsoleteusescolors && fsi[33] && fsj[33] && (fsi[33] & fsj[33]) == 0) + if (obsoleteusescolors && fsi[33] && fsj[33] && (fsi[33] & fsj[33]) == 0) continue; /* colors do not conflict */ queue_push(conflicts, pool_str2id(pool, (char *)cbdata.filesspace + cbdata.files.elements[ii] + 34, 1)); queue_push(conflicts, p); diff --git a/src/libsolv.ver b/src/libsolv.ver index a9b95a9..9360bfc 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -60,6 +60,7 @@ SOLV_1.0 { pool_freeidhashes; pool_freetmpspace; pool_freewhatprovides; + pool_get_flag; pool_id2evr; pool_id2langid; pool_id2rel; @@ -76,6 +77,7 @@ SOLV_1.0 { pool_queuetowhatprovides; pool_rel2id; pool_search; + pool_set_flag; pool_set_installed; pool_set_languages; pool_setarch; diff --git a/src/pool.c b/src/pool.c index 89c6c1a..77704a1 100644 --- a/src/pool.c +++ b/src/pool.c @@ -63,11 +63,13 @@ pool_create(void) queue_init(&pool->vendormap); pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */ +#ifndef RPM5 + pool->allowselfconflicts = 1; +#endif #ifdef FEDORA pool->obsoleteusescolors = 1; #endif #ifdef DEBIAN - pool->allowselfconflicts = 1; pool->disttype = DISTTYPE_DEB; #endif #ifdef RPM5 @@ -127,6 +129,60 @@ pool_setdisttype(Pool *pool, int disttype) } #endif +int +pool_get_flag(Pool *pool, int flag) +{ + switch (flag) + { + case POOL_FLAG_PROMOTEEPOCH: + return pool->promoteepoch; + case POOL_FLAG_ALLOWSELFCONFLICTS: + return pool->allowselfconflicts; + case POOL_FLAG_OBSOLETEUSESPROVIDES: + return pool->obsoleteusesprovides; + case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES: + return pool->implicitobsoleteusesprovides; + case POOL_FLAG_OBSOLETEUSESCOLORS: + return pool->obsoleteusescolors; + case POOL_FLAG_NOINSTALLEDOBSOLETES: + return pool->noinstalledobsoletes; + default: + break; + } + return -1; +} + +int +pool_set_flag(Pool *pool, int flag, int value) +{ + int old = pool_get_flag(pool, flag); + switch (flag) + { + case POOL_FLAG_PROMOTEEPOCH: + pool->promoteepoch = value; + break; + case POOL_FLAG_ALLOWSELFCONFLICTS: + pool->allowselfconflicts = value; + break; + case POOL_FLAG_OBSOLETEUSESPROVIDES: + pool->obsoleteusesprovides = value; + break; + case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES: + pool->implicitobsoleteusesprovides = value; + break; + case POOL_FLAG_OBSOLETEUSESCOLORS: + pool->obsoleteusescolors = value; + break; + case POOL_FLAG_NOINSTALLEDOBSOLETES: + pool->noinstalledobsoletes = value; + break; + default: + break; + } + return old; +} + + Id pool_add_solvable(Pool *pool) { diff --git a/src/pool.h b/src/pool.h index f67979f..121eb56 100644 --- a/src/pool.h +++ b/src/pool.h @@ -81,14 +81,6 @@ struct _Pool { /* package manager type, deb/rpm */ int disttype; - /* flags to tell the library how the installed package manager works */ - int promoteepoch; /* true: missing epoch is replaced by epoch of dependency */ - int obsoleteusesprovides; /* true: obsoletes are matched against provides, not names */ - int implicitobsoleteusesprovides; /* true: implicit obsoletes due to same name are matched against provides, not names */ - int obsoleteusescolors; /* true: obsoletes check arch color */ - int noinstalledobsoletes; /* true: ignore obsoletes of installed packages */ - int allowselfconflicts; /* true: packages which conflict with itself are installable */ - Id *id2arch; /* map arch ids to scores */ unsigned char *id2color; /* map arch ids to colors */ Id lastarch; /* last valid entry in id2arch/id2color */ @@ -128,6 +120,14 @@ struct _Pool { Datapos pos; #ifdef LIBSOLV_INTERNAL + /* flags to tell the library how the installed package manager works */ + int promoteepoch; /* true: missing epoch is replaced by epoch of dependency */ + int obsoleteusesprovides; /* true: obsoletes are matched against provides, not names */ + int implicitobsoleteusesprovides; /* true: implicit obsoletes due to same name are matched against provides, not names */ + int obsoleteusescolors; /* true: obsoletes check arch color */ + int noinstalledobsoletes; /* true: ignore obsoletes of installed packages */ + int allowselfconflicts; /* true: packages which conflict with itself are installable */ + /* hash for rel unification */ Hashtable relhashtbl; /* hashtable: (name,evr,op)Hash -> Id */ Hashmask relhashmask; @@ -161,6 +161,13 @@ struct _Pool { #define SOLV_DEBUG_TO_STDERR (1<<30) +#define POOL_FLAG_PROMOTEEPOCH 1 +#define POOL_FLAG_ALLOWSELFCONFLICTS 2 +#define POOL_FLAG_OBSOLETEUSESPROVIDES 3 +#define POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES 4 +#define POOL_FLAG_OBSOLETEUSESCOLORS 5 +#define POOL_FLAG_NOINSTALLEDOBSOLETES 6 + /* ----------------------------------------------- */ @@ -195,6 +202,8 @@ extern void pool_setdebuglevel(Pool *pool, int level); #ifdef MULTI_SEMANTICS extern void pool_setdisttype(Pool *pool, int disttype); #endif +extern int pool_set_flag(Pool *pool, int flag, int value); +extern int pool_get_flag(Pool *pool, int flag); extern void pool_setvendorclasses(Pool *pool, const char **vendorclasses); extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4))); -- 2.7.4