From afb1e2e3bb580077c6c917e6ea98baad8f3c39b3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 10 May 2005 08:27:59 +0000 Subject: * ported/cleaned up the "Automatic dependency handling" patch from Michael Hofmann --- cmdline/apt-get.cc | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6268f4953..31148a807 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -58,6 +58,7 @@ #include #include #include +#include /*}}}*/ using namespace std; @@ -992,6 +993,26 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, cerr << _("Unable to correct missing packages.") << endl; return _error->Error(_("Aborting install.")); } + + // write the auto-mark list ---------------------------------- + // -- we do it here because there is no libapt::Commit() :/ + FileFd state_file; + string state = _config->FindDir("Dir::State") + "pkgstates"; + + + state_file.Open(state, FileFd::WriteEmpty); + std::ostringstream ostr; + for(pkgCache::PkgIterator p=Cache->PkgBegin(); !p.end();p++) { + if(Cache[p].AutomaticRemove != pkgCache::State::RemoveUnknown) { + ostr.str(string("")); + ostr << "Package: " << p.Name() + << "\nRemove-Reason: " + << (int)(Cache[p].AutomaticRemove) << "\n\n"; + state_file.Write(ostr.str().c_str(), ostr.str().size()); + //std::cout << "Writing auto-mark: " << ostr.str() << endl; + } + } + // ---------------------------------------------------------- _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); @@ -1375,6 +1396,135 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ +// RecurseDirty - Mark used packages as dirty /*{{{*/ +// --------------------------------------------------------------------- +/* Mark all reachable packages as dirty. */ +void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State::PkgRemoveState DirtLevel) +{ + // If it is not installed, and we are in manual mode, ignore it + if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && + DirtLevel == pkgCache::State::RemoveManual) + { +// fprintf(stdout,"This one is not installed/virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is not installed, and it is not virtual, ignore it + if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && + Pkg->VersionList != 0) + { +// fprintf(stdout,"This one is not installed %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is similar or more dirty than we are ;-), because we've been here already, don't mark it + // This is necessary because virtual packages just relay the current level, + // so it may be possible e.g. that this was already seen with ::RemoveSuggested, but + // we are ::RemoveRequired + if (Cache[Pkg].Dirty() >= DirtLevel) + { + //fprintf(stdout,"Seen already %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is less important than the current DirtLevel, don't mark it + if (Cache[Pkg].AutomaticRemove != pkgCache::State::RemoveManual && + Cache[Pkg].AutomaticRemove > DirtLevel) + { +// fprintf(stdout,"We don't need %s %d %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel, Cache[Pkg].Dirty()); + return; + } + + // Mark it as used + Cache->SetDirty(Pkg, DirtLevel); + + //fprintf(stdout,"We keep %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + + // We are a virtual package + if (Pkg->VersionList == 0) + { +// fprintf(stdout,"We are virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); ! Prv.end(); ++Prv) + RecurseDirty (Cache, Prv.OwnerPkg(), DirtLevel); + return; + } + + // Depending on the type of dependency, follow it + for (pkgCache::DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); ! D.end(); ++D) + { +// fprintf(stdout,"We depend on %s %s\n", D.TargetPkg().Name(), D.DepType()); + + switch(D->Type) + { + case pkgCache::Dep::Depends: + case pkgCache::Dep::PreDepends: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRequired); + break; + case pkgCache::Dep::Recommends: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRecommended); + break; + case pkgCache::Dep::Suggests: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveSuggested); + break; + case pkgCache::Dep::Conflicts: + case pkgCache::Dep::Replaces: + case pkgCache::Dep::Obsoletes: + // We don't handle these here + break; + } + } +// fprintf(stdout,"We keep %s %d %d \n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); +} + /*}}}*/ +// DoAutomaticRemove - Remove all automatic unused packages /*{{{*/ +// --------------------------------------------------------------------- +/* Remove unused automatic packages */ +bool DoAutomaticRemove(CacheFile &Cache) +{ + std::cout << "DoAutomaticRemove()" << std::endl; + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + if(!Cache[Pkg].Dirty() && Cache[Pkg].AutomaticRemove > 0) + std::cout << "has auto-remove information: " << Pkg.Name() + << " " << (int)Cache[Pkg].AutomaticRemove + << std::endl; + + + if (_config->FindB("APT::Get::Remove",true) == false) + return _error->Error(_("We are not supposed to delete stuff, can't start AutoRemover")); + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + Cache->SetDirty(Pkg, pkgCache::State::RemoveUnknown); + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + RecurseDirty (Cache, Pkg, pkgCache::State::RemoveManual); + + + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + { + if (! Cache[Pkg].Dirty() && + (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) + { + fprintf(stdout,"We could delete %s %d\n", Pkg.Name(), Cache[Pkg].AutomaticRemove); + Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); + } + } + + // Now see if we destroyed anything + if (Cache->BrokenCount() != 0) + { + c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n" + "shouldn't happen. Please file a bug report against apt.") << endl; + c1out << endl; + c1out << _("The following information may help to resolve the situation:") << endl; + c1out << endl; + ShowBroken(c1out,Cache,false); + + return _error->Error(_("Internal Error, AutoRemover broke stuff")); + } + return true; +} + /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -1546,6 +1696,11 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } + //if (_config->FindB("APT::Get::AutomaticRemove")) { + if (!DoAutomaticRemove(Cache)) + return false; + //} + /* Print out a list of packages that are going to be installed extra to what the user asked */ if (Cache->InstCount() != ExpectedInst) @@ -1565,6 +1720,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; + //if (_config->FindB("APT::Get::AutomaticRemove")) + Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; VersionsList += string(Cache[I].CandVersion) + "\n"; } } @@ -2410,6 +2567,7 @@ 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 /*{{{*/ @@ -2465,6 +2623,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, + {0,"experimental-automatic-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From a83d884db24933000f19dbff706529db057d50c1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 23 Jun 2005 16:40:54 +0000 Subject: * cleanups --- cmdline/apt-get.cc | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 31148a807..9f9ecd375 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -994,25 +994,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return _error->Error(_("Aborting install.")); } - // write the auto-mark list ---------------------------------- // -- we do it here because there is no libapt::Commit() :/ - FileFd state_file; - string state = _config->FindDir("Dir::State") + "pkgstates"; - - - state_file.Open(state, FileFd::WriteEmpty); - std::ostringstream ostr; - for(pkgCache::PkgIterator p=Cache->PkgBegin(); !p.end();p++) { - if(Cache[p].AutomaticRemove != pkgCache::State::RemoveUnknown) { - ostr.str(string("")); - ostr << "Package: " << p.Name() - << "\nRemove-Reason: " - << (int)(Cache[p].AutomaticRemove) << "\n\n"; - state_file.Write(ostr.str().c_str(), ostr.str().size()); - //std::cout << "Writing auto-mark: " << ostr.str() << endl; - } - } - // ---------------------------------------------------------- + Cache->writeStateFile(NULL); _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); @@ -1720,8 +1703,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; - //if (_config->FindB("APT::Get::AutomaticRemove")) - Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; + // mark each pkg as auto-installed + Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; VersionsList += string(Cache[I].CandVersion) + "\n"; } } -- cgit v1.2.3 From 80fa0d8a1a77f4dab696dcf11d1908ecda761fab Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 09:36:22 +0000 Subject: * moved most of the real work into depcache::writeStateFile --- cmdline/apt-get.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9f9ecd375..bc8cd1ae5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1703,10 +1703,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; - // mark each pkg as auto-installed - Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; - VersionsList += string(Cache[I].CandVersion) + "\n"; - } + VersionsList += string(Cache[I].CandVersion) + "\n"; + } } ShowList(c1out,_("The following extra packages will be installed:"),List,VersionsList); -- cgit v1.2.3 From d36ab88eb8a5e490e4a817b87f20cb3f890e0da1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 09:58:47 +0000 Subject: * write the state file after a successfull commit from the pkgManager --- cmdline/apt-get.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index bc8cd1ae5..f1496c9e2 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -994,9 +994,6 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return _error->Error(_("Aborting install.")); } - // -- we do it here because there is no libapt::Commit() :/ - Cache->writeStateFile(NULL); - _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) -- cgit v1.2.3 From db1e7193fa7d5b86656c05112b9d6ad6e75845b8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 12:34:34 +0000 Subject: * moved the importend algorithm to algorithm.h as "pkgMarkUsed()" --- cmdline/apt-get.cc | 144 +++++++++++------------------------------------------ 1 file changed, 28 insertions(+), 116 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index f1496c9e2..54479e224 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1354,106 +1354,6 @@ bool DoUpdate(CommandLine &CmdL) return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); return true; -} - /*}}}*/ -// DoUpgrade - Upgrade all packages /*{{{*/ -// --------------------------------------------------------------------- -/* Upgrade all packages without installing new packages or erasing old - packages */ -bool DoUpgrade(CommandLine &CmdL) -{ - CacheFile Cache; - if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) - return false; - - // Do the upgrade - if (pkgAllUpgrade(Cache) == false) - { - ShowBroken(c1out,Cache,false); - return _error->Error(_("Internal error, AllUpgrade broke stuff")); - } - - return InstallPackages(Cache,true); -} - /*}}}*/ -// RecurseDirty - Mark used packages as dirty /*{{{*/ -// --------------------------------------------------------------------- -/* Mark all reachable packages as dirty. */ -void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State::PkgRemoveState DirtLevel) -{ - // If it is not installed, and we are in manual mode, ignore it - if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && - DirtLevel == pkgCache::State::RemoveManual) - { -// fprintf(stdout,"This one is not installed/virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is not installed, and it is not virtual, ignore it - if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && - Pkg->VersionList != 0) - { -// fprintf(stdout,"This one is not installed %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is similar or more dirty than we are ;-), because we've been here already, don't mark it - // This is necessary because virtual packages just relay the current level, - // so it may be possible e.g. that this was already seen with ::RemoveSuggested, but - // we are ::RemoveRequired - if (Cache[Pkg].Dirty() >= DirtLevel) - { - //fprintf(stdout,"Seen already %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is less important than the current DirtLevel, don't mark it - if (Cache[Pkg].AutomaticRemove != pkgCache::State::RemoveManual && - Cache[Pkg].AutomaticRemove > DirtLevel) - { -// fprintf(stdout,"We don't need %s %d %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel, Cache[Pkg].Dirty()); - return; - } - - // Mark it as used - Cache->SetDirty(Pkg, DirtLevel); - - //fprintf(stdout,"We keep %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - - // We are a virtual package - if (Pkg->VersionList == 0) - { -// fprintf(stdout,"We are virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); ! Prv.end(); ++Prv) - RecurseDirty (Cache, Prv.OwnerPkg(), DirtLevel); - return; - } - - // Depending on the type of dependency, follow it - for (pkgCache::DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); ! D.end(); ++D) - { -// fprintf(stdout,"We depend on %s %s\n", D.TargetPkg().Name(), D.DepType()); - - switch(D->Type) - { - case pkgCache::Dep::Depends: - case pkgCache::Dep::PreDepends: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRequired); - break; - case pkgCache::Dep::Recommends: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRecommended); - break; - case pkgCache::Dep::Suggests: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveSuggested); - break; - case pkgCache::Dep::Conflicts: - case pkgCache::Dep::Replaces: - case pkgCache::Dep::Obsoletes: - // We don't handle these here - break; - } - } -// fprintf(stdout,"We keep %s %d %d \n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); } /*}}}*/ // DoAutomaticRemove - Remove all automatic unused packages /*{{{*/ @@ -1462,30 +1362,23 @@ void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State: bool DoAutomaticRemove(CacheFile &Cache) { std::cout << "DoAutomaticRemove()" << std::endl; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - if(!Cache[Pkg].Dirty() && Cache[Pkg].AutomaticRemove > 0) - std::cout << "has auto-remove information: " << Pkg.Name() - << " " << (int)Cache[Pkg].AutomaticRemove - << std::endl; - if (_config->FindB("APT::Get::Remove",true) == false) - return _error->Error(_("We are not supposed to delete stuff, can't start AutoRemover")); - - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - Cache->SetDirty(Pkg, pkgCache::State::RemoveUnknown); - - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - RecurseDirty (Cache, Pkg, pkgCache::State::RemoveManual); - + return _error->Error(_("We are not supposed to delete stuff, can't " + "start AutoRemover")); + // do the actual work + pkgMarkUsed(Cache); + // look over the cache to see what can be removed for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { if (! Cache[Pkg].Dirty() && - (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) + (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && + Cache[Pkg].Delete() == false)) { - fprintf(stdout,"We could delete %s %d\n", Pkg.Name(), Cache[Pkg].AutomaticRemove); + fprintf(stdout,"We could delete %s %d\n", + Pkg.Name(), Cache[Pkg].AutomaticRemove); Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); } } @@ -1503,6 +1396,25 @@ bool DoAutomaticRemove(CacheFile &Cache) return _error->Error(_("Internal Error, AutoRemover broke stuff")); } return true; +} +// DoUpgrade - Upgrade all packages /*{{{*/ +// --------------------------------------------------------------------- +/* Upgrade all packages without installing new packages or erasing old + packages */ +bool DoUpgrade(CommandLine &CmdL) +{ + CacheFile Cache; + if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) + return false; + + // Do the upgrade + if (pkgAllUpgrade(Cache) == false) + { + ShowBroken(c1out,Cache,false); + return _error->Error(_("Internal error, AllUpgrade broke stuff")); + } + + return InstallPackages(Cache,true); } /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ -- cgit v1.2.3 From 120365cee294d00706928b0327ac755ab3448eca Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 28 Jun 2005 08:41:51 +0000 Subject: * cleanups, documentation updates (don't show any debug output if no Debug::pkgAutomaticRemove was set, don't remove if not APT::Get::AutomaticRemove (--automatic-remove) was set) --- cmdline/apt-get.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 3bafd42ba..0236d7e77 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1361,7 +1361,8 @@ bool DoUpdate(CommandLine &CmdL) /* Remove unused automatic packages */ bool DoAutomaticRemove(CacheFile &Cache) { - std::cout << "DoAutomaticRemove()" << std::endl; + if(_config->FindI("Debug::pkgAutoRemove",false)) + std::cout << "DoAutomaticRemove()" << std::endl; if (_config->FindB("APT::Get::Remove",true) == false) return _error->Error(_("We are not supposed to delete stuff, can't " @@ -1597,10 +1598,10 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } - //if (_config->FindB("APT::Get::AutomaticRemove")) { + if (_config->FindB("APT::Get::AutomaticRemove")) { if (!DoAutomaticRemove(Cache)) return false; - //} + } /* Print out a list of packages that are going to be installed extra to what the user asked */ @@ -2522,7 +2523,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, - {0,"experimental-automatic-remove","APT::Get::AutomaticRemove",0}, + {0,"automatic-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From 0a57c0f0e4d0bc3474ce4d2101f36a997891d30d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 29 Jun 2005 06:11:36 +0000 Subject: * use mark-and-sweep from aptitude now as GC algorithm --- cmdline/apt-get.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 0236d7e77..9d97f8756 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1374,12 +1374,11 @@ bool DoAutomaticRemove(CacheFile &Cache) // look over the cache to see what can be removed for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - if (! Cache[Pkg].Dirty() && + if (Cache[Pkg].Garbage && (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) { - fprintf(stdout,"We could delete %s %d\n", - Pkg.Name(), Cache[Pkg].AutomaticRemove); + fprintf(stdout,"We could delete %s\n", Pkg.Name()); Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); } } -- cgit v1.2.3 From f8ac1720a94468d1384e88a57729e6d9801b56fd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Jun 2005 13:34:32 +0000 Subject: * slighly more debug output, renamed "--automatic-remove" to "--auto-remove" --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9d97f8756..cb8fc7724 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2522,7 +2522,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, - {0,"automatic-remove","APT::Get::AutomaticRemove",0}, + {0,"auto-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From f77bf408f3f7ae650bac2a967f28610737acf1ab Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Aug 2005 11:59:11 +0000 Subject: * merged with apt@packages.debian.org/apt--main--0 Patches applied: * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added --- cmdline/apt-get.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 316bb7af9..e673e0f5b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -688,7 +688,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true) { - c2out << "Authentication warning overridden.\n"; + c2out << _("Authentication warning overridden.\n"); return true; } @@ -750,7 +750,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (Cache->BrokenCount() != 0) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, InstallPackages was called with broken packages!"); + return _error->Error(_("Internal error, InstallPackages was called with broken packages!")); } if (Cache->DelCount() == 0 && Cache->InstCount() == 0 && @@ -765,11 +765,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Simulate") == true) { pkgSimulate PM(Cache); - pkgPackageManager::OrderResult Res = PM.DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd); if (Res == pkgPackageManager::Failed) return false; if (Res != pkgPackageManager::Completed) - return _error->Error("Internal error, Ordering didn't finish"); + return _error->Error(_("Internal error, Ordering didn't finish")); return true; } @@ -810,7 +811,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; - c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl; + c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << endl; } // Number of bytes @@ -840,7 +841,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, struct statvfs Buf; string OutputDir = _config->FindDir("Dir::Cache::Archives"); if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s."), @@ -994,7 +995,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, } _system->UnLock(); - pkgPackageManager::OrderResult Res = PM->DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) return false; if (Res == pkgPackageManager::Completed) @@ -1743,7 +1745,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (Fix.Resolve() == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } } @@ -1751,7 +1753,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (pkgAllUpgrade(Cache) == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } return InstallPackages(Cache,false); @@ -1922,7 +1924,7 @@ bool DoSource(CommandLine &CmdL) struct statvfs Buf; string OutputDir = "."; if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s"), -- cgit v1.2.3 From 2a7e07c7578048abd9f7bfd4ce0ca5c3696b9f3a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Aug 2005 10:38:58 +0000 Subject: * merged from main Patches applied: * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-109 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-110 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-23 * remvoed a debug string * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-24 * soname changed, fixed a bug in the parsing code when dpkg send the same state more than once (at the end) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-25 * merged with apt@packages.debian.org/apt--main--0, added changelog entry for the 0.6.40.1 upload * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-26 * fix a bug when out-of-order states are send from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-27 * changelog update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-28 * a real changelog entry now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-29 * changelog finalized * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-30 * propper (and sane) support for pmerror and pmconffile added --- cmdline/apt-get.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index cb8fc7724..ac0d56073 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -689,7 +689,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true) { - c2out << "Authentication warning overridden.\n"; + c2out << _("Authentication warning overridden.\n"); return true; } @@ -751,7 +751,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (Cache->BrokenCount() != 0) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, InstallPackages was called with broken packages!"); + return _error->Error(_("Internal error, InstallPackages was called with broken packages!")); } if (Cache->DelCount() == 0 && Cache->InstCount() == 0 && @@ -766,11 +766,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Simulate") == true) { pkgSimulate PM(Cache); - pkgPackageManager::OrderResult Res = PM.DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd); if (Res == pkgPackageManager::Failed) return false; if (Res != pkgPackageManager::Completed) - return _error->Error("Internal error, Ordering didn't finish"); + return _error->Error(_("Internal error, Ordering didn't finish")); return true; } @@ -811,7 +812,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; - c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl; + c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << endl; } // Number of bytes @@ -841,7 +842,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, struct statvfs Buf; string OutputDir = _config->FindDir("Dir::Cache::Archives"); if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s."), @@ -995,7 +996,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, } _system->UnLock(); - pkgPackageManager::OrderResult Res = PM->DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) return false; if (Res == pkgPackageManager::Completed) @@ -1790,7 +1792,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (Fix.Resolve() == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } } @@ -1798,7 +1800,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (pkgAllUpgrade(Cache) == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } return InstallPackages(Cache,false); @@ -1969,7 +1971,7 @@ bool DoSource(CommandLine &CmdL) struct statvfs Buf; string OutputDir = "."; if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s"), -- cgit v1.2.3 From 74a05226eff7041cd8f2380fe599862d350a1ac3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Nov 2005 11:39:27 +0000 Subject: * merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'. --- cmdline/apt-get.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ac0d56073..c8b64f5d8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1370,19 +1370,23 @@ bool DoAutomaticRemove(CacheFile &Cache) return _error->Error(_("We are not supposed to delete stuff, can't " "start AutoRemover")); - // do the actual work - pkgMarkUsed(Cache); - - // look over the cache to see what can be removed - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - if (Cache[Pkg].Garbage && - (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && - Cache[Pkg].Delete() == false)) - { - fprintf(stdout,"We could delete %s\n", Pkg.Name()); - Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); - } + pkgDepCache::ActionGroup group(*Cache); + + // look over the cache to see what can be removed + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + { + if (Cache[Pkg].Garbage) + { + if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) + fprintf(stdout,"We could delete %s\n", Pkg.Name()); + + if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) + Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false)); + else + Cache->MarkKeep(Pkg, false, false); + } + } } // Now see if we destroyed anything @@ -1399,6 +1403,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } return true; } + // DoUpgrade - Upgrade all packages /*{{{*/ // --------------------------------------------------------------------- /* Upgrade all packages without installing new packages or erasing old @@ -1450,6 +1455,11 @@ bool DoInstall(CommandLine &CmdL) bool DefRemove = false; if (strcasecmp(CmdL.FileList[0],"remove") == 0) DefRemove = true; + else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) + { + _config->Set("APT::Get::AutomaticRemove", "true"); + DefRemove = true; + } for (const char **I = CmdL.FileList + 1; *I != 0; I++) { @@ -2533,6 +2543,7 @@ int main(int argc,const char *argv[]) {"upgrade",&DoUpgrade}, {"install",&DoInstall}, {"remove",&DoInstall}, + {"autoremove",&DoInstall}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, {"build-dep",&DoBuildDep}, -- cgit v1.2.3 From 7a6058744badb38d2ccac0158d6ed1359cfb0239 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 8 Dec 2005 17:29:42 +0000 Subject: * merged with the current debian version Patches applied: * bubulle@debian.org--2005/apt--main--0--patch-132 Completed Simplified Chinese translation * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-94 * pkgDirStream has (slightly) better extract support now * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-95 * merge fix for #339533 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-96 * merged with bubulle * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-97 * some more debug output * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-98 * ABI change: merged more flexible pkgAcquireFile code * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-99 * merged http download limit for apt (#146877) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-100 * applied parts of the string speedup patch from debian #319377 (ABI change) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-101 * fix for #340448 --- cmdline/apt-get.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 356d36b48..48b21a31f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2040,6 +2040,7 @@ bool DoSource(CommandLine &CmdL) if (system(S) != 0) { fprintf(stderr,_("Unpack command '%s' failed.\n"),S); + fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n")); _exit(1); } } -- cgit v1.2.3 From 9ceaa28f2ce0bde0cbf6f73a32a68761ec85f11d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 20 Feb 2006 18:50:44 +0000 Subject: * make errors during apt-get update warnings only (default sources spec) --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d4a6bee32..92051f8ff 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1381,7 +1381,7 @@ bool DoUpdate(CommandLine &CmdL) return false; if (Failed == true) - return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + return _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); return true; } -- cgit v1.2.3 From 47eb38f452c7477aab782dce56e85a0a85e22764 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 21 Feb 2006 12:23:22 +0000 Subject: * handle network failures more gracefully (default apt sources spec) apt-pkg/acquire-item.cc: - on network failures (Timeout,ResolveFailure,ConnectionRefused) move the old (known good) sigfile back and don't touch the indexfiles cmdline/apt-get.cc: - don't fail on apt-get update problems but issue a warning instead --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 92051f8ff..99a51c9b8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1381,7 +1381,7 @@ bool DoUpdate(CommandLine &CmdL) return false; if (Failed == true) - return _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); return true; } -- cgit v1.2.3 From 7e5f33eb8a0f224b938f17236f684ba5cadb9c7f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 21 Feb 2006 16:39:25 +0000 Subject: * more work for the DefaultAptSources spec apt-pkg/acquire-item.h: - add new pkgAcquire::Item::StatTransientNetworkError status apt-pkg/acquire-item.cc: - if we get a StatTransientNetworkError use old sigfile and indexfiles apt-pkg/acquire-worker.cc: - set StatTransientNetworkError on "Timeout", "TmpResolveFailure", "ConnectionRefused" cmdline/apt-get.cc: - handle a StatTransientNetworkError different than a normal error (warning instead of error) --- cmdline/apt-get.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 99a51c9b8..e98d4fec5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1355,20 +1355,29 @@ bool DoUpdate(CommandLine &CmdL) return false; bool Failed = false; + bool TransientNetworkFailure = false; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) { if ((*I)->Status == pkgAcquire::Item::StatDone) continue; (*I)->Finished(); - + fprintf(stderr,_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), (*I)->ErrorText.c_str()); + + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + { + TransientNetworkFailure = true; + continue; + } + Failed = true; } // Clean out any old list files - if (!Failed && _config->FindB("APT::Get::List-Cleanup",true) == true) + if (!TransientNetworkFailure && + _config->FindB("APT::Get::List-Cleanup",true) == true) { if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false) @@ -1380,9 +1389,11 @@ bool DoUpdate(CommandLine &CmdL) if (Cache.BuildCaches() == false) return false; - if (Failed == true) + if (TransientNetworkFailure == true) _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead.")); - + else if (Failed == true) + return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); + return true; } /*}}}*/ -- cgit v1.2.3 From 60681f9354217c830943315951e6559253bfa832 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 2 May 2006 09:44:30 +0200 Subject: * depcache.cc: - added APT::Install-{Recommends,Suggests} global option * depcache.h: - added DepCache::State::InstPolicyBroken() to check if the current install state violates the policy (compated with InstBroken() that only checks for the minimal requirements) --- cmdline/apt-get.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d4a6bee32..6979fa8f2 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1145,9 +1145,11 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, else ExpectedInst++; - // Install it with autoinstalling enabled. - if (State.InstBroken() == true && BrokenFix == false) + // Install it with autoinstalling enabled (if we not respect the minial + // required deps or the policy) + if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false) Cache.MarkInstall(Pkg,true); + return true; } /*}}}*/ -- cgit v1.2.3 From a4decc40b3eb085ea994d2a8b31ee9cddfd570ff Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Jul 2006 11:00:34 +0200 Subject: * apt-pkg/depcache.cc: - close the outfile properly (thanks to kamion) * cmdline/apt-get.cc: - unbreak dselect-upgrade by adding a ActionGroup around it --- cmdline/apt-get.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 30d046447..8b3c68573 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1771,6 +1771,8 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) return false; + pkgDepCache::ActionGroup group(Cache); + // Install everything with the install flag set pkgCache::PkgIterator I = Cache->PkgBegin(); for (;I.end() != true; I++) -- cgit v1.2.3 From 54668e4e591651be2d83b95ff4a9d96668db1e36 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jul 2006 10:58:26 +0200 Subject: * cmdline/apt-get.cc: - add a scope with a ActionGroup in DoInstall() to speed up the install of long package lists (e.g. pbuilder) --- cmdline/apt-get.cc | 261 +++++++++++++++++++++++++++-------------------------- 1 file changed, 132 insertions(+), 129 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 8b3c68573..ad4da133f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1476,159 +1476,162 @@ bool DoInstall(CommandLine &CmdL) if (strcasecmp(CmdL.FileList[0],"remove") == 0) DefRemove = true; else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) - { - _config->Set("APT::Get::AutomaticRemove", "true"); - DefRemove = true; - } + { + _config->Set("APT::Get::AutomaticRemove", "true"); + DefRemove = true; + } - for (const char **I = CmdL.FileList + 1; *I != 0; I++) + // new scope for the ActionGroup { - // Duplicate the string - unsigned int Length = strlen(*I); - char S[300]; - if (Length >= sizeof(S)) - continue; - strcpy(S,*I); - - // See if we are removing and special indicators.. - bool Remove = DefRemove; - char *VerTag = 0; - bool VerIsRel = false; - while (Cache->FindPkg(S).end() == true) + pkgDepCache::ActionGroup group(Cache); + for (const char **I = CmdL.FileList + 1; *I != 0; I++) { - // Handle an optional end tag indicating what to do - if (Length >= 1 && S[Length - 1] == '-') - { - Remove = true; - S[--Length] = 0; + // Duplicate the string + unsigned int Length = strlen(*I); + char S[300]; + if (Length >= sizeof(S)) continue; - } - - if (Length >= 1 && S[Length - 1] == '+') + strcpy(S,*I); + + // See if we are removing and special indicators.. + bool Remove = DefRemove; + char *VerTag = 0; + bool VerIsRel = false; + while (Cache->FindPkg(S).end() == true) { - Remove = false; - S[--Length] = 0; - continue; - } + // Handle an optional end tag indicating what to do + if (Length >= 1 && S[Length - 1] == '-') + { + Remove = true; + S[--Length] = 0; + continue; + } - char *Slash = strchr(S,'='); - if (Slash != 0) - { - VerIsRel = false; - *Slash = 0; - VerTag = Slash + 1; - } + if (Length >= 1 && S[Length - 1] == '+') + { + Remove = false; + S[--Length] = 0; + continue; + } - Slash = strchr(S,'/'); - if (Slash != 0) - { - VerIsRel = true; - *Slash = 0; - VerTag = Slash + 1; - } + char *Slash = strchr(S,'='); + if (Slash != 0) + { + VerIsRel = false; + *Slash = 0; + VerTag = Slash + 1; + } - break; - } - - // Locate the package - pkgCache::PkgIterator Pkg = Cache->FindPkg(S); - Packages++; - if (Pkg.end() == true) - { - // Check if the name is a regex - const char *I; - for (I = S; *I != 0; I++) - if (*I == '?' || *I == '*' || *I == '|' || - *I == '[' || *I == '^' || *I == '$') - break; - if (*I == 0) - return _error->Error(_("Couldn't find package %s"),S); - - // Regexs must always be confirmed - ExpectedInst += 1000; + Slash = strchr(S,'/'); + if (Slash != 0) + { + VerIsRel = true; + *Slash = 0; + VerTag = Slash + 1; + } - // Compile the regex pattern - regex_t Pattern; - int Res; - if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE | - REG_NOSUB)) != 0) - { - char Error[300]; - regerror(Res,&Pattern,Error,sizeof(Error)); - return _error->Error(_("Regex compilation error - %s"),Error); + break; } - - // Run over the matches - bool Hit = false; - for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + + // Locate the package + pkgCache::PkgIterator Pkg = Cache->FindPkg(S); + Packages++; + if (Pkg.end() == true) { - if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) - continue; + // Check if the name is a regex + const char *I; + for (I = S; *I != 0; I++) + if (*I == '?' || *I == '*' || *I == '|' || + *I == '[' || *I == '^' || *I == '$') + break; + if (*I == 0) + return _error->Error(_("Couldn't find package %s"),S); + + // Regexs must always be confirmed + ExpectedInst += 1000; + + // Compile the regex pattern + regex_t Pattern; + int Res; + if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE | + REG_NOSUB)) != 0) + { + char Error[300]; + regerror(Res,&Pattern,Error,sizeof(Error)); + return _error->Error(_("Regex compilation error - %s"),Error); + } + + // Run over the matches + bool Hit = false; + for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + { + if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) + continue; + + ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"), + Pkg.Name(),S); - ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"), - Pkg.Name(),S); + if (VerTag != 0) + if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) + return false; + Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, + ExpectedInst,false); + } + regfree(&Pattern); + + if (Hit == false) + return _error->Error(_("Couldn't find package %s"),S); + } + else + { if (VerTag != 0) if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) return false; - - Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, - ExpectedInst,false); - } - regfree(&Pattern); - - if (Hit == false) - return _error->Error(_("Couldn't find package %s"),S); - } - else - { - if (VerTag != 0) - if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) + if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) return false; - if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) - return false; - } - } + } + } - /* If we are in the Broken fixing mode we do not attempt to fix the - problems. This is if the user invoked install without -f and gave - packages */ - if (BrokenFix == true && Cache->BrokenCount() != 0) - { - c1out << _("You might want to run `apt-get -f install' to correct these:") << endl; - ShowBroken(c1out,Cache,false); + /* If we are in the Broken fixing mode we do not attempt to fix the + problems. This is if the user invoked install without -f and gave + packages */ + if (BrokenFix == true && Cache->BrokenCount() != 0) + { + c1out << _("You might want to run `apt-get -f install' to correct these:") << endl; + ShowBroken(c1out,Cache,false); - return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).")); - } + return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).")); + } - // Call the scored problem resolver - Fix.InstallProtect(); - if (Fix.Resolve(true) == false) - _error->Discard(); + // Call the scored problem resolver + Fix.InstallProtect(); + if (Fix.Resolve(true) == false) + _error->Discard(); - // Now we check the state of the packages, - if (Cache->BrokenCount() != 0) - { - c1out << - _("Some packages could not be installed. This may mean that you have\n" - "requested an impossible situation or if you are using the unstable\n" - "distribution that some required packages have not yet been created\n" - "or been moved out of Incoming.") << endl; - if (Packages == 1) + // Now we check the state of the packages, + if (Cache->BrokenCount() != 0) { - c1out << endl; c1out << - _("Since you only requested a single operation it is extremely likely that\n" - "the package is simply not installable and a bug report against\n" - "that package should be filed.") << endl; - } + _("Some packages could not be installed. This may mean that you have\n" + "requested an impossible situation or if you are using the unstable\n" + "distribution that some required packages have not yet been created\n" + "or been moved out of Incoming.") << endl; + if (Packages == 1) + { + c1out << endl; + c1out << + _("Since you only requested a single operation it is extremely likely that\n" + "the package is simply not installable and a bug report against\n" + "that package should be filed.") << endl; + } - c1out << _("The following information may help to resolve the situation:") << endl; - c1out << endl; - ShowBroken(c1out,Cache,false); - return _error->Error(_("Broken packages")); - } - + c1out << _("The following information may help to resolve the situation:") << endl; + c1out << endl; + ShowBroken(c1out,Cache,false); + return _error->Error(_("Broken packages")); + } + } if (_config->FindB("APT::Get::AutomaticRemove")) { if (!DoAutomaticRemove(Cache)) return false; -- cgit v1.2.3 From e9ae36778e841f09ad195c17004e711bf7b7abae Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Aug 2006 15:08:58 +0200 Subject: * cmdline/apt-get.cc: - added "{no-}install-recommends" option to apt-get * doc/examples/configure-index: - recommends/suggests option documented --- cmdline/apt-get.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6979fa8f2..b419a05d9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2524,6 +2524,7 @@ int main(int argc,const char *argv[]) {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, + {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; -- cgit v1.2.3 From 4ef9a929f1cb74f08f764b321cbea62cbfe025a2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 11 Aug 2006 11:30:11 +0200 Subject: * cmdline/apt-get.cc: - added "--fix-policy" option to make it easy to fix any not-install recommends * apt-pkg/depcache.{cc,h} - MarkInstall() has a new "ForceImportantDeps" option (defaults to false) to fice the install of recommends even for already installed pkgs - a new PolicyBroken() function to see how much of the recommends are broken --- cmdline/apt-get.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7b7780a48..58976351c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -628,6 +628,8 @@ void CacheFile::Sort() and verifies that the system is OK. */ bool CacheFile::CheckDeps(bool AllowBroken) { + bool FixBroken = _config->FindB("APT::Get::Fix-Broken",false); + if (_error->PendingError() == true) return false; @@ -639,12 +641,24 @@ bool CacheFile::CheckDeps(bool AllowBroken) if (pkgApplyStatus(*DCache) == false) return false; + if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true) + { + FixBroken = true; + if ((DCache->PolicyBrokenCount() > 0)) + { + // upgrade all policy-broken packages with ForceImportantDeps=True + for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++) + if ((*DCache)[I].NowPolicyBroken() == true) + DCache->MarkInstall(I,true,0,true); + } + } + // Nothing is broken if (DCache->BrokenCount() == 0 || AllowBroken == true) return true; // Attempt to fix broken things - if (_config->FindB("APT::Get::Fix-Broken",false) == true) + if (FixBroken == true) { c1out << _("Correcting dependencies...") << flush; if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0) @@ -2543,6 +2557,7 @@ int main(int argc,const char *argv[]) {0,"arch-only","APT::Get::Arch-Only",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean}, + {0,"fix-policy","APT::Get::Fix-Policy-Broken",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; -- cgit v1.2.3 From 8eff320d8061aa7cad48c7eaf834f70e1d3e86b4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 14 Aug 2006 21:16:02 +0200 Subject: * cmdline/apt-get.cc: - fix the "fix-policy" code * debian/changelog: - new version --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 96e974acb..4bd66383f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -650,7 +650,7 @@ bool CacheFile::CheckDeps(bool AllowBroken) // upgrade all policy-broken packages with ForceImportantDeps=True for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++) if ((*DCache)[I].NowPolicyBroken() == true) - DCache->MarkInstall(I,true,0,true); + DCache->MarkInstall(I,true,0,false, true); } } -- cgit v1.2.3 From 9d2938d4e6e86c6afdb9606f76f4ae9ce0ac4ee5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 6 Sep 2006 19:12:34 +0200 Subject: * cmdline/apt-get.cc: - always show the autoremove information and give advice how to use it * debian/rules: - install apt.conf.autoremove with blacklist for linux-image and linux-restriceted-modules --- cmdline/apt-get.cc | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9e7071988..5e1ccb0c0 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1392,31 +1392,42 @@ bool DoUpdate(CommandLine &CmdL) /* Remove unused automatic packages */ bool DoAutomaticRemove(CacheFile &Cache) { - if(_config->FindI("Debug::pkgAutoRemove",false)) + bool Debug = _config->FindI("Debug::pkgAutoRemove",false); + pkgDepCache::ActionGroup group(*Cache); + + if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; if (_config->FindB("APT::Get::Remove",true) == false) return _error->Error(_("We are not supposed to delete stuff, can't " "start AutoRemover")); + string autoremovelist, autoremoveversions; + // look over the cache to see what can be removed + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - pkgDepCache::ActionGroup group(*Cache); - - // look over the cache to see what can be removed - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - { - if (Cache[Pkg].Garbage) - { - if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) - fprintf(stdout,"We could delete %s\n", Pkg.Name()); - - if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) + if (Cache[Pkg].Garbage) + { + 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")) + { + if(Pkg.CurrentVer() != 0 && + Pkg->CurrentState != pkgCache::State::ConfigFiles) Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false)); - else + else Cache->MarkKeep(Pkg, false, false); - } - } + } + } } + ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + if (!_config->FindB("APT::Get::AutomaticRemove") && + autoremovelist.size() > 0) + c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; // Now see if we destroyed anything if (Cache->BrokenCount() != 0) @@ -1632,10 +1643,8 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } } - if (_config->FindB("APT::Get::AutomaticRemove")) { - if (!DoAutomaticRemove(Cache)) + if (!DoAutomaticRemove(Cache)) return false; - } /* Print out a list of packages that are going to be installed extra to what the user asked */ -- cgit v1.2.3 From c97fd4ec4a34eb15eb8985890a47e768f4b94f0d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:32:32 +0200 Subject: * cmdline/apt-get.cc: - only error out if both "APT::Get::Autoremove" is set to true and "APT::Get::Remove" to false, in this case the the save options wins and apt will abort --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5e1ccb0c0..411b16e90 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1398,7 +1398,8 @@ bool DoAutomaticRemove(CacheFile &Cache) if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; - if (_config->FindB("APT::Get::Remove",true) == false) + 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")); -- cgit v1.2.3 From 3d0de656b6263d51c288d82ef2b352e53023382c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:52:19 +0200 Subject: * cmdline/apt-get.cc: - changed the behaviour of --no-remove and --auto-remove, if --no-remove is given, then that will turn off --auto-remove implicitely --- cmdline/apt-get.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 411b16e90..4af23641b 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"); 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 @@ -1415,7 +1420,7 @@ bool DoAutomaticRemove(CacheFile &Cache) autoremovelist += string(Pkg.Name()) + " "; autoremoveversions += string(Cache[Pkg].CandVersion) + " "; - if (_config->FindB("APT::Get::AutomaticRemove")) + if (doAutoRemove) { if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) @@ -1426,8 +1431,7 @@ 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 (!doAutoRemove && autoremovelist.size() > 0) c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; // Now see if we destroyed anything -- cgit v1.2.3 From ae24ac67f6bbab1474a5386b946fc7bd97ad86c8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:53:26 +0200 Subject: * cmdline/apt-get.cc: - typo --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 4af23641b..570e1016c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1430,7 +1430,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } } } - ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); if (!doAutoRemove && autoremovelist.size() > 0) c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; -- cgit v1.2.3 From c158ff49dacb8f6fdca98f9b43329eac44f1a827 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Sep 2006 14:02:53 +0200 Subject: * tasksupport (apt-get installtask lala) added --- cmdline/apt-get.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 64882e3e8..9705f84dc 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1406,6 +1406,61 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ +// DoInstallTask - Install task from the command line /*{{{*/ +// --------------------------------------------------------------------- +/* Install named task */ +bool DoInstallTask(CommandLine &CmdL) +{ + const char *start, *end; + pkgCache::PkgIterator Pkg; + + CacheFile Cache; + if (Cache.OpenForInstall() == false || + Cache.CheckDeps(CmdL.FileSize() != 1) == false) + return false; + + // create the records parser + pkgRecords Recs(Cache); + + unsigned int ExpectedInst = 0; + unsigned int Packages = 0; + pkgProblemResolver Fix(Cache); + char buf[64*1024]; + + for (const char **I = CmdL.FileList + 1; *I != 0; I++) + { + regex_t Pattern; + int Res; + + // build regexp for the task + char S[300]; + snprintf(S, sizeof(S), "^Task:.*%s.*\n", *I); + regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE); + + for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + { + pkgCache::VerIterator ver = (*Cache)[Pkg].CandidateVerIter(*Cache); + if(ver.end()) + continue; + pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); + parser.GetRec(start,end); + strncpy(buf, start, end-start); + buf[end-start] = 0x0; + if (regexec(&Pattern,buf,0,0,0) != 0) + continue; + TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst); + } + } + + // Call the scored problem resolver + Fix.InstallProtect(); + if (Fix.Resolve(true) == false) + _error->Discard(); + + // prompt for install + return InstallPackages(Cache,false,true); +} + // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -2546,6 +2601,7 @@ int main(int argc,const char *argv[]) CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate}, {"upgrade",&DoUpgrade}, {"install",&DoInstall}, + {"installtask",&DoInstallTask}, {"remove",&DoInstall}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, -- cgit v1.2.3 From ab04fa68f216974b277c708ab0788ef8798f879f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Sep 2006 15:41:52 +0200 Subject: * cmdline/apt-get.cc: - install with FixBroken=true --- cmdline/apt-get.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9705f84dc..57e0e9ec7 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1434,7 +1434,7 @@ bool DoInstallTask(CommandLine &CmdL) // build regexp for the task char S[300]; - snprintf(S, sizeof(S), "^Task:.*%s.*\n", *I); + snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", *I); regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE); for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) @@ -1448,14 +1448,13 @@ bool DoInstallTask(CommandLine &CmdL) buf[end-start] = 0x0; if (regexec(&Pattern,buf,0,0,0) != 0) continue; - TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst); + TryToInstall(Pkg,Cache,Fix,false,true,ExpectedInst); } } // Call the scored problem resolver Fix.InstallProtect(); - if (Fix.Resolve(true) == false) - _error->Discard(); + Fix.Resolve(true); // prompt for install return InstallPackages(Cache,false,true); -- cgit v1.2.3 From d6df222d8edb3e38401affcee2a4e5eba605da32 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Sep 2006 16:06:06 +0200 Subject: * cmdline/apt-get.cc: - call regexp_free() --- cmdline/apt-get.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 57e0e9ec7..2062aaa16 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1423,14 +1423,12 @@ bool DoInstallTask(CommandLine &CmdL) pkgRecords Recs(Cache); unsigned int ExpectedInst = 0; - unsigned int Packages = 0; pkgProblemResolver Fix(Cache); char buf[64*1024]; for (const char **I = CmdL.FileList + 1; *I != 0; I++) { regex_t Pattern; - int Res; // build regexp for the task char S[300]; @@ -1450,6 +1448,8 @@ bool DoInstallTask(CommandLine &CmdL) continue; TryToInstall(Pkg,Cache,Fix,false,true,ExpectedInst); } + + regfree(&Pattern); } // Call the scored problem resolver -- cgit v1.2.3 From 39cc1bbdd0faa13dcb150b573f56cd2dd64fa460 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Sep 2006 17:22:41 +0200 Subject: * cmdline/apt-get.cc: - changed syntax from "installtask" to "install taskname^" (the ^ <- makes it look for tasks) --- cmdline/apt-get.cc | 86 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 2062aaa16..09bf572a5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1409,55 +1409,46 @@ bool DoUpgrade(CommandLine &CmdL) // DoInstallTask - Install task from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named task */ -bool DoInstallTask(CommandLine &CmdL) +bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, + bool BrokenFix, + unsigned int& ExpectedInst, + const char *taskname) { const char *start, *end; pkgCache::PkgIterator Pkg; + char buf[64*1024]; + regex_t Pattern; - CacheFile Cache; - if (Cache.OpenForInstall() == false || - Cache.CheckDeps(CmdL.FileSize() != 1) == false) - return false; - - // create the records parser + // get the records pkgRecords Recs(Cache); - - unsigned int ExpectedInst = 0; - pkgProblemResolver Fix(Cache); - char buf[64*1024]; - for (const char **I = CmdL.FileList + 1; *I != 0; I++) + // build regexp for the task + char S[300]; + snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", taskname); + regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE); + + bool found = false; + bool res = true; + for (Pkg = Cache.PkgBegin(); Pkg.end() == false; Pkg++) { - regex_t Pattern; - - // build regexp for the task - char S[300]; - snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", *I); - regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE); - - for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) - { - pkgCache::VerIterator ver = (*Cache)[Pkg].CandidateVerIter(*Cache); - if(ver.end()) - continue; - pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); - parser.GetRec(start,end); - strncpy(buf, start, end-start); - buf[end-start] = 0x0; - if (regexec(&Pattern,buf,0,0,0) != 0) - continue; - TryToInstall(Pkg,Cache,Fix,false,true,ExpectedInst); - } - - regfree(&Pattern); + pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache); + if(ver.end()) + continue; + pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); + parser.GetRec(start,end); + strncpy(buf, start, end-start); + buf[end-start] = 0x0; + if (regexec(&Pattern,buf,0,0,0) != 0) + continue; + res &= TryToInstall(Pkg,Cache,Fix,false,BrokenFix,ExpectedInst); + found = true; } - - // Call the scored problem resolver - Fix.InstallProtect(); - Fix.Resolve(true); - // prompt for install - return InstallPackages(Cache,false,true); + if(!found) + _error->Error(_("Couldn't find task %s"),taskname); + + regfree(&Pattern); + return res; } // DoInstall - Install packages from the command line /*{{{*/ @@ -1496,6 +1487,18 @@ bool DoInstall(CommandLine &CmdL) bool Remove = DefRemove; char *VerTag = 0; bool VerIsRel = false; + + // this is a task! + if (Length >= 1 && S[Length - 1] == '^') + { + S[--Length] = 0; + // tasks must always be confirmed + ExpectedInst += 1000; + // see if we can install it + TryInstallTask(Cache, Fix, BrokenFix, ExpectedInst, S); + continue; + } + while (Cache->FindPkg(S).end() == true) { // Handle an optional end tag indicating what to do @@ -1512,7 +1515,7 @@ bool DoInstall(CommandLine &CmdL) S[--Length] = 0; continue; } - + char *Slash = strchr(S,'='); if (Slash != 0) { @@ -2600,7 +2603,6 @@ int main(int argc,const char *argv[]) CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate}, {"upgrade",&DoUpgrade}, {"install",&DoInstall}, - {"installtask",&DoInstallTask}, {"remove",&DoInstall}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, -- cgit v1.2.3 From be0a16728d441e6b37f647e0b989b173cca0c142 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Sep 2006 00:32:38 +0200 Subject: * cmdline/apt-get.cc: - run TryToInstall() in a way that it won't automatically tries to fix the cache after each package but queue them all first --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 09bf572a5..25d205a4f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1440,7 +1440,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, buf[end-start] = 0x0; if (regexec(&Pattern,buf,0,0,0) != 0) continue; - res &= TryToInstall(Pkg,Cache,Fix,false,BrokenFix,ExpectedInst); + res &= TryToInstall(Pkg,Cache,Fix,false,true,ExpectedInst); found = true; } -- cgit v1.2.3 From b255ff1a1161385b7f52454ec8661f058f05d6db Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 29 Sep 2006 15:13:45 +0200 Subject: * cmdline/apt-get.cc: - fix problem that AutomaticRemove can't be set permanently via preferences --- cmdline/apt-get.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 570e1016c..9b6e36e21 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1393,7 +1393,7 @@ bool DoUpdate(CommandLine &CmdL) bool DoAutomaticRemove(CacheFile &Cache) { bool Debug = _config->FindI("Debug::pkgAutoRemove",false); - bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove"); + bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false); pkgDepCache::ActionGroup group(*Cache); @@ -2560,7 +2560,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 /*{{{*/ -- cgit v1.2.3 From e406c1756b00ad725988c0da792330f8cf5d63f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 13 Mar 2007 12:00:21 +0100 Subject: * cmdline/apt-get.cc: - fix show-versions output --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9b6e36e21..6c1b915ab 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1419,7 +1419,7 @@ bool DoAutomaticRemove(CacheFile &Cache) std::cout << "We could delete %s" << Pkg.Name() << std::endl; autoremovelist += string(Pkg.Name()) + " "; - autoremoveversions += string(Cache[Pkg].CandVersion) + " "; + autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; if (doAutoRemove) { if(Pkg.CurrentVer() != 0 && -- cgit v1.2.3 From e4b74e4b347ccde887a3d7d8a585dcf264e13305 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Mar 2007 12:41:37 +0100 Subject: * cmdline/apt-get.cc: - apt-get install foo for a already installed package foo that is marked "auto" will clear the auto-flag --- cmdline/apt-get.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6c1b915ab..8f4e17898 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1484,6 +1484,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); @@ -1606,6 +1607,18 @@ 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(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++; + } } } @@ -1768,6 +1781,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); -- cgit v1.2.3 From fd59a713400968e1e9f35a7eaeea08b58e77c53b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Mar 2007 13:47:42 +0100 Subject: * cmdline/apt-get.cc: - do not clean the auto-flag in "remove" mode (e.g. apt-get remove already-installed-pkg) - only show packages in the auto-remove list that are not already marked for removal --- cmdline/apt-get.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 8f4e17898..ed1ef98be 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1417,9 +1417,13 @@ 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) + "\n"; + + // 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 && @@ -1611,7 +1615,8 @@ bool DoInstall(CommandLine &CmdL) // see if we need to fix the auto-mark flag // e.g. apt-get install foo // where foo is marked automatic - if(Cache[Pkg].Install() == false && + if(!Remove && + Cache[Pkg].Install() == false && (Cache[Pkg].Flags & pkgCache::Flag::Auto)) { ioprintf(c1out,_("%s set to manual installed.\n"), -- cgit v1.2.3 From 7898bd970a791bb8892b0dfdffc683828a447900 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Mar 2007 13:57:57 +0100 Subject: =?UTF-8?q?*=20cmdline/apt-get.cc:=20=20=20-=20applied=20patch=20f?= =?UTF-8?q?rom=20Frode=20M.=20D=C3=B8ving=20=20to=20have=20APT::Get::HideA?= =?UTF-8?q?utoRemove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmdline/apt-get.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ed1ef98be..e8e5a8c39 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1394,8 +1394,8 @@ 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; @@ -1434,8 +1434,9 @@ bool DoAutomaticRemove(CacheFile &Cache) } } } - ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); - if (!doAutoRemove && 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 -- cgit v1.2.3 From e47c7d16435822f40149cd831ff6ba0a143ded85 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 8 Jun 2007 22:21:42 +0200 Subject: * add "purge" commandline argument, closes: #133421) (thanks to Julien Danjou for the patch) --- cmdline/apt-get.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 64882e3e8..c79c1559e 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1428,7 +1428,11 @@ bool DoInstall(CommandLine &CmdL) bool DefRemove = false; if (strcasecmp(CmdL.FileList[0],"remove") == 0) DefRemove = true; - + else if (strcasecmp(CmdL.FileList[0], "purge") == 0) + { + _config->Set("APT::Get::Purge", true); + DefRemove = true; + } for (const char **I = CmdL.FileList + 1; *I != 0; I++) { // Duplicate the string @@ -2443,6 +2447,7 @@ bool ShowHelp(CommandLine &CmdL) " upgrade - Perform an upgrade\n" " install - Install new packages (pkg is libc6 not libc6.deb)\n" " remove - Remove packages\n" + " purge - Remove and purge packages\n" " source - Download source archives\n" " build-dep - Configure build-dependencies for source packages\n" " dist-upgrade - Distribution upgrade, see apt-get(8)\n" -- cgit v1.2.3 From 1979e742ad5e2a0b6e547fbe3f4c4066b5a9bd2e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 8 Jun 2007 23:06:54 +0200 Subject: * add --dsc-only option, thanks to K. Richard Pixley --- cmdline/apt-get.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c79c1559e..6bbc40242 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1954,6 +1954,11 @@ bool DoSource(CommandLine &CmdL) I->Type != "tar") continue; + // Dsc only mode only fetches .dsc files + if (_config->FindB("APT::Get::Dsc-Only",false) == true && + I->Type != "dsc") + continue; + // don't download the same uri twice (should this be moved to // the fetcher interface itself?) if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end()) @@ -2536,7 +2541,8 @@ int main(int argc,const char *argv[]) {0,"force-yes","APT::Get::force-yes",0}, {0,"print-uris","APT::Get::Print-URIs",0}, {0,"diff-only","APT::Get::Diff-Only",0}, - {0,"tar-only","APT::Get::tar-Only",0}, + {0,"tar-only","APT::Get::Tar-Only",0}, + {0,"dsc-only","APT::Get::Dsc-Only",0}, {0,"purge","APT::Get::Purge",0}, {0,"list-cleanup","APT::Get::List-Cleanup",0}, {0,"reinstall","APT::Get::ReInstall",0}, -- cgit v1.2.3 From 5a68ea79e4828bb5615b1d490fe811c18d04a8e1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 9 Jun 2007 01:22:45 +0200 Subject: * cmdline/apt-get.cc: - revert task-install feature - show auto-removal information --- cmdline/apt-get.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index e4632cc6c..e9b619787 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1596,6 +1596,18 @@ bool DoInstall(CommandLine &CmdL) bool Remove = DefRemove; char *VerTag = 0; bool VerIsRel = false; + + // this is a task! + if (Length >= 1 && S[Length - 1] == '^') + { + S[--Length] = 0; + // tasks must always be confirmed + ExpectedInst += 1000; + // see if we can install it + TryInstallTask(Cache, Fix, BrokenFix, ExpectedInst, S); + continue; + } + while (Cache->FindPkg(S).end() == true) { // Handle an optional end tag indicating what to do @@ -1744,10 +1756,8 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } } - if (_config->FindB("APT::Get::AutomaticRemove")) { - if (!DoAutomaticRemove(Cache)) - return false; - } + if (!DoAutomaticRemove(Cache)) + return false; /* Print out a list of packages that are going to be installed extra to what the user asked */ -- cgit v1.2.3