/*
- * Copyright (c) 2007, Novell Inc.
+ * Copyright (c) 2007-2009, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
* for further information
pool_freewhatprovides(pool);
}
-static Pool *pool_shrink_whatprovides_sortcmp_data;
-
static int
-pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp)
+pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
{
int r;
- Pool *pool = pool_shrink_whatprovides_sortcmp_data;
+ Pool *pool = dp;
Id oa, ob, *da, *db;
oa = pool->whatprovides[*(Id *)ap];
ob = pool->whatprovides[*(Id *)bp];
sorted = sat_malloc2(pool->ss.nstrings, sizeof(Id));
for (id = 0; id < pool->ss.nstrings; id++)
sorted[id] = id;
- pool_shrink_whatprovides_sortcmp_data = pool;
- qsort(sorted + 1, pool->ss.nstrings - 1, sizeof(Id), pool_shrink_whatprovides_sortcmp);
+ sat_sort(sorted + 1, pool->ss.nstrings - 1, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
last = 0;
lastid = 0;
for (i = 1; i < pool->ss.nstrings; i++)
pool->whatprovidesdataoff = off;
pool->whatprovidesdataleft = extra;
pool_shrink_whatprovides(pool);
- POOL_DEBUG(SAT_DEBUG_STATS, "whatprovides memory used: %ld K id array, %ld K data\n", ((unsigned long)pool->ss.nstrings + pool->nrels + WHATPROVIDES_BLOCK) / (1024/sizeof(Id)), ((unsigned long)pool->whatprovidesdataoff + pool->whatprovidesdataleft) / (1024/sizeof(Id)));
+ POOL_DEBUG(SAT_DEBUG_STATS, "whatprovides memory used: %d K id array, %d K data\n", (pool->ss.nstrings + pool->nrels + WHATPROVIDES_BLOCK) / (int)(1024/sizeof(Id)), (pool->whatprovidesdataoff + pool->whatprovidesdataleft) / (int)(1024/sizeof(Id)));
POOL_DEBUG(SAT_DEBUG_STATS, "createwhatprovides took %d ms\n", sat_timems(now));
}
/*
* free all of our whatprovides data
- * be careful, everything internalized with pool_queuetowhatprovides is gone, too
+ * be careful, everything internalized with pool_queuetowhatprovides is
+ * gone, too
*/
void
pool_freewhatprovides(Pool *pool)
return 1;
if (flags != 2 && flags != 5)
flags ^= 5;
+#ifdef DEBIAN_SEMANTICS
+ if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_COMPARE)))) != 0)
+ return 1;
+#else
if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_MATCH_RELEASE)))) != 0)
return 1;
+#endif
+ return 0;
+}
+
+/* match two dependencies */
+
+int
+pool_match_dep(Pool *pool, Id d1, Id d2)
+{
+ Reldep *rd1, *rd2;
+ int pflags, flags;
+
+ if (d1 == d2)
+ return 1;
+ if (!ISRELDEP(d1))
+ {
+ if (!ISRELDEP(d2))
+ return 0;
+ rd2 = GETRELDEP(pool, d2);
+ return pool_match_dep(pool, d1, rd2->name);
+ }
+ rd1 = GETRELDEP(pool, d1);
+ if (!ISRELDEP(d2))
+ {
+ return pool_match_dep(pool, rd1->name, d2);
+ }
+ rd2 = GETRELDEP(pool, d2);
+ if (!pool_match_dep(pool, rd1->name, rd2->name))
+ return 0;
+ pflags = rd1->flags;
+ flags = rd2->flags;
+ if (!pflags || !flags || pflags >= 8 || flags >= 8)
+ return 0;
+ if (flags == 7 || pflags == 7)
+ return 1;
+ if ((pflags & flags & 5) != 0)
+ return 1;
+ if (rd1->evr == rd2->evr)
+ {
+ if ((pflags & flags & 2) != 0)
+ return 1;
+ }
+ else
+ {
+ int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5);
+#ifdef DEBIAN_SEMANTICS
+ if ((f & (1 << (1 + evrcmp(pool, rd1->evr, rd2->evr, EVRCMP_COMPARE)))) != 0)
+ return 1;
+#else
+ if ((f & (1 << (1 + evrcmp(pool, rd1->evr, rd2->evr, EVRCMP_MATCH_RELEASE)))) != 0)
+ return 1;
+#endif
+ }
return 0;
}
{
case REL_AND:
case REL_WITH:
- pp = pool->whatprovidesdata + pool_whatprovides(pool, name);
- pp2 = pool->whatprovidesdata + pool_whatprovides(pool, evr);
+ pp = pool_whatprovides_ptr(pool, name);
+ pp2 = pool_whatprovides_ptr(pool, evr);
while ((p = *pp++) != 0)
{
for (pp3 = pp2; *pp3;)
}
break;
case REL_OR:
- pp = pool->whatprovidesdata + pool_whatprovides(pool, name);
+ pp = pool_whatprovides_ptr(pool, name);
while ((p = *pp++) != 0)
queue_push(&plist, p);
- pp = pool->whatprovidesdata + pool_whatprovides(pool, evr);
+ pp = pool_whatprovides_ptr(pool, evr);
while ((p = *pp++) != 0)
queue_pushunique(&plist, p);
break;
#endif
if (flags && flags < 8)
{
- pp = pool->whatprovidesdata + pool_whatprovides(pool, name);
+ pp = pool_whatprovides_ptr(pool, name);
while (ISRELDEP(name))
{
rd = GETRELDEP(pool, name);
else
{
int f = flags == 5 ? 5 : flags == 2 ? pflags : (flags ^ 5) & (pflags | 5);
+#ifdef DEBIAN_SEMANTICS
+ if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_COMPARE)))) != 0)
+ break;
+#else
if ((f & (1 << (1 + evrcmp(pool, pevr, evr, EVRCMP_MATCH_RELEASE)))) != 0)
break;
+#endif
}
}
if (!pid)
return dep;
}
-static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep)
+static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id dep)
+{
+ Id p, pp;
+ Solvable *sn = pool->solvables + n;
+
+ FOR_PROVIDES(p, pp, sn->name)
+ {
+ Solvable *s = pool->solvables + p;
+ if (s->name != sn->name || s->arch != sn->arch)
+ continue;
+ if ((map[p] & 9) == 9)
+ return 1;
+ }
+ return 0;
+}
+
+static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
{
Id p, pp;
int r = 0;
{
if (p == SYSTEMSOLVABLE)
return 1; /* always boring, as never constraining */
+ if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
+ continue;
+ if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
+ if (providedbyinstalled_multiversion(pool, map, p, dep))
+ continue;
if ((map[p] & 9) == 9)
return 9;
r |= map[p] & 17;
*/
void
-pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
+pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
{
int i, r, m, did;
Id p, *dp, con, *conp, req, *reqp;
conp = s->repo->idarraydata + s->conflicts;
while ((con = *conp++) != 0)
{
- dp = pool->whatprovidesdata + pool_whatprovides(pool, con);
+ dp = pool_whatprovides_ptr(pool, con);
for (; *dp; dp++)
map[p] |= 2; /* XXX: self conflict ? */
}
{
if (req == SOLVABLE_PREREQMARKER)
continue;
- r = providedbyinstalled(pool, map, req);
+ r = providedbyinstalled(pool, map, req, 0, 0);
if (!r)
{
/* decided and miss */
}
if (s->conflicts)
{
+ int ispatch = 0; /* see solver.c patch handling */
+
+ if (!strncmp("patch:", id2str(pool, s->name), 6))
+ ispatch = 1;
conp = s->repo->idarraydata + s->conflicts;
while ((con = *conp++) != 0)
{
- if ((providedbyinstalled(pool, map, con) & 1) != 0)
+ if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
{
map[p] = 2;
break;
if ((m == 1 || m == 17) && ISRELDEP(con))
{
con = dep2name(pool, con);
- if ((providedbyinstalled(pool, map, con) & 1) != 0)
+ if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
m = 9;
}
}
obsp = s->repo->idarraydata + s->obsoletes;
while ((obs = *obsp++) != 0)
{
- if ((providedbyinstalled(pool, map, obs) & 1) != 0)
+ if ((providedbyinstalled(pool, map, obs, 0, 0) & 1) != 0)
{
map[p] = 2;
break;
free(map);
}
+void
+pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
+{
+ pool_trivial_installable_noobsoletesmap(pool, installedmap, pkgs, res, 0);
+}
+
// EOF