From: Michael Vogt Date: Thu, 14 Dec 2006 10:34:01 +0000 (+0100) Subject: * merged from the apt--auto-mark branch X-Git-Tag: 0.7.21~284^2~11 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/a8d4b8ff68e674110799fb193a897af56ca6a041?hp=-c * merged from the apt--auto-mark branch --- a8d4b8ff68e674110799fb193a897af56ca6a041 diff --combined cmdline/apt-get.cc index be4b46857,9b6e36e21..6949dc6eb --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@@ -629,8 -629,6 +629,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; @@@ -642,24 -640,12 +642,24 @@@ 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, false, 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) @@@ -1160,11 -1146,9 +1160,11 @@@ bool TryToInstall(pkgCache::PkgIterato 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; } /*}}}*/ @@@ -1409,7 -1393,7 +1409,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); @@@ -1485,51 -1469,6 +1485,51 @@@ bool DoUpgrade(CommandLine &CmdL return InstallPackages(Cache,true); } /*}}}*/ +// DoInstallTask - Install task from the command line /*{{{*/ +// --------------------------------------------------------------------- +/* Install named task */ +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; + + // get the records + pkgRecords Recs(Cache); + + // 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++) + { + 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; + } + + if(!found) + _error->Error(_("Couldn't find task %s"),taskname); + + regfree(&Pattern); + return res; +} + // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@@ -2621,7 -2560,6 +2621,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 /*{{{*/ @@@ -2679,8 -2617,6 +2678,8 @@@ int main(int argc,const char *argv[] {0,"arch-only","APT::Get::Arch-Only",0}, {0,"auto-remove","APT::Get::AutomaticRemove",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}}; diff --combined doc/apt-get.8.xml index 17f663a35,db852d007..3c245b83b --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@@ -47,6 -47,7 +47,7 @@@ check clean autoclean + autoremove @@@ -203,6 -204,11 +204,11 @@@ APT::Clean-Installed will prevent installed packages from being erased if it is set to off. + + autoremove + autoremove is used to remove packages that were automatically + installed to satisfy dependencies for some package and that are no more needed. + @@@ -382,6 -388,13 +388,13 @@@ Configuration Item: APT::Get::Remove. + + If the command is either install or remove, + then this option acts like running autoremove command, removing the unused + dependency packages. Configuration Item: APT::Get::AutomaticRemove. + + + Only has meaning for the source and build-dep @@@ -467,7 -480,7 +480,7 @@@ See Also &apt-cache;, &apt-cdrom;, &dpkg;, &dselect;, &sources-list;, - &apt-conf;, &apt-config;, + &apt-conf;, &apt-config;, &apt-secure;, The APT User's guide in &guidesdir;, &apt-preferences;, the APT Howto.