Resolve dependencies to resolvables

This commit is contained in:
Ingo Weinhold 2011-06-25 17:13:55 +02:00
parent 4081d37dec
commit bd66b7e670
6 changed files with 63 additions and 4 deletions

View File

@ -268,7 +268,13 @@ PackageFSRoot::_AddPackage(Package* package)
dependenciesToUpdate.Add(dependency);
}
return fPackageLinksDirectory->AddPackage(package);
status_t error = fPackageLinksDirectory->AddPackage(package);
if (error != B_OK)
RETURN_ERROR(error);
_ResolveDependencies(dependenciesToUpdate);
return B_OK;
}
@ -317,7 +323,35 @@ PackageFSRoot::_ResolveDependencies(ResolvableDependencyList& dependencies)
if (dependencies.IsEmpty())
return;
// TODO:...
while (Dependency* dependency = dependencies.RemoveHead()) {
Package* package = dependency->Package();
_ResolveDependency(dependency);
// also resolve all other dependencies for that package
for (ResolvableDependencyList::Iterator it = dependencies.GetIterator();
(dependency = it.Next()) != NULL;) {
if (dependency->Package() == package) {
it.Remove();
_ResolveDependency(dependency);
}
}
fPackageLinksDirectory->UpdatePackageDependencies(package);
}
}
void
PackageFSRoot::_ResolveDependency(Dependency* dependency)
{
// get the resolvable family for the dependency
ResolvableFamily* resolvableFamily
= fResolvables.Lookup(dependency->Name());
if (resolvableFamily == NULL)
return;
// let the family resolve the dependency
resolvableFamily->ResolveDependency(dependency);
}

View File

@ -65,6 +65,7 @@ private:
void _ResolveDependencies(
ResolvableDependencyList& dependencies);
void _ResolveDependency(Dependency* dependency);
static status_t _GetOrCreateRoot(dev_t deviceID, ino_t nodeID,
PackageFSRoot*& _root);

View File

@ -297,6 +297,14 @@ PackageLinkDirectory::RemovePackage(Package* package,
}
void
PackageLinkDirectory::UpdatePackageDependencies(Package* package,
PackageLinksListener* listener)
{
// TODO:...
}
status_t
PackageLinkDirectory::_Update(PackageLinksListener* listener)
{

View File

@ -37,6 +37,8 @@ public:
PackageLinksListener* listener);
void RemovePackage(Package* package,
PackageLinksListener* listener);
void UpdatePackageDependencies(Package* package,
PackageLinksListener* listener);
bool IsEmpty() const
{ return fPackages.IsEmpty(); }

View File

@ -134,6 +134,8 @@ PackageLinksDirectory::AddPackage(Package* package)
void
PackageLinksDirectory::RemovePackage(Package* package)
{
NodeWriteLocker writeLocker(this);
// get the package's link directory and remove the package from it
PackageLinkDirectory* linkDirectory = package->LinkDirectory();
if (linkDirectory == NULL)
@ -141,8 +143,6 @@ PackageLinksDirectory::RemovePackage(Package* package)
BReference<PackageLinkDirectory> linkDirectoryReference(linkDirectory);
NodeWriteLocker writeLocker(this);
linkDirectory->RemovePackage(package, fListener);
// if empty, remove the link directory itself
@ -150,3 +150,16 @@ PackageLinksDirectory::RemovePackage(Package* package)
RemoveChild(linkDirectory);
}
void
PackageLinksDirectory::UpdatePackageDependencies(Package* package)
{
NodeWriteLocker writeLocker(this);
PackageLinkDirectory* linkDirectory = package->LinkDirectory();
if (linkDirectory == NULL)
return;
linkDirectory->UpdatePackageDependencies(package, fListener);
}

View File

@ -34,6 +34,7 @@ public:
status_t AddPackage(Package* package);
void RemovePackage(Package* package);
void UpdatePackageDependencies(Package* package);
private:
timespec fModifiedTime;