% Input predicates, which represent the state of the system at one point: % % installed(Package, Root) - package Package is physically present in root Root. % is_prefix(yes/no) - whether this is Gentoo Prefix, i.e. everything happens inside the prefix % d_HDEPEND(Package, DependPackage) - Package has a HDEPEND on DependPackage % d_RDEPEND(Package, DependPackage) - ... has RDEPEND ... % d_DEPEND(Package, DependPackage) % d_PDEPEND(Package, DependPackage) % d_BADEPEND(Package, DependPackage) % d_IDEPEND(Package, DependPackage) % Get "host root" (for HDEPENDs and IDEPENDs). % If this is Gentoo Prefix, produces Root. % Otherwise, produces '/'. host_root(Root, Root) :- is_prefix(yes). host_root(Root, '/') :- is_prefix(no). % package Package is installed in root Root and has RDEPENDs satisfied installed_correctly(Package, Root) :- % must be physically installed installed(Package, Root), % all RDEPENDs must be installed correctly forall(d_RDEPEND(Package, RunDependPackage), installed_correctly(RunDependPackage, Root)). % package Package is installed correctly and all PDEPENDs are satisfied installed_completely(Package, Root) :- % must be physically installed installed(Package, Root), % all RDEPENDs must be installed completely forall(d_RDEPEND(Package, RunDependPackage), installed_completely(RunDependPackage, Root)), % all PDEPENDs must be installed completely forall(d_PDEPEND(Package, PostDependPackage), installed_completely(PostDependPackage, Root)). % package Package for root Root can be built right now can_be_built(Package, Root) :- % all HDEPENDs are satisfied host_root(Root, HostRoot), forall(d_HDEPEND(Package, HostDependPackage), installed_correctly(HostDependPackage, HostRoot)), % should this be installed_completely()? % all DEPENDs are satisfied forall(d_DEPEND(Package, DependPackage), can_be_built_against(DependPackage, Root)). % package Package in root Root can be built against, i.e. successfully used % within a DEPEND. can_be_built_against(Package, Root) :- % must be installed correctly installed_correctly(Package, Root), % all its BADEPENDs must be able to be built against forall(d_BADEPEND(Package, BuildAgainstPackage), can_be_built_against(BuildAgainstPackage, Root)). % package Package has install dependencies satisfied for % installing or removing from root Root install_deps_satisfied(Package, Root) :- host_root(Root, HostRoot), forall(d_IDEPEND(Package, InstallDependPackage), installed_correctly(InstallDependPackage, HostRoot)). % should this be installed_completely()?