--- apt-0.5.15lorg2/cmdline/apt-get.cc- 2009-03-16 12:59:03 +0300 +++ apt-0.5.15lorg2/cmdline/apt-get.cc 2009-03-16 14:18:14 +0300 @@ -1234,10 +1234,12 @@ bool DownloadPackages(vector &UR // --------------------------------------------------------------------- /* This used to be inlined in DoInstall, but with the advent of regex package name matching it was split out.. */ -bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, - pkgProblemResolver &Fix,bool Remove,bool BrokenFix, +bool TryToInstall(pkgCache::PkgIterator &Pkg,pkgDepCache &Cache, + pkgProblemResolver &Fix,bool Remove, bool& mark, unsigned int &ExpectedInst,bool AllowFail = true) { + mark = false; + // CNC:2004-03-03 - Improved virtual package handling. if (Pkg->VersionList == 0 && Pkg->ProvidesList != 0) { @@ -1483,6 +1485,7 @@ bool TryToInstall(pkgCache::PkgIterator // Install it Cache.MarkInstall(Pkg,false); + mark = true; if (State.Install() == false) { if (_config->FindB("APT::Get::ReInstall",false) == true) @@ -1502,10 +1505,7 @@ bool TryToInstall(pkgCache::PkgIterator } else ExpectedInst++; - - // Install it with autoinstalling enabled. - if (State.InstBroken() == true && BrokenFix == false) - Cache.MarkInstall(Pkg,true); + return true; } /*}}}*/ @@ -1988,6 +1988,7 @@ bool DoInstall(CommandLine &CmdL) else if (strcasecmp(CmdL.FileList[0],"reinstall") == 0) _config->Set("APT::Get::ReInstall", true); + std::list marked; for (const char **I = CmdL.FileList + 1; *I != 0; I++) { // Duplicate the string @@ -2140,6 +2141,7 @@ bool DoInstall(CommandLine &CmdL) // Run over the matches bool Hit = false; + bool mark; for (vector::const_iterator I = VS.begin(); I != VS.end(); I++) { @@ -2150,8 +2152,10 @@ bool DoInstall(CommandLine &CmdL) ioprintf(c1out,_("Selecting %s for '%s'\n"), Pkg.Name(),OrigS); - Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, + Hit |= TryToInstall(Pkg,Cache,Fix,Remove,mark, ExpectedInst,true); + if (mark) + marked.push_back(Pkg); } if (Hit == true) @@ -2176,6 +2180,7 @@ bool DoInstall(CommandLine &CmdL) // Run over the matches bool Hit = false; + bool mark; for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) { if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) @@ -2190,8 +2195,10 @@ bool DoInstall(CommandLine &CmdL) if (TryToChangeVer(Pkg,Cache,Fix,VerOp,VerTag,VerIsRel) == false) return false; - Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, + Hit |= TryToInstall(Pkg,Cache,Fix,Remove,mark, ExpectedInst,false); + if (mark) + marked.push_back(Pkg); } regfree(&Pattern); @@ -2204,11 +2211,24 @@ bool DoInstall(CommandLine &CmdL) // CNC:2003-11-05 if (TryToChangeVer(Pkg,Cache,Fix,VerOp,VerTag,VerIsRel) == false) return false; - if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) + bool mark; + if (TryToInstall(Pkg,Cache,Fix,Remove,mark,ExpectedInst) == false) return false; + if (mark) + marked.push_back(Pkg); } } + // Install it with autoinstalling enabled. + for (std::list::iterator MI = marked.begin(); + MI != marked.end(); ++MI) + { + pkgCache::PkgIterator Pkg = *MI; + pkgDepCache::StateCache &State = Cache[Pkg]; + if (State.InstBroken() == true && BrokenFix == false) + ((pkgDepCache&) Cache).MarkInstall(Pkg,true); + } + // CNC:2003-03-19 #ifdef WITH_LUA _lua->SetDepCache(Cache); @@ -2967,7 +2987,12 @@ bool DoBuildDep(CommandLine &CmdL) */ if (IV.end() == false && Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - TryToInstall(Pkg,Cache,Fix,true,false,ExpectedInst); + { + bool Hit = false; + bool mark; + Hit |= TryToInstall(Pkg,Cache,Fix,true,mark,ExpectedInst); + } + } else // BuildDep || BuildDepIndep { @@ -3100,7 +3125,8 @@ bool DoBuildDep(CommandLine &CmdL) if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; - if (TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst) == true) + bool mark; + if (TryToInstall(Pkg,Cache,Fix,false,mark,ExpectedInst) == true) { // We successfully installed something; skip remaining alternatives skipAlternatives = hasAlternatives;