pkgman install: Simplify transaction creation
This commit is contained in:
@@ -357,16 +357,8 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
||||
DIE(error, "failed to create transaction");
|
||||
|
||||
// download the new packages and prepare the transaction
|
||||
for (int32 i = 0; const BSolverResultElement* element = result.ElementAt(i);
|
||||
for (int32 i = 0; BSolverPackage* package = packagesToActivate.ItemAt(i);
|
||||
i++) {
|
||||
BSolverPackage* package = element->Package();
|
||||
|
||||
switch (element->Type()) {
|
||||
case BSolverResultElement::B_TYPE_INSTALL:
|
||||
{
|
||||
if (installedRepositories.HasItem(package->Repository()))
|
||||
continue;
|
||||
|
||||
// get package URL and target entry
|
||||
Repository* repository
|
||||
= static_cast<Repository*>(package->Repository());
|
||||
@@ -394,18 +386,16 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
||||
DIE(B_NO_MEMORY,
|
||||
"failed to add package to activate to transaction");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BSolverResultElement::B_TYPE_UNINSTALL:
|
||||
for (int32 i = 0; BSolverPackage* package = packagesToDeactivate.ItemAt(i);
|
||||
i++) {
|
||||
// add package to transaction
|
||||
if (!transaction.AddPackageToDeactivate(
|
||||
package->Info().CanonicalFileName())) {
|
||||
DIE(B_NO_MEMORY,
|
||||
"failed to add package to deactivate to transaction");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// commit the transaction
|
||||
|
||||
Reference in New Issue
Block a user