X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/c97fd4ec4a34eb15eb8985890a47e768f4b94f0d..7898bd970a791bb8892b0dfdffc683828a447900:/cmdline/apt-get.cc diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 411b16e90..e8e5a8c39 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1393,15 +1393,20 @@ bool DoUpdate(CommandLine &CmdL) bool DoAutomaticRemove(CacheFile &Cache) { bool Debug = _config->FindI("Debug::pkgAutoRemove",false); + bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false); + bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove"); pkgDepCache::ActionGroup group(*Cache); if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; - if (_config->FindB("APT::Get::AutomaticRemove") && - _config->FindB("APT::Get::Remove",true) == false) - return _error->Error(_("We are not supposed to delete stuff, can't " - "start AutoRemover")); + if (_config->FindB("APT::Get::Remove",true) == false && + doAutoRemove == true) + { + c1out << _("We are not supposed to delete stuff, can't start " + "AutoRemover") << std::endl; + doAutoRemove = false; + } string autoremovelist, autoremoveversions; // look over the cache to see what can be removed @@ -1412,10 +1417,14 @@ bool DoAutomaticRemove(CacheFile &Cache) if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) if(Debug) std::cout << "We could delete %s" << Pkg.Name() << std::endl; - - autoremovelist += string(Pkg.Name()) + " "; - autoremoveversions += string(Cache[Pkg].CandVersion) + " "; - if (_config->FindB("APT::Get::AutomaticRemove")) + + // only show stuff in the list that is not yet marked for removal + if(Cache[Pkg].Delete() == false) + { + autoremovelist += string(Pkg.Name()) + " "; + autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; + } + if (doAutoRemove) { if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) @@ -1425,9 +1434,9 @@ bool DoAutomaticRemove(CacheFile &Cache) } } } - ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); - if (!_config->FindB("APT::Get::AutomaticRemove") && - autoremovelist.size() > 0) + if (!hideAutoRemove) + ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + if (!doAutoRemove && !hideAutoRemove && autoremovelist.size() > 0) c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; // Now see if we destroyed anything @@ -1480,6 +1489,7 @@ bool DoInstall(CommandLine &CmdL) if (Cache->BrokenCount() != 0) BrokenFix = true; + unsigned int AutoMarkChanged = 0; unsigned int ExpectedInst = 0; unsigned int Packages = 0; pkgProblemResolver Fix(Cache); @@ -1602,6 +1612,19 @@ bool DoInstall(CommandLine &CmdL) return false; if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) return false; + + // see if we need to fix the auto-mark flag + // e.g. apt-get install foo + // where foo is marked automatic + if(!Remove && + Cache[Pkg].Install() == false && + (Cache[Pkg].Flags & pkgCache::Flag::Auto)) + { + ioprintf(c1out,_("%s set to manual installed.\n"), + Pkg.Name()); + Cache->MarkAuto(Pkg,false); + AutoMarkChanged++; + } } } @@ -1764,6 +1787,14 @@ 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 (AutoMarkChanged > 0 && + Cache->DelCount() == 0 && Cache->InstCount() == 0 && + Cache->BadCount() == 0) + Cache->writeStateFile(NULL); + // See if we need to prompt if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0) return InstallPackages(Cache,false,false); @@ -2556,7 +2587,6 @@ void GetInitialize() _config->Set("APT::Get::Fix-Broken",false); _config->Set("APT::Get::Force-Yes",false); _config->Set("APT::Get::List-Cleanup",true); - _config->Set("APT::Get::AutomaticRemove",false); } /*}}}*/ // SigWinch - Window size change signal handler /*{{{*/