cpack_repository/commit
Distinguish different dependency relations
author | Jan Wielemaker |
---|---|
Sun Nov 14 13:05:13 2010 +0100 | |
committer | Jan Wielemaker |
Sun Nov 14 13:05:13 2010 +0100 | |
commit | d9a85b44970ae0a424abedd1f709a0995ccec4b7 |
tree | 95a797a93a727a6da9b9346fe2904be38d261ffc |
parent | d3b4ed04eceaa8785d505cd514f8d634faca01be |
Diff style: patch stat
diff --git a/components/cpack/graphs.pl b/components/cpack/graphs.pl index 84d578a..5252361 100644 --- a/components/cpack/graphs.pl +++ b/components/cpack/graphs.pl @@ -109,8 +109,23 @@ bf_expand([D-F|AG0], AG, MaxBranch, Triples) :- append(AG0, Dsts, AG). related(S, O, rdf(S,P,O)) :- - rdf_equal(cpack:requiresPackage, P), - cpack_requires(S, O, _Why). + cpack_requires_p(S, O, P). related(O, S, rdf(S,P,O)) :- - rdf_equal(cpack:requiresPackage, P), - cpack_requires(S, O, _Why). + cpack_requires_p(S, O, P). + +:- rdf_meta + req_type_predicate(?, r). + +cpack_requires_p(Package, Required, P) :- + cpack_requires(Package, Required, Reasons), + maplist(functor_name, Reasons, Types), + sort(Types, Set), + ( Set = [One] + -> req_type_predicate(One, P) + ; rdf_equal(cpack:requiresPackage, P) + ). + +functor_name(Term, Name) :- functor(Term, Name, _). + +req_type_predicate(token, cpack:requiresPackageByToken). +req_type_predicate(file_ref, cpack:requiresPackageByFile). diff --git a/lib/cpack/dependency.pl b/lib/cpack/dependency.pl index 0bba0ce..670913e 100644 --- a/lib/cpack/dependency.pl +++ b/lib/cpack/dependency.pl @@ -30,7 +30,8 @@ :- module(cpack_dependency, [ file_used_by_file_in_package/3, % +File, -UsedBy, -Package - cpack_requires/3 % +Package, -Package, -Why + cpack_requires/3, % +Package, -Package, -Why + cpack_conflicts/3 % +Package, -Package, -Why ]). :- use_module(library(semweb/rdf_db)). :- use_module(library(semweb/rdfs)). @@ -52,16 +53,20 @@ file_used_by_file_in_package(File, UsedBy, Pack) :- rdf_has(UsedBy, cpack:inPack, Pack). -%% cpack_requires(+Package, -Required, -Why) is nondet. +%% cpack_requires(+Package, -Required, -Reasons) is nondet. % -% True when Package requires Required. +% True when Package requires Required. Reasons is an ordered set +% of reasons. Individual reasons are one of: +% +% * token(Name) +% Package requires _token_ that is provided by Required. +% * file_ref(FileRef) +% Package uses the file FileRef, which is provided by Required -cpack_requires(Package, Required, token) :- - cpack_requires_by_token(Package, Required). -cpack_requires(Package, Required, file) :- - cpack_requires_by_file(Package, Required). +cpack_requires(Package, Required, AllReasons) :- + setof(Why, cpack_requires_by(Package, Required, Why), AllReasons). -cpack_requires_by_token(Package, Required) :- +cpack_requires_by(Package, Required, token(Token)) :- rdf_has(Package, cpack:requires, Req), ( rdf_is_literal(Req) -> Token = Req @@ -69,9 +74,15 @@ cpack_requires_by_token(Package, Required) :- ), rdf_has(Required, cpack:provides, Token). -cpack_requires_by_file(Package, Required) :- +cpack_requires_by(Package, Required, file_ref(FileRef)) :- rdf_has(File, cpack:inPack, Package), rdf_has(File, cpack:usesFile, FileRef), rdf_has(ReqFile, cpack:resolves, FileRef), rdf_has(ReqFile, cpack:inPack, Required), Required \== Package. + +%% cpack_conflicts(+Package, -Conflict, -Why) is nondet. +% +% True when Package and Conflict are in conflict. + +cpack_conflicts(_Package, _Conflict, _Why).