let sources2packages ?(src="src") archs l =
let archs = "all"::"any"::archs in
let select = function
|(v,(((false,_)::_) as al)) when
List.for_all (fun (_,a) -> not(List.mem a archs)) al -> Some v
|(v,(((true,_)::_) as al)) when
List.exists (fun (_,a) -> List.mem a archs) al -> Some v
|(v,[]) -> Some v
|_ -> None
in
let conflicts l = List.filter_map select l in
let depends ll =
List.filter_map (fun l ->
match List.filter_map select l with
|[] -> None
| l -> Some l
) ll
in
let bins pkg = String.concat "," pkg.binary in
List.filter_map (fun pkg ->
let pkgarchs = pkg.architecture in
if List.exists (fun a -> List.mem a archs) pkgarchs then
Some (
{ Packages.default_package with
Packages.name = src ^ sep ^ pkg.name ;
source = (pkg.name, Some pkg.version);
version = pkg.version;
depends = depends (pkg.build_depends_indep @ pkg.build_depends);
conflicts = conflicts (pkg.build_conflicts_indep @ pkg.build_conflicts);
architecture = String.concat "," pkg.architecture;
extras = [("type",src);("binaries",bins pkg)]
}
)
else None
) l