|
|
@@ -577,31 +577,28 @@ bool DoAutomaticRemove(CacheFile &Cache)
|
|
|
}
|
|
|
/*}}}*/
|
|
|
|
|
|
+static const unsigned short MOD_REMOVE = 1;
|
|
|
+static const unsigned short MOD_INSTALL = 2;
|
|
|
|
|
|
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache)
|
|
|
+{
|
|
|
+ std::map<unsigned short, APT::VersionSet> verset;
|
|
|
+ return DoCacheManipulationFromCommandLine(CmdL, Cache, verset);
|
|
|
+}
|
|
|
|
|
|
-
|
|
|
-// DoInstall - Install packages from the command line /*{{{*/
|
|
|
-// ---------------------------------------------------------------------
|
|
|
-/* Install named packages */
|
|
|
-bool DoInstall(CommandLine &CmdL)
|
|
|
+bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
|
|
|
+ std::map<unsigned short, APT::VersionSet> &verset)
|
|
|
{
|
|
|
- CacheFile Cache;
|
|
|
- if (Cache.OpenForInstall() == false ||
|
|
|
- Cache.CheckDeps(CmdL.FileSize() != 1) == false)
|
|
|
- return false;
|
|
|
-
|
|
|
+
|
|
|
// Enter the special broken fixing mode if the user specified arguments
|
|
|
bool BrokenFix = false;
|
|
|
if (Cache->BrokenCount() != 0)
|
|
|
BrokenFix = true;
|
|
|
|
|
|
- pkgProblemResolver* Fix = NULL;
|
|
|
+ SPtr<pkgProblemResolver> Fix;
|
|
|
if (_config->FindB("APT::Get::CallResolver", true) == true)
|
|
|
Fix = new pkgProblemResolver(Cache);
|
|
|
|
|
|
- static const unsigned short MOD_REMOVE = 1;
|
|
|
- static const unsigned short MOD_INSTALL = 2;
|
|
|
-
|
|
|
unsigned short fallback = MOD_INSTALL;
|
|
|
if (strcasecmp(CmdL.FileList[0],"remove") == 0)
|
|
|
fallback = MOD_REMOVE;
|
|
|
@@ -622,14 +619,12 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-",
|
|
|
APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::NEWEST));
|
|
|
CacheSetHelperAPTGet helper(c0out);
|
|
|
- std::map<unsigned short, APT::VersionSet> verset = APT::VersionSet::GroupedFromCommandLine(Cache,
|
|
|
+ verset = APT::VersionSet::GroupedFromCommandLine(Cache,
|
|
|
CmdL.FileList + 1, mods, fallback, helper);
|
|
|
|
|
|
if (_error->PendingError() == true)
|
|
|
{
|
|
|
helper.showVirtualPackageErrors(Cache);
|
|
|
- if (Fix != NULL)
|
|
|
- delete Fix;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -663,8 +658,6 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
|
|
|
if (_error->PendingError() == true)
|
|
|
{
|
|
|
- if (Fix != NULL)
|
|
|
- delete Fix;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -675,8 +668,6 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
{
|
|
|
c1out << _("You might want to run 'apt-get -f install' to correct these:") << std::endl;
|
|
|
ShowBroken(c1out,Cache,false);
|
|
|
- if (Fix != NULL)
|
|
|
- delete Fix;
|
|
|
return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."));
|
|
|
}
|
|
|
|
|
|
@@ -684,7 +675,6 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
{
|
|
|
// Call the scored problem resolver
|
|
|
Fix->Resolve(true);
|
|
|
- delete Fix;
|
|
|
}
|
|
|
|
|
|
// Now we check the state of the packages,
|
|
|
@@ -718,6 +708,34 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
if (!DoAutomaticRemove(Cache))
|
|
|
return false;
|
|
|
|
|
|
+ // if nothing changed in the cache, but only the automark information
|
|
|
+ // we write the StateFile here, otherwise it will be written in
|
|
|
+ // cache.commit()
|
|
|
+ if (InstallAction.AutoMarkChanged > 0 &&
|
|
|
+ Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
|
|
|
+ Cache->BadCount() == 0 &&
|
|
|
+ _config->FindB("APT::Get::Simulate",false) == false)
|
|
|
+ Cache->writeStateFile(NULL);
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// DoInstall - Install packages from the command line /*{{{*/
|
|
|
+// ---------------------------------------------------------------------
|
|
|
+/* Install named packages */
|
|
|
+bool DoInstall(CommandLine &CmdL)
|
|
|
+{
|
|
|
+ CacheFile Cache;
|
|
|
+ if (Cache.OpenForInstall() == false ||
|
|
|
+ Cache.CheckDeps(CmdL.FileSize() != 1) == false)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ std::map<unsigned short, APT::VersionSet> verset;
|
|
|
+
|
|
|
+ if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset))
|
|
|
+ return false;
|
|
|
+
|
|
|
/* Print out a list of packages that are going to be installed extra
|
|
|
to what the user asked */
|
|
|
if (Cache->InstCount() != verset[MOD_INSTALL].size())
|
|
|
@@ -833,15 +851,6 @@ bool DoInstall(CommandLine &CmdL)
|
|
|
|
|
|
}
|
|
|
|
|
|
- // if nothing changed in the cache, but only the automark information
|
|
|
- // we write the StateFile here, otherwise it will be written in
|
|
|
- // cache.commit()
|
|
|
- if (InstallAction.AutoMarkChanged > 0 &&
|
|
|
- Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
|
|
|
- Cache->BadCount() == 0 &&
|
|
|
- _config->FindB("APT::Get::Simulate",false) == false)
|
|
|
- Cache->writeStateFile(NULL);
|
|
|
-
|
|
|
// See if we need to prompt
|
|
|
// FIXME: check if really the packages in the set are going to be installed
|
|
|
if (Cache->InstCount() == verset[MOD_INSTALL].size() && Cache->DelCount() == 0)
|