BSolverPackage* PackageManager::_GetSolverPackage(PackageInfoRef package) { int32 flags = BSolver::B_FIND_IN_NAME; if (package->State() == ACTIVATED || package->State() == INSTALLED) flags |= BSolver::B_FIND_INSTALLED_ONLY; BObjectList<BSolverPackage> packages; status_t result = Solver()->FindPackages(package->Title(), flags, packages); if (result == B_OK) { for (int32 i = 0; i < packages.CountItems(); i++) { BSolverPackage* solverPackage = packages.ItemAt(i); if (solverPackage->Name() != package->Title()) continue; else if (package->State() == NONE && dynamic_cast<BPackageManager::RemoteRepository*>( solverPackage->Repository()) == NULL) { continue; } return solverPackage; } } return NULL; }
int32 BPackageManager::_FindBasePackage(const PackageList& packages, const BPackageInfo& info) { if (info.BasePackage().IsEmpty()) return -1; // find the requirement matching the base package BPackageResolvableExpression* basePackage = NULL; int32 count = info.RequiresList().CountItems(); for (int32 i = 0; i < count; i++) { BPackageResolvableExpression* requires = info.RequiresList().ItemAt(i); if (requires->Name() == info.BasePackage()) { basePackage = requires; break; } } if (basePackage == NULL) { fUserInteractionHandler->Warn(B_OK, "package %s-%s doesn't have a " "matching requires for its base package \"%s\"", info.Name().String(), info.Version().ToString().String(), info.BasePackage().String()); return -1; } // find the first package matching the base package requires count = packages.CountItems(); for (int32 i = 0; i < count; i++) { BSolverPackage* package = packages.ItemAt(i); if (package->Name() == basePackage->Name() && package->Info().Matches(*basePackage)) { return i; } } return -1; }