Skip to content

Commit b60858c

Browse files
authored
Merge pull request #592 from kontura/dep_fulfilled
Add pool_dep_fulfilled_in_map function
2 parents f81f180 + 933f0e4 commit b60858c

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

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
@@ -754,4 +754,74 @@ int (*pool_get_custom_vendorcheck(Pool *pool))(Pool *, Solvable *, Solvable *)
754754
return pool->custom_vendorcheck;
755755
}
756756

757+
static int
758+
pool_dep_fulfilled_in_map_cplx(Pool *pool, const Map *map, Reldep *rd)
759+
{
760+
if (rd->flags == REL_COND)
761+
{
762+
if (ISRELDEP(rd->evr))
763+
{
764+
Reldep *rd2 = GETRELDEP(pool, rd->evr);
765+
if (rd2->flags == REL_ELSE)
766+
{
767+
if (pool_dep_fulfilled_in_map(pool, map, rd2->name))
768+
return pool_dep_fulfilled_in_map(pool, map, rd->name);
769+
return pool_dep_fulfilled_in_map(pool, map, rd2->evr);
770+
}
771+
}
772+
if (pool_dep_fulfilled_in_map(pool, map, rd->name))
773+
return 1;
774+
return !pool_dep_fulfilled_in_map(pool, map, rd->evr);
775+
}
776+
if (rd->flags == REL_UNLESS)
777+
{
778+
if (ISRELDEP(rd->evr))
779+
{
780+
Reldep *rd2 = GETRELDEP(pool, rd->evr);
781+
if (rd2->flags == REL_ELSE)
782+
{
783+
if (!pool_dep_fulfilled_in_map(pool, map, rd2->name))
784+
return pool_dep_fulfilled_in_map(pool, map, rd->name);
785+
return pool_dep_fulfilled_in_map(pool, map, rd2->evr);
786+
}
787+
}
788+
if (!pool_dep_fulfilled_in_map(pool, map, rd->name))
789+
return 0;
790+
return !pool_dep_fulfilled_in_map(pool, map, rd->evr);
791+
}
792+
if (rd->flags == REL_AND)
793+
{
794+
if (!pool_dep_fulfilled_in_map(pool, map, rd->name))
795+
return 0;
796+
return pool_dep_fulfilled_in_map(pool, map, rd->evr);
797+
}
798+
if (rd->flags == REL_OR)
799+
{
800+
if (pool_dep_fulfilled_in_map(pool, map, rd->name))
801+
return 1;
802+
return pool_dep_fulfilled_in_map(pool, map, rd->evr);
803+
}
804+
return 0;
805+
}
806+
807+
808+
int pool_dep_fulfilled_in_map(Pool *pool, const Map *map, Id dep)
809+
{
810+
Id p, pp;
811+
812+
if (ISRELDEP(dep)) {
813+
Reldep *rd = GETRELDEP(pool, dep);
814+
if (rd->flags == REL_COND || rd->flags == REL_UNLESS ||
815+
rd->flags == REL_AND || rd->flags == REL_OR)
816+
return pool_dep_fulfilled_in_map_cplx(pool, map, rd);
817+
if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
818+
return 0;
819+
}
820+
FOR_PROVIDES(p, pp, dep) {
821+
if (MAPTST(map, p))
822+
return 1;
823+
}
824+
return 0;
825+
}
826+
757827
/* 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)