Skip to content

Commit 933f0e4

Browse files
committed
Add pool_dep_fulfilled_in_map function
This is can be used to determine dependency closure on a given set of packages (even with complex dependencies).
1 parent 1181b96 commit 933f0e4

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

doc/libsolv-pool.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ by the ``evr'' parts must overlap.
562562
Like pool_match_dep, but the provider is the "self-provides" dependency
563563
of the Solvable _s_, i.e. the dependency ``s->name = s->evr''.
564564
565+
int pool_dep_fulfilled_in_map(Pool *pool, const Map *map, Id dep);
566+
567+
Returns ``1'' if the dependency _dep_ is provided by at least one package
568+
from _map_, otherwise ``0'' is returned.
565569
566570
Whatprovides Index
567571
------------------

src/libsolv.ver

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ SOLV_1.0 {
9191
pool_lookup_str;
9292
pool_lookup_void;
9393
pool_match_dep;
94+
pool_dep_fulfilled_in_map;
9495
pool_match_nevr_rel;
9596
pool_prepend_rootdir;
9697
pool_prepend_rootdir_tmp;

src/pool.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,4 +2104,74 @@ int (*pool_get_custom_vendorcheck(Pool *pool))(Pool *, Solvable *, Solvable *)
21042104
return pool->custom_vendorcheck;
21052105
}
21062106

2107+
static int
2108+
pool_dep_fulfilled_in_map_cplx(Pool *pool, const Map *map, Reldep *rd)
2109+
{
2110+
if (rd->flags == REL_COND)
2111+
{
2112+
if (ISRELDEP(rd->evr))
2113+
{
2114+
Reldep *rd2 = GETRELDEP(pool, rd->evr);
2115+
if (rd2->flags == REL_ELSE)
2116+
{
2117+
if (pool_dep_fulfilled_in_map(pool, map, rd2->name))
2118+
return pool_dep_fulfilled_in_map(pool, map, rd->name);
2119+
return pool_dep_fulfilled_in_map(pool, map, rd2->evr);
2120+
}
2121+
}
2122+
if (pool_dep_fulfilled_in_map(pool, map, rd->name))
2123+
return 1;
2124+
return !pool_dep_fulfilled_in_map(pool, map, rd->evr);
2125+
}
2126+
if (rd->flags == REL_UNLESS)
2127+
{
2128+
if (ISRELDEP(rd->evr))
2129+
{
2130+
Reldep *rd2 = GETRELDEP(pool, rd->evr);
2131+
if (rd2->flags == REL_ELSE)
2132+
{
2133+
if (!pool_dep_fulfilled_in_map(pool, map, rd2->name))
2134+
return pool_dep_fulfilled_in_map(pool, map, rd->name);
2135+
return pool_dep_fulfilled_in_map(pool, map, rd2->evr);
2136+
}
2137+
}
2138+
if (!pool_dep_fulfilled_in_map(pool, map, rd->name))
2139+
return 0;
2140+
return !pool_dep_fulfilled_in_map(pool, map, rd->evr);
2141+
}
2142+
if (rd->flags == REL_AND)
2143+
{
2144+
if (!pool_dep_fulfilled_in_map(pool, map, rd->name))
2145+
return 0;
2146+
return pool_dep_fulfilled_in_map(pool, map, rd->evr);
2147+
}
2148+
if (rd->flags == REL_OR)
2149+
{
2150+
if (pool_dep_fulfilled_in_map(pool, map, rd->name))
2151+
return 1;
2152+
return pool_dep_fulfilled_in_map(pool, map, rd->evr);
2153+
}
2154+
return 0;
2155+
}
2156+
2157+
2158+
int pool_dep_fulfilled_in_map(Pool *pool, const Map *map, Id dep)
2159+
{
2160+
Id p, pp;
2161+
2162+
if (ISRELDEP(dep)) {
2163+
Reldep *rd = GETRELDEP(pool, dep);
2164+
if (rd->flags == REL_COND || rd->flags == REL_UNLESS ||
2165+
rd->flags == REL_AND || rd->flags == REL_OR)
2166+
return pool_dep_fulfilled_in_map_cplx(pool, map, rd);
2167+
if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
2168+
return 0;
2169+
}
2170+
FOR_PROVIDES(p, pp, dep) {
2171+
if (MAPTST(map, p))
2172+
return 1;
2173+
}
2174+
return 0;
2175+
}
2176+
21072177
/* EOF */

src/pool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ Id pool_id2langid(Pool *pool, Id id, const char *lang, int create);
305305

306306
int pool_intersect_evrs(Pool *pool, int pflags, Id pevr, int flags, Id evr);
307307
int pool_match_dep(Pool *pool, Id d1, Id d2);
308+
int pool_dep_fulfilled_in_map(Pool *pool, const Map *map, Id dep);
308309

309310
/* semi private, used in pool_match_nevr */
310311
int pool_match_nevr_rel(Pool *pool, Solvable *s, Id d);

0 commit comments

Comments
 (0)