summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2021-03-18 17:37:49 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2021-04-26 13:00:24 +0200
commitd6f3458badf2cfea3ca7de7632ae31daff5742be (patch)
tree7acc19c1e590fe8c2c81ef6609fa1a5a863d90da /apt-private
parent9a54e70c1040379fb06827bacb461c61e341e694 (diff)
Call MarkAndSweep only manually in apt-get for autoremove
An interactive tool like aptitude needs these flags current far more often than we do as a user can see them in apt only in one very well defined place – the autoremove display block – so we don't need to run it up to four times while a normal "apt install" is processed as that is just busywork. The effect on runtime is minimal, as a single run doesn't take too long anyhow, but it cuts down tremendously on debug output at the expense of requiring some manual handholding. This is opt-in so that aptitude doesn't need to change nor do we need to change our own tools like "apt list" where it is working correctly as intended. A special flag and co is needed as we want to prevent the ActionGroup inside pkgDepCache::Init to be inhibited already so we need to insert ourselves while the DepCache is still in the process of being built. This is also the reason why the debug output in some tests changed to all unmarked, but that is fine as the marking could have been already obsoleted by the actions taken, just inhibited by a proper action group.
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-install.cc21
-rw-r--r--apt-private/private-source.cc3
2 files changed, 16 insertions, 8 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 0c26c4275..414a00b9f 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -80,6 +80,16 @@ bool CheckNothingBroken(CacheFile &Cache) /*{{{*/
// ---------------------------------------------------------------------
/* This displays the informative messages describing what is going to
happen and then calls the download routines */
+class SimulateWithActionGroupInhibited : public pkgSimulate
+{
+public:
+ SimulateWithActionGroupInhibited(CacheFile &Cache) : pkgSimulate(Cache) { Sim.IncreaseActionGroupLevel(); }
+ SimulateWithActionGroupInhibited(SimulateWithActionGroupInhibited const &Cache) = delete;
+ SimulateWithActionGroupInhibited(SimulateWithActionGroupInhibited &&Cache) = delete;
+ SimulateWithActionGroupInhibited& operator=(SimulateWithActionGroupInhibited const &Cache) = delete;
+ SimulateWithActionGroupInhibited& operator=(SimulateWithActionGroupInhibited &&Cache) = delete;
+ ~SimulateWithActionGroupInhibited() = default;
+};
static void RemoveDownloadNeedingItemsFromFetcher(pkgAcquire &Fetcher, bool &Transient)
{
for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd();)
@@ -208,7 +218,7 @@ bool InstallPackages(CacheFile &Cache, bool ShwKept, bool Ask, bool Safety, std:
// Run the simulator ..
if (_config->FindB("APT::Get::Simulate") == true)
{
- pkgSimulate PM(Cache);
+ SimulateWithActionGroupInhibited PM(Cache);
APT::Progress::PackageManager *progress = APT::Progress::PackageManagerProgressFactory();
pkgPackageManager::OrderResult Res = PM.DoInstall(progress);
@@ -420,7 +430,6 @@ bool DoAutomaticRemove(CacheFile &Cache)
kernelAutoremovalMatcher = APT::KernelAutoRemoveHelper::GetProtectedKernelsFilter(Cache, true);
}
- pkgDepCache::ActionGroup group(*Cache);
if(Debug)
std::cout << "DoAutomaticRemove()" << std::endl;
@@ -431,6 +440,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
"AutoRemover") << std::endl;
return false;
}
+ Cache->MarkAndSweep();
bool purgePkgs = _config->FindB("APT::Get::Purge", false);
bool smallList = (hideAutoRemove == false &&
@@ -529,8 +539,6 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
} while (Changed == true);
}
- // trigger marking now so that the package list below is correct
- group.release();
// Now see if we had destroyed anything (if we had done anything)
if (Cache->BrokenCount() != 0)
@@ -550,6 +558,8 @@ bool DoAutomaticRemove(CacheFile &Cache)
{
if (smallList == false)
{
+ // trigger marking now so that the package list is correct
+ Cache->MarkAndSweep();
SortedPackageUniverse Universe(Cache);
ShowList(c1out, P_("The following package was automatically installed and is no longer required:",
"The following packages were automatically installed and are no longer required:",
@@ -664,9 +674,7 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<PseudoPkg
TryToInstall InstallAction(Cache, Fix.get(), BrokenFix);
TryToRemove RemoveAction(Cache, Fix.get());
- // new scope for the ActionGroup
{
- pkgDepCache::ActionGroup group(Cache);
unsigned short const order[] = { MOD_REMOVE, MOD_INSTALL, 0 };
for (unsigned short i = 0; order[i] != 0; ++i)
@@ -828,6 +836,7 @@ struct PkgIsExtraInstalled {
bool DoInstall(CommandLine &CmdL)
{
CacheFile Cache;
+ Cache.InhibitActionGroups(true);
auto VolatileCmdL = GetPseudoPackages(Cache.GetSourceList(), CmdL, AddVolatileBinaryFile, "");
// then open the cache
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index 9b47ce31f..5d1db5a50 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -652,6 +652,7 @@ bool DoBuildDep(CommandLine &CmdL)
std::string const pseudoArch = hostArch.empty() ? nativeArch : hostArch;
CacheFile Cache;
+ Cache.InhibitActionGroups(true);
auto VolatileCmdL = GetPseudoPackages(Cache.GetSourceList(), CmdL, AddVolatileSourceFile, pseudoArch);
auto AreDoingSatisfy = strcasecmp(CmdL.FileList[0], "satisfy") == 0;
@@ -820,7 +821,6 @@ bool DoBuildDep(CommandLine &CmdL)
APT::PackageVector removeAgain;
{
- pkgDepCache::ActionGroup group(Cache);
TryToInstall InstallAction(Cache, &Fix, false);
std::list<std::pair<pkgCache::VerIterator, std::string>> candSwitch;
for (auto const &pkg: pseudoPkgs)
@@ -856,7 +856,6 @@ bool DoBuildDep(CommandLine &CmdL)
return false;
{
- pkgDepCache::ActionGroup group(Cache);
if (_config->FindB(AreDoingSatisfy ? "APT::Get::Satisfy-Automatic" : "APT::Get::Build-Dep-Automatic", false) == false)
{
for (auto const &pkg: removeAgain)