Skip to content

Commit

Permalink
- get rid of DEBINA_SEMANTICS, add pool->noarchid, add DISTTYPE_ARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Apr 3, 2012
1 parent d1275e7 commit 17ea16d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 51 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ENDIF (FEDORA)

IF (DEBIAN)
MESSAGE (STATUS "Building for Debian")
ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
ADD_DEFINITIONS (-DDEBIAN)
SET (ENABLE_DEBIAN ON)
ENDIF (DEBIAN)

Expand Down
36 changes: 23 additions & 13 deletions src/evr.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@



#if defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS)

#ifdef MULTI_SEMANTICS
# define solv_vercmp solv_vercmp_deb
#endif
#if defined(DEBIAN) || defined(MULTI_SEMANTICS)

/* debian type version compare */
int
solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
solv_vercmp_deb(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r, c1, c2;
while (1)
Expand Down Expand Up @@ -64,19 +60,15 @@ solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
}
}

#ifdef MULTI_SEMANTICS
# undef solv_vercmp
#endif

#endif

#if !defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS)
#if !defined(DEBIAN) || defined(MULTI_SEMANTICS)

/* rpm type version compare */
/* note: the code assumes that *q1 and *q2 are not alphanumeric! */

int
solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
solv_vercmp_rpm(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r = 0;
const char *e1, *e2;
Expand Down Expand Up @@ -134,8 +126,26 @@ solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)

#endif


/*
* the solv_vercmp variant your system uses.
*/
int
solv_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
{
#ifdef DEBIAN
return solv_vercmp_deb(s1, q1, s2, q2);
#else
return solv_vercmp_rpm(s1, q1, s2, q2);
#endif
}

#if defined(MULTI_SEMANTICS)
# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : &solv_ver##cmp))
# define solv_vercmp (*(pool->disttype == DISTTYPE_DEB ? &solv_vercmp_deb : &solv_ver##cmp_rpm))
#elif defined(DEBIAN)
# define solv_vercmp solv_vercmp_deb
#else
# define solv_vercmp solv_vercmp_rpm
#endif

/* edition (e:v-r) compare */
Expand Down
7 changes: 1 addition & 6 deletions src/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,8 @@ policy_illegal_archchange(Solver *solv, Solvable *s1, Solvable *s2)
}

/* we allow changes to/from noarch */
#ifndef DEBIAN_SEMANTICS
if (a1 == a2 || a1 == ARCH_NOARCH || a2 == ARCH_NOARCH)
if (a1 == a2 || a1 == pool->noarchid || a2 == pool->noarchid)
return 0;
#else
if (a1 == a2 || a1 == ARCH_ALL || a2 == ARCH_ALL)
return 0;
#endif
if (!pool->id2arch)
return 0;
a1 = a1 <= pool->lastarch ? pool->id2arch[a1] : 0;
Expand Down
26 changes: 19 additions & 7 deletions src/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ pool_create(void)
pool->nsolvables = 2;
memset(pool->solvables, 0, 2 * sizeof(Solvable));

queue_init(&pool->vendormap);

#ifdef DEBIAN
pool->disttype = DISTTYPE_DEB;
pool->noarchid = ARCH_ALL;
#else
pool->disttype = DISTTYPE_RPM;
pool->noarchid = ARCH_NOARCH;
#endif

/* initialize the system solvable */
s = pool->solvables + SYSTEMSOLVABLE;
s->name = SYSTEM_SYSTEM;
s->arch = ARCH_NOARCH;
s->arch = pool->noarchid;
s->evr = ID_EMPTY;

queue_init(&pool->vendormap);

pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
#ifdef FEDORA
pool->obsoleteusescolors = 1;
#endif
#ifdef DEBIAN
pool->disttype = DISTTYPE_DEB;
#endif
#ifdef RPM5
pool->forbidselfconflicts = 1;
pool->obsoleteusesprovides = 1;
Expand Down Expand Up @@ -125,6 +130,13 @@ void
pool_setdisttype(Pool *pool, int disttype)
{
pool->disttype = disttype;
if (disttype == DISTTYPE_RPM)
pool->noarchid == ARCH_NOARCH;
if (disttype == DISTTYPE_DEB)
pool->noarchid == ARCH_ALL;
if (disttype == DISTTYPE_ARCH)
pool->noarchid == ARCH_ANY;
pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
}
#endif

Expand Down Expand Up @@ -511,7 +523,7 @@ pool_queuetowhatprovides(Pool *pool, Queue *q)

#if defined(MULTI_SEMANTICS)
# define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
#elif defined(DEBIAN_SEMANTICS)
#elif defined(DEBIAN)
# define EVRCMP_DEPCMP EVRCMP_COMPARE
#else
# define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
Expand Down
3 changes: 3 additions & 0 deletions src/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ struct _Pool {
int noinstalledobsoletes; /* true: ignore obsoletes of installed packages */
int forbidselfconflicts; /* true: packages which conflict with itself are not installable */

Id noarchid; /* ARCH_NOARCH, ARCH_ALL, ARCH_ANY, ... */

/* hash for rel unification */
Hashtable relhashtbl; /* hashtable: (name,evr,op)Hash -> Id */
Hashmask relhashmask;
Expand All @@ -144,6 +146,7 @@ struct _Pool {

#define DISTTYPE_RPM 0
#define DISTTYPE_DEB 1
#define DISTTYPE_ARCH 2

#define SOLV_FATAL (1<<0)
#define SOLV_ERROR (1<<1)
Expand Down
6 changes: 1 addition & 5 deletions src/poolarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ pool_setarchpolicy(Pool *pool, const char *arch)
pool->lastarch = 0;
return;
}
#ifndef DEBIAN_SEMANTICS
id = ARCH_NOARCH;
#else
id = ARCH_ALL;
#endif
id = pool->noarchid;
lastarch = id + 255;
id2arch = solv_calloc(lastarch + 1, sizeof(Id));
id2arch[id] = 1; /* the "noarch" class */
Expand Down
23 changes: 12 additions & 11 deletions src/poolid.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,10 @@ pool_id2str(const Pool *pool, Id id)

static const char *rels[] = {
" ! ",
#ifndef DEBIAN_SEMANTICS
" > ",
#else
" >> ",
#endif
" = ",
" >= ",
#ifndef DEBIAN_SEMANTICS
" < ",
#else
" << ",
#endif
" <> ",
" <= ",
" <=> "
Expand All @@ -163,9 +155,18 @@ pool_id2rel(const Pool *pool, Id id)
rd = GETRELDEP(pool, id);
switch (rd->flags)
{
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
return rels[rd->flags & 7];
case 0: case 2: case 3:
case 5: case 6: case 7:
return rels[rd->flags];
#if !defined(DEBIAN) && !defined(MULTI_SEMANTICS)
case 1: case 4:
return rels[rd->flags];
#else
case 1:
return pool->disttype == DISTTYPE_DEB ? " >> " : rels[rd->flags];
case 4:
return pool->disttype == DISTTYPE_DEB ? " << " : rels[rd->flags];
#endif
case REL_AND:
return " & ";
case REL_OR:
Expand Down
17 changes: 9 additions & 8 deletions src/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,15 +1464,16 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
Reldep *rd = GETRELDEP(pool, what);
if (rd->flags == REL_EQ && select == SOLVER_SOLVABLE_NAME)
{
#if !defined(DEBIAN_SEMANTICS)
const char *evr = pool_id2str(pool, rd->evr);
if (strchr(evr, '-'))
set |= SOLVER_SETEVR;
if (pool->disttype != DISTTYPE_DEB)
{
const char *evr = pool_id2str(pool, rd->evr);
if (strchr(evr, '-'))
set |= SOLVER_SETEVR;
else
set |= SOLVER_SETEV;
}
else
set |= SOLVER_SETEV;
#else
set |= SOLVER_SETEVR;
#endif
set |= SOLVER_SETEVR;
}
if (rd->flags <= 7 && ISRELDEP(rd->name))
rd = GETRELDEP(pool, rd->name);
Expand Down

0 comments on commit 17ea16d

Please sign in to comment.