cpack_repository/commit

ADDED: Provide explicit information about package dependencies using a new package property requires/1.

authorJan Wielemaker
Thu Jun 23 15:35:12 2011 +0200
committerJan Wielemaker
Thu Jun 23 15:35:12 2011 +0200
commit93c16fda37e77a127f98c4d12717d077d0e0da6b
treedb740615efceee28d9575a7a58e834194e0df1a6
parent66da8dd748a375b0b6511154372b97449b75d5e5
Diff style: patch stat
diff --git a/api/cpack.pl b/api/cpack.pl
index 4b2d1ad..73c82bf 100644
--- a/api/cpack.pl
+++ b/api/cpack.pl
@@ -155,17 +155,23 @@ client_error(Term0, Term) :-
 %	    * files(ListOfFile)
 %	    Each file is a term file(Path, Options), where options is
 %	        - module(Module)
+%	    * requires(ListOfPackages)
 
 pack_install_data(Pack, Data) :-
-	cpack_list(Pack, List),
-	maplist(pack_info(install), List, Data).
+	cpack_list(Pack, List, Dependencies),
+	maplist(pack_info(install, Dependencies), List, Data).
 
-pack_info(Type, Pack, cpack(Name, Options)) :-
+pack_info(Type, Dependencies, Pack, cpack(Name, Options)) :-
 	rdf_has(Pack, cpack:packageName, literal(Name)),
+	memberchk(Pack-PackDeps, Dependencies),
+	maplist(pack_name, PackDeps, PackDepNames),
 	findall(O, ( pack_option(Pack, O, Types),
 		     memberchk(Type, Types)
 		   ),
-		Options).
+		Options, [requires(PackDepNames)]).
+
+pack_name(Pack, Name) :-
+	rdf_has(Pack, cpack:packageName, literal(Name)), !.
 
 pack_option(Pack, url(Pack), [install]).
 pack_option(Pack, title(Title), [install]) :-
@@ -213,11 +219,11 @@ file_option(URI, size(Bytes)) :-
 
 cpack_clone_data(_Request) :-
 	findall(Pack, rdfs_individual_of(Pack, cpack:'Package'), Packs0),
-	(   catch(cpack_list(Packs0, Packs), _, fail)
+	(   catch(cpack_list(Packs0, Packs, Dependencies), _, fail)
 	->  true
 	;   Packs = Packs0
 	),
-	maplist(pack_info(clone), Packs, Data),
+	maplist(pack_info(clone, Dependencies), Packs, Data),
 	format('Content-type: application/x-prolog~n~n'),
 	format('% Server clone data~n~n', []),
 	maplist(write_clause, Data).
diff --git a/lib/cpack/dependency.pl b/lib/cpack/dependency.pl
index a9e7889..cbcc931 100644
--- a/lib/cpack/dependency.pl
+++ b/lib/cpack/dependency.pl
@@ -33,6 +33,7 @@
 	    cpack_requires/3,		% +Package, -Package, -Why
 	    cpack_conflicts/3,		% +Package, -Package, -Why
 	    cpack_list/2,		% +Package, -ListOfImplied
+	    cpack_list/3,		% +Package, -ListOfImplied, -Dependencies
 	    cpack_not_satisfied/2,	% +Package, -Reasons
 	    file_not_satisfied/2,	% +File, -Reasons
 	    file_imports_from/3,	% +File, -Imports, -From
@@ -136,12 +137,15 @@ cpack_conflicts_by(Package, Conflict, same_file(Path,File1,File2)) :-
 		 *******************************/
 
 %%	cpack_list(+Pack, -PackList) is det.
+%%	cpack_list(+Pack, -PackList, -UGraph) is det.
 %
 %	PackList is a list of all packages  that need to be installed to
 %	get Pack working. This list is ensured to contain Pack.
 %
 %	@param	Pack is either the URI of a single Pack or a list of
 %		these.
+%	@param	UGraph is a ugraph of Pack-ListOfRequired. See
+%		library(ugraph) for details.
 %
 %	@tbd	Toplogical sorting may not be possible.  As ordering is
 %		not always necessary, we should try to relax
@@ -151,6 +155,9 @@ cpack_conflicts_by(Package, Conflict, same_file(Path,File1,File2)) :-
 %		second, libraries must be loaded before applications.
 
 cpack_list(Pack, Packs) :-
+	cpack_list(Pack, Packs, _).
+
+cpack_list(Pack, Packs, Ugraph) :-
 	dependency_ugraph(Pack, Ugraph),
 	(   sort_dependencies(Ugraph, Packs)
 	->  check_conflicts(Packs),