X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/d2685fd634b32f152748b7004c6810e946bbbcf2..aa0e1101d75e6b61d63dc486caa0ab32a45b024f:/apt-pkg/algorithms.cc?ds=sidebyside diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 8dadb933a..505ba59f7 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.13 1998/12/06 03:41:25 jgg Exp $ +// $Id: algorithms.cc,v 1.18 1999/06/04 02:31:37 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -29,7 +29,7 @@ pkgProblemResolver *pkgProblemResolver::This = 0; // --------------------------------------------------------------------- /* */ pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache), - Sim(Cache) + Sim(Cache.GetMap()) { Flags = new unsigned char[Cache.HeaderP->PackageCount]; memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount); @@ -44,7 +44,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/) PkgIterator Pkg = Sim.FindPkg(iPkg.Name()); Flags[Pkg->ID] = 1; - clog << "Inst " << Pkg.Name(); + cout << "Inst " << Pkg.Name(); Sim.MarkInstall(Pkg,false); // Look for broken conflicts+predepends. @@ -58,7 +58,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/) { if ((Sim[D] & pkgDepCache::DepInstall) == 0) { - clog << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']'; + cout << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']'; if (D->Type == pkgCache::Dep::Conflicts) _error->Error("Fatal, conflicts violated %s",I.Name()); } @@ -68,7 +68,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/) if (Sim.BrokenCount() != 0) ShortBreaks(); else - clog << endl; + cout << endl; return true; } /*}}}*/ @@ -86,7 +86,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg) // Sim.MarkInstall(Pkg,false); if (Sim[Pkg].InstBroken() == true) { - clog << "Conf " << Pkg.Name() << " broken" << endl; + cout << "Conf " << Pkg.Name() << " broken" << endl; Sim.Update(); @@ -98,21 +98,21 @@ bool pkgSimulate::Configure(PkgIterator iPkg) continue; if (D->Type == pkgCache::Dep::Conflicts) - clog << " Conflicts:" << D.TargetPkg().Name(); + cout << " Conflicts:" << D.TargetPkg().Name(); else - clog << " Depends:" << D.TargetPkg().Name(); + cout << " Depends:" << D.TargetPkg().Name(); } - clog << endl; + cout << endl; _error->Error("Conf Broken %s",Pkg.Name()); } else - clog << "Conf " << Pkg.Name(); + cout << "Conf " << Pkg.Name(); if (Sim.BrokenCount() != 0) ShortBreaks(); else - clog << endl; + cout << endl; return true; } @@ -127,12 +127,12 @@ bool pkgSimulate::Remove(PkgIterator iPkg) Flags[Pkg->ID] = 3; Sim.MarkDelete(Pkg); - clog << "Remv " << Pkg.Name(); + cout << "Remv " << Pkg.Name(); if (Sim.BrokenCount() != 0) ShortBreaks(); else - clog << endl; + cout << endl; return true; } @@ -142,18 +142,18 @@ bool pkgSimulate::Remove(PkgIterator iPkg) /* */ void pkgSimulate::ShortBreaks() { - clog << " ["; + cout << " ["; for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++) { if (Sim[I].InstBroken() == true) { if (Flags[I->ID] == 0) - clog << I.Name() << ' '; + cout << I.Name() << ' '; /* else - clog << I.Name() << "! ";*/ + cout << I.Name() << "! ";*/ } } - clog << ']' << endl; + cout << ']' << endl; } /*}}}*/ // ApplyStatus - Adjust for non-ok packages /*{{{*/ @@ -169,16 +169,37 @@ bool pkgApplyStatus(pkgDepCache &Cache) if (I->InstState == pkgCache::State::ReInstReq || I->InstState == pkgCache::State::HoldReInstReq) { - Cache.MarkKeep(I); + if (I.CurrentVer().Downloadable() == true) + Cache.MarkKeep(I); + else + { + // Is this right? Will dpkg choke on an upgrade? + if (Cache[I].CandidateVerIter(Cache).Downloadable() == true) + Cache.MarkInstall(I); + else + return _error->Error("The package %s needs to be reinstalled, " + "but I can't find an archive for it.",I.Name()); + } + continue; } switch (I->CurrentState) { - // This means installation failed somehow + /* This means installation failed somehow - it does not need to be + re-unpacked (probably) */ case pkgCache::State::UnPacked: case pkgCache::State::HalfConfigured: - Cache.MarkKeep(I); + if (I.CurrentVer().Downloadable() == true || + I.State() != pkgCache::PkgIterator::NeedsUnpack) + Cache.MarkKeep(I); + else + { + if (Cache[I].CandidateVerIter(Cache).Downloadable() == true) + Cache.MarkInstall(I); + else + Cache.MarkDelete(I); + } break; // This means removal failed @@ -700,7 +721,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { if (Debug == true) clog << "Note, a broken or group was found in " << I.Name() << "." << endl; - Cache.MarkDelete(I); + if ((Flags[I->ID] & Protected) != Protected) + Cache.MarkDelete(I); break; } @@ -754,7 +776,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) Scores[I->ID] = Scores[Pkg->ID]; } } - + Change = true; Done = true; break; @@ -834,8 +856,19 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) delete [] PList; if (Cache.BrokenCount() != 0) - return _error->Error("Internal error, pkgProblemResolver::Resolve generated breaks."); - + { + // See if this is the result of a hold + pkgCache::PkgIterator I = Cache.PkgBegin(); + for (;I.end() != true; I++) + { + if (Cache[I].InstBroken() == false) + continue; + if ((Flags[I->ID] & Protected) != Protected) + return _error->Error("Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages."); + } + return _error->Error("Unable to correct problems, you have held broken packages."); + } + return true; } /*}}}*/