From 657ecd4a08d5e979a7f66109d371904ec64a2d3d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 18 Aug 2011 11:45:51 +0200 Subject: * cmdline/apt-get.cc: - remove the binary caches in 'apt-get clean' as it is the first thing recommend by many supporters in case of APT segfaults --- cmdline/apt-get.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1849f1335..2dd1c2bce 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2203,10 +2203,14 @@ bool DoDSelectUpgrade(CommandLine &CmdL) /* */ bool DoClean(CommandLine &CmdL) { + std::string const archivedir = _config->FindDir("Dir::Cache::archives"); + std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); + std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); + if (_config->FindB("APT::Get::Simulate") == true) { - cout << "Del " << _config->FindDir("Dir::Cache::archives") << "* " << - _config->FindDir("Dir::Cache::archives") << "partial/*" << endl; + cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl + << "Del " << pkgcache << " " << srcpkgcache << endl; return true; } @@ -2214,14 +2218,20 @@ bool DoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); + Lock.Fd(GetLock(archivedir + "lock")); if (_error->PendingError() == true) return _error->Error(_("Unable to lock the download directory")); } pkgAcquire Fetcher; - Fetcher.Clean(_config->FindDir("Dir::Cache::archives")); - Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/"); + Fetcher.Clean(archivedir); + Fetcher.Clean(archivedir + "partial/"); + + if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) + unlink(pkgcache.c_str()); + if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) + unlink(srcpkgcache.c_str()); + return true; } /*}}}*/ -- cgit v1.2.3 From 8de79b68a834a6cc7abb8976e96ed19374fc02a2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 23:10:15 +0200 Subject: remove the caches in 'apt-get update', too, as they will be invalid in most cases anyway --- cmdline/apt-get.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 2dd1c2bce..69b9dcda9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1625,7 +1625,8 @@ bool DoUpdate(CommandLine &CmdL) if (_config->FindB("APT::Get::Download",true) == true) ListUpdate(Stat, *List); - // Rebuild the cache. + // Rebuild the cache. + pkgCacheFile::RemoveCaches(); if (Cache.BuildCaches() == false) return false; @@ -2227,10 +2228,7 @@ bool DoClean(CommandLine &CmdL) Fetcher.Clean(archivedir); Fetcher.Clean(archivedir + "partial/"); - if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) - unlink(pkgcache.c_str()); - if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) - unlink(srcpkgcache.c_str()); + pkgCacheFile::RemoveCaches(); return true; } -- cgit v1.2.3 From 9120d409efc74891d008a7cfc5180c1ac8645c8c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Aug 2011 11:20:51 +0200 Subject: * cmdline/apt-key: - if command is 'add' do not error out if the specified keyring doesn't exist, it will be created by gpg --- cmdline/apt-key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index e632be706..97d6e0323 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -152,7 +152,7 @@ if [ "$1" = "--keyring" ]; then #echo "keyfile given" shift TRUSTEDFILE="$1" - if [ -r "$TRUSTEDFILE" ]; then + if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ]; then GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE" else echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable" -- cgit v1.2.3 From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- cmdline/acqprogress.cc | 8 +++++--- cmdline/apt-cache.cc | 10 +++++----- cmdline/apt-cdrom.cc | 8 ++++---- cmdline/apt-config.cc | 7 ++++--- cmdline/apt-extracttemplates.cc | 5 +++-- cmdline/apt-get.cc | 7 ++++--- cmdline/apt-mark.cc | 7 ++++--- cmdline/apt-sortpkgs.cc | 7 ++++--- 8 files changed, 33 insertions(+), 26 deletions(-) (limited to 'cmdline') diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index d2db949ea..fd80ea126 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -8,19 +8,21 @@ ##################################################################### */ /*}}}*/ // Include files /*{{{*/ -#include "acqprogress.h" +#include + #include #include #include #include #include -#include - #include #include #include #include + +#include "acqprogress.h" +#include /*}}}*/ using namespace std; diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 232bb93ec..588c3c409 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -13,8 +13,9 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include -#include #include #include #include @@ -31,17 +32,16 @@ #include #include -#include -#include - +#include #include #include #include #include #include #include - #include + +#include /*}}}*/ using namespace std; diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index d1268edf9..8608b1215 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -11,6 +11,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -21,10 +23,6 @@ #include #include #include -#include -#include - -//#include "indexcopy.h" #include #include @@ -36,6 +34,8 @@ #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 589ee7ada..df2958975 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -16,6 +16,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -23,13 +25,12 @@ #include #include -#include -#include - #include #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 07bc0c25d..5d7b76c23 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -28,7 +30,7 @@ #include #include #include - + #include #include #include @@ -36,7 +38,6 @@ #include #include -#include #include #include "apt-extracttemplates.h" /*}}}*/ diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1a03acaa8..1bf4cf6f9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -25,6 +25,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE @@ -46,9 +48,6 @@ #include #include -#include -#include - #include "acqprogress.h" #include @@ -68,6 +67,8 @@ #include #include +#include + #define statfs statfs64 #define statvfs statvfs64 /*}}}*/ diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index b2c664979..8c9a47913 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -5,6 +5,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -12,10 +14,9 @@ #include #include -#include -#include - #include + +#include /*}}}*/ using namespace std; diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 171b0ba13..219e7ddff 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -12,6 +12,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -19,14 +21,13 @@ #include #include -#include -#include - #include #include #include #include + +#include /*}}}*/ using namespace std; -- cgit v1.2.3 From 4fe19044a7102f20c62f2f223d5624106f50ddb6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:39:57 +0200 Subject: * cmdline/apt-get.cc: - output list of virtual package providers to c1out in -q=1 instead of /dev/null to unbreak sbuild (LP: #816155) --- cmdline/apt-get.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 69b9dcda9..9096f263f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -657,22 +657,22 @@ public: pkgCache::PkgIterator Pkg = I.OwnerPkg(); if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { - out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); + c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) - out << _(" [Installed]"); - out << endl; + c1out << _(" [Installed]"); + c1out << endl; ++provider; } } // if we found no candidate which provide this package, show non-candidates if (provider == 0) for (I = Pkg.ProvidesList(); I.end() == false; ++I) - out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() + c1out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() << _(" [Not candidate version]") << endl; else out << _("You should explicitly select one to install.") << endl; } else { - ioprintf(out, + ioprintf(c1out, _("Package %s is not available, but is referred to by another package.\n" "This may mean that the package is missing, has been obsoleted, or\n" "is only available from another source\n"),Pkg.FullName(true).c_str()); @@ -691,9 +691,9 @@ public: List += Dep.ParentPkg().FullName(true) + " "; //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? } - ShowList(out,_("However the following packages replace it:"),List,VersionsList); + ShowList(c1out,_("However the following packages replace it:"),List,VersionsList); } - out << std::endl; + c1out << std::endl; } return false; } -- cgit v1.2.3 From 650faab01603caac04494d54cf6b10a65c00ea13 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:46:48 +0200 Subject: Support large files in the complete toolset. Indexes of this size are pretty unlikely for now, but we need it for deb packages which could become bigger than 4GB now (LP: #815895) --- cmdline/acqprogress.cc | 12 ++++++------ cmdline/apt-get.cc | 6 ------ 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'cmdline') diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index fd80ea126..1ccb08804 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -163,7 +163,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) ScreenWidth = sizeof(Buffer)-1; // Put in the percent done - sprintf(S,"%ld%%",long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems))); + sprintf(S,"%.0f%%",((CurrentBytes + CurrentItems)*100.0)/(TotalBytes+TotalItems)); bool Shown = false; for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0; @@ -214,11 +214,11 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false) { if (Mode == Short) - snprintf(S,End-S," %lu%%", - long(double(I->CurrentSize*100.0)/double(I->TotalSize))); + snprintf(S,End-S," %.0f%%", + (I->CurrentSize*100.0)/I->TotalSize); else - snprintf(S,End-S,"/%sB %lu%%",SizeToStr(I->TotalSize).c_str(), - long(double(I->CurrentSize*100.0)/double(I->TotalSize))); + snprintf(S,End-S,"/%sB %.0f%%",SizeToStr(I->TotalSize).c_str(), + (I->CurrentSize*100.0)/I->TotalSize); } S += strlen(S); snprintf(S,End-S,"]"); @@ -238,7 +238,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) if (CurrentCPS != 0) { char Tmp[300]; - unsigned long ETA = (unsigned long)((TotalBytes - CurrentBytes)/CurrentCPS); + unsigned long long ETA = (TotalBytes - CurrentBytes)/CurrentCPS; sprintf(Tmp," %sB/s %s",SizeToStr(CurrentCPS).c_str(),TimeToStr(ETA).c_str()); unsigned int Len = strlen(Buffer); unsigned int LenT = strlen(Tmp); diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1bf4cf6f9..9b9c0f0b0 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -27,9 +27,6 @@ // Include Files /*{{{*/ #include -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - #include #include #include @@ -68,9 +65,6 @@ #include #include - -#define statfs statfs64 -#define statvfs statvfs64 /*}}}*/ #define RAMFS_MAGIC 0x858458f6 -- cgit v1.2.3 From 472ff00ef2e48383805d281c6364ec27839e3f4d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 19:14:19 +0200 Subject: use forward declaration in headers if possible instead of includes --- cmdline/acqprogress.h | 4 +++- cmdline/apt-cache.cc | 6 +++++- cmdline/apt-cdrom.cc | 2 ++ cmdline/apt-config.cc | 1 + cmdline/apt-dump-solver.cc | 1 + cmdline/apt-extracttemplates.cc | 1 + cmdline/apt-get.cc | 5 +++++ cmdline/apt-internal-solver.cc | 2 ++ cmdline/apt-mark.cc | 1 + cmdline/apt-sortpkgs.cc | 2 ++ 10 files changed, 23 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/acqprogress.h b/cmdline/acqprogress.h index 48f90ae59..8f0903923 100644 --- a/cmdline/acqprogress.h +++ b/cmdline/acqprogress.h @@ -12,6 +12,8 @@ #include +#include + class AcqTextStatus : public pkgAcquireStatus { unsigned int &ScreenWidth; @@ -21,7 +23,7 @@ class AcqTextStatus : public pkgAcquireStatus public: - virtual bool MediaChange(string Media,string Drive); + virtual bool MediaChange(std::string Media,std::string Drive); virtual void IMSHit(pkgAcquire::ItemDesc &Itm); virtual void Fetch(pkgAcquire::ItemDesc &Itm); virtual void Done(pkgAcquire::ItemDesc &Itm); diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index a4cdf784e..82a31c9b1 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -24,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include #include @@ -40,6 +43,7 @@ #include #include #include +#include #include /*}}}*/ diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 8608b1215..fa48debcd 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index df2958975..94f6ee9b0 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc index dab0cc6fd..e82e15c6e 100644 --- a/cmdline/apt-dump-solver.cc +++ b/cmdline/apt-dump-solver.cc @@ -12,6 +12,7 @@ #include #include +#include /*}}}*/ // ShowHelp - Show a help screen /*{{{*/ diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 5d7b76c23..d5c1a3208 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d8f207f0a..5e950332f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,10 @@ #include #include #include +#include +#include +#include +#include #include "acqprogress.h" diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index ef6c688fe..1b636e4d5 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -11,10 +11,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 8c9a47913..339cbdf44 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 44b74cf6c..20ae14f2a 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include -- cgit v1.2.3 From 81ce578199d8fa83283fc6b1e759acafaee7fbf0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 13:27:53 +0200 Subject: * cmdline/apt-get.cc: - follow Provides in the evaluation of saving candidates, too, for statisfying garbage package dependencies (Closes: #640590) --- cmdline/apt-get.cc | 59 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5e950332f..88e734697 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1689,8 +1689,9 @@ bool DoAutomaticRemove(CacheFile &Cache) // install it in the first place, so nuke it instead of show it if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0) { + if (Pkg.CandVersion() != 0) + tooMuch.insert(Pkg); Cache->MarkDelete(Pkg, false); - tooMuch.insert(Pkg); } // only show stuff in the list that is not yet marked for removal else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) @@ -1714,33 +1715,41 @@ bool DoAutomaticRemove(CacheFile &Cache) bool Changed; do { Changed = false; - for (APT::PackageSet::const_iterator P = tooMuch.begin(); - P != tooMuch.end() && Changed == false; ++P) + for (APT::PackageSet::const_iterator Pkg = tooMuch.begin(); + Pkg != tooMuch.end() && Changed == false; ++Pkg) { - for (pkgCache::DepIterator R = P.RevDependsList(); - R.end() == false; ++R) - { - if (R.IsNegative() == true || - Cache->IsImportantDep(R) == false) - continue; - pkgCache::PkgIterator N = R.ParentPkg(); - if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false)) - continue; - if (Debug == true) - std::clog << "Save " << P << " as another installed garbage package depends on it" << std::endl; - Cache->MarkInstall(P, false); - if(hideAutoRemove == false) + APT::PackageSet too; + too.insert(Pkg); + for (pkgCache::PrvIterator Prv = Cache[Pkg].CandidateVerIter(Cache).ProvidesList(); + Prv.end() == false; ++Prv) + too.insert(Prv.ParentPkg()); + for (APT::PackageSet::const_iterator P = too.begin(); + P != too.end() && Changed == false; ++P) { + for (pkgCache::DepIterator R = P.RevDependsList(); + R.end() == false; ++R) { - ++autoRemoveCount; - if (smallList == false) - { - autoremovelist += P.FullName(true) + " "; - autoremoveversions += string(Cache[P].CandVersion) + "\n"; - } + if (R.IsNegative() == true || + Cache->IsImportantDep(R) == false) + continue; + pkgCache::PkgIterator N = R.ParentPkg(); + if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false)) + continue; + if (Debug == true) + std::clog << "Save " << Pkg << " as another installed garbage package depends on it" << std::endl; + Cache->MarkInstall(Pkg, false); + if (hideAutoRemove == false) + { + ++autoRemoveCount; + if (smallList == false) + { + autoremovelist += Pkg.FullName(true) + " "; + autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; + } + } + tooMuch.erase(Pkg); + Changed = true; + break; } - tooMuch.erase(P); - Changed = true; - break; } } } while (Changed == true); -- cgit v1.2.3 From 778559db797ce61611e2b761b24dcb49c49f2652 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 14:30:31 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - use std::vector instead of fixed size arrays to store args and multiarch-packagename strings - load the dpkg base arguments only one time and reuse them later * cmdline/apt-get.cc: - follow Provides in the evaluation of saving candidates, too, for statisfying garbage package dependencies (Closes: #640590) * apt-pkg/algorithms.cc: - if a package is garbage, don't try to save it with FixByInstall --- cmdline/apt-get.cc | 59 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9096f263f..49ac8f2cf 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1684,8 +1684,9 @@ bool DoAutomaticRemove(CacheFile &Cache) // install it in the first place, so nuke it instead of show it if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0) { + if (Pkg.CandVersion() != 0) + tooMuch.insert(Pkg); Cache->MarkDelete(Pkg, false); - tooMuch.insert(Pkg); } // only show stuff in the list that is not yet marked for removal else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) @@ -1709,33 +1710,41 @@ bool DoAutomaticRemove(CacheFile &Cache) bool Changed; do { Changed = false; - for (APT::PackageSet::const_iterator P = tooMuch.begin(); - P != tooMuch.end() && Changed == false; ++P) + for (APT::PackageSet::const_iterator Pkg = tooMuch.begin(); + Pkg != tooMuch.end() && Changed == false; ++Pkg) { - for (pkgCache::DepIterator R = P.RevDependsList(); - R.end() == false; ++R) - { - if (R.IsNegative() == true || - Cache->IsImportantDep(R) == false) - continue; - pkgCache::PkgIterator N = R.ParentPkg(); - if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false)) - continue; - if (Debug == true) - std::clog << "Save " << P << " as another installed garbage package depends on it" << std::endl; - Cache->MarkInstall(P, false); - if(hideAutoRemove == false) + APT::PackageSet too; + too.insert(Pkg); + for (pkgCache::PrvIterator Prv = Cache[Pkg].CandidateVerIter(Cache).ProvidesList(); + Prv.end() == false; ++Prv) + too.insert(Prv.ParentPkg()); + for (APT::PackageSet::const_iterator P = too.begin(); + P != too.end() && Changed == false; ++P) { + for (pkgCache::DepIterator R = P.RevDependsList(); + R.end() == false; ++R) { - ++autoRemoveCount; - if (smallList == false) - { - autoremovelist += P.FullName(true) + " "; - autoremoveversions += string(Cache[P].CandVersion) + "\n"; - } + if (R.IsNegative() == true || + Cache->IsImportantDep(R) == false) + continue; + pkgCache::PkgIterator N = R.ParentPkg(); + if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false)) + continue; + if (Debug == true) + std::clog << "Save " << Pkg << " as another installed garbage package depends on it" << std::endl; + Cache->MarkInstall(Pkg, false); + if (hideAutoRemove == false) + { + ++autoRemoveCount; + if (smallList == false) + { + autoremovelist += Pkg.FullName(true) + " "; + autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; + } + } + tooMuch.erase(Pkg); + Changed = true; + break; } - tooMuch.erase(P); - Changed = true; - break; } } } while (Changed == true); -- cgit v1.2.3