From: Michael Vogt Date: Fri, 8 Jun 2007 23:34:26 +0000 (+0200) Subject: * merged some more missing bits X-Git-Tag: 0.7.21~277^2~2 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/468126e3030ac3db47e4c7d361badf99c338fdf4?hp=-c * merged some more missing bits --- 468126e3030ac3db47e4c7d361badf99c338fdf4 diff --combined apt-pkg/depcache.cc index ac667d51d,4794d3503..af2fd54c7 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@@ -8,6 -8,9 +8,6 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/depcache.h" -#endif #include #include #include @@@ -23,6 -26,8 +23,8 @@@ #include #include + #include + #include pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) : @@@ -238,6 -243,6 +240,9 @@@ bool pkgDepCache::writeStateFile(OpProg std::clog << "Skipping already written " << pkg.Name() << std::endl; continue; } ++ // skip not installed ones if requested ++ if(InstalledOnly && pkg->CurrentVer == 0) ++ continue; if(_config->FindB("Debug::pkgAutoRemove",false)) std::clog << "Writing new AutoInstall: " << pkg.Name() << std::endl; @@@ -250,8 -255,9 +255,9 @@@ } fclose(OutFile); - // move the outfile over the real file + // move the outfile over the real file and set permissions rename(outfile.c_str(), state.c_str()); + chmod(state.c_str(), 0644); return true; } @@@ -270,7 -276,7 +276,7 @@@ bool pkgDepCache::CheckDep(DepIterator we allow it anyhow because dpkg does. Technically it is a packaging bug. Conflicts may never self match */ if (Dep.TargetPkg() != Dep.ParentPkg() || - (Dep->Type != Dep::Conflicts && Dep->Type != Dep::Obsoletes)) + (Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes)) { PkgIterator Pkg = Dep.TargetPkg(); // Check the base package @@@ -300,8 -306,7 +306,8 @@@ { /* Provides may never be applied against the same package if it is a conflicts. See the comment above. */ - if (P.OwnerPkg() == Pkg && Dep->Type == Dep::Conflicts) + if (P.OwnerPkg() == Pkg && + (Dep->Type == Dep::Conflicts || Dep->Type == Dep::DpkgBreaks)) continue; // Check if the provides is a hit @@@ -397,11 -402,9 +403,11 @@@ void pkgDepCache::AddStates(const PkgIt { StateCache &State = PkgState[Pkg->ID]; - // The Package is broken + // The Package is broken (either minimal dep or policy dep) if ((State.DepState & DepInstMin) != DepInstMin) iBrokenCount += Add; + if ((State.DepState & DepInstPolicy) != DepInstPolicy) + iPolicyBrokenCount += Add; // Bad state if (Pkg.State() != PkgIterator::NeedsNothing) @@@ -455,9 -458,7 +461,9 @@@ void pkgDepCache::BuildGroupOrs(VerIter /* Invert for Conflicts. We have to do this twice to get the right sense for a conflicts group */ - if (D->Type == Dep::Conflicts || D->Type == Dep::Obsoletes) + if (D->Type == Dep::Conflicts || + D->Type == Dep::DpkgBreaks || + D->Type == Dep::Obsoletes) State = ~State; // Add to the group if we are within an or.. @@@ -468,9 -469,7 +474,9 @@@ Group = 0; // Invert for Conflicts - if (D->Type == Dep::Conflicts || D->Type == Dep::Obsoletes) + if (D->Type == Dep::Conflicts || + D->Type == Dep::DpkgBreaks || + D->Type == Dep::Obsoletes) State = ~State; } } @@@ -603,9 -602,7 +609,9 @@@ void pkgDepCache::Update(OpProgress *Pr Group = 0; // Invert for Conflicts - if (D->Type == Dep::Conflicts || D->Type == Dep::Obsoletes) + if (D->Type == Dep::Conflicts || + D->Type == Dep::DpkgBreaks || + D->Type == Dep::Obsoletes) State = ~State; } } @@@ -635,9 -632,7 +641,9 @@@ void pkgDepCache::Update(DepIterator D State = DependencyState(D); // Invert for Conflicts - if (D->Type == Dep::Conflicts || D->Type == Dep::Obsoletes) + if (D->Type == Dep::Conflicts || + D->Type == Dep::DpkgBreaks || + D->Type == Dep::Obsoletes) State = ~State; RemoveStates(D.ParentPkg()); @@@ -709,6 -704,7 +715,6 @@@ void pkgDepCache::MarkKeep(PkgIterator // We dont even try to keep virtual packages.. if (Pkg->VersionList == 0) return; - #if 0 // reseting the autoflag here means we lose the // auto-mark information if a user selects a package for removal // but changes his mind then and sets it for keep again @@@ -779,8 -775,7 +785,8 @@@ void pkgDepCache::MarkDelete(PkgIterato // --------------------------------------------------------------------- /* */ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, - unsigned long Depth, bool FromUser) + unsigned long Depth, bool FromUser, + bool ForceImportantDeps) { if (Depth > 100) return; @@@ -795,8 -790,7 +801,8 @@@ installed */ StateCache &P = PkgState[Pkg->ID]; P.iFlags &= ~AutoKept; - if (P.InstBroken() == false && (P.Mode == ModeInstall || + if ((P.InstPolicyBroken() == false && P.InstBroken() == false) && + (P.Mode == ModeInstall || P.CandidateVer == (Version *)Pkg.CurrentVer())) { if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0) @@@ -807,9 -801,11 +813,9 @@@ // See if there is even any possible instalation candidate if (P.CandidateVer == 0) return; - // We dont even try to install virtual packages.. if (Pkg->VersionList == 0) return; - /* Target the candidate version and remove the autoflag. We reset the autoflag below if this was called recursively. Otherwise the user should have the ability to de-auto a package by changing its state */ @@@ -863,43 -859,10 +869,43 @@@ /* Check if this dep should be consider for install. If it is a user defined important dep and we are installed a new package then - it will be installed. Otherwise we only worry about critical deps */ + it will be installed. Otherwise we only check for important + deps that have changed from the installed version + */ if (IsImportantDep(Start) == false) continue; - if (Pkg->CurrentVer != 0 && Start.IsCritical() == false) + + /* check if any ImportantDep() (but not Critial) where added + * since we installed the package + */ + bool isNewImportantDep = false; + if(!ForceImportantDeps && !Start.IsCritical()) + { + bool found=false; + VerIterator instVer = Pkg.CurrentVer(); + if(!instVer.end()) + { + for (DepIterator D = instVer.DependsList(); D.end() != true; D++) + { + //FIXME: deal better with or-groups(?) + DepIterator LocalStart = D; + + if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg()) + found=true; + } + // this is a new dep if it was not found to be already + // a important dep of the installed pacakge + isNewImportantDep = !found; + } + } + if(isNewImportantDep) + if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) + std::clog << "new important dependency: " + << Start.TargetPkg().Name() << std::endl; + + // skip important deps if the package is already installed + if (Pkg->CurrentVer != 0 && Start.IsCritical() == false + && !isNewImportantDep && !ForceImportantDeps) continue; /* If we are in an or group locate the first or that can @@@ -910,8 -873,7 +916,8 @@@ /* This bit is for processing the possibilty of an install/upgrade fixing the problem */ SPtrArray List = Start.AllTargets(); - if ((DepState[Start->ID] & DepCVer) == DepCVer) + if (Start->Type != Dep::DpkgBreaks && + (DepState[Start->ID] & DepCVer) == DepCVer) { // Right, find the best version to install.. Version **Cur = List; @@@ -959,7 -921,7 +965,7 @@@ else { // mark automatic dependency - MarkInstall(InstPkg,true,Depth + 1, false); + MarkInstall(InstPkg,true,Depth + 1, false, ForceImportantDeps); // Set the autoflag, after MarkInstall because MarkInstall unsets it if (P->CurrentVer == 0) PkgState[InstPkg->ID].Flags |= Flag::Auto; @@@ -967,23 -929,17 +973,23 @@@ } continue; } - + /* For conflicts we just de-install the package and mark as auto, - Conflicts may not have or groups */ - if (Start->Type == Dep::Conflicts || Start->Type == Dep::Obsoletes) + Conflicts may not have or groups. For dpkg's Breaks we try to + upgrade the package. */ + if (Start->Type == Dep::Conflicts || Start->Type == Dep::Obsoletes || + Start->Type == Dep::DpkgBreaks) { for (Version **I = List; *I != 0; I++) { VerIterator Ver(*this,*I); PkgIterator Pkg = Ver.ParentPkg(); - - MarkDelete(Pkg); + + if (Start->Type != Dep::DpkgBreaks) + MarkDelete(Pkg); + else + if (PkgState[Pkg->ID].CandidateVer != *I) + MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps); } continue; } @@@ -1131,28 -1087,7 +1137,28 @@@ pkgCache::VerIterator pkgDepCache::Poli /* */ bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep) { - return Dep.IsCritical(); + if(Dep.IsCritical()) + return true; + else if(Dep->Type == pkgCache::Dep::Recommends) + { + if ( _config->FindB("APT::Install-Recommends", false)) + return true; + // we suport a special mode to only install-recommends for certain + // sections + // FIXME: this is a meant as a temporarly solution until the + // recommends are cleaned up + string s = _config->Find("APT::Install-Recommends-Section",""); + if(s.size() > 0) + { + const char *sec = Dep.TargetPkg().Section(); + if (sec && strcmp(sec, s.c_str()) == 0) + return true; + } + } + else if(Dep->Type == pkgCache::Dep::Suggests) + return _config->FindB("APT::Install-Suggests", false); + + return false; } /*}}}*/ diff --combined cmdline/apt-mark index dadc01366,728f083dc..fdc3e1856 --- a/cmdline/apt-mark +++ b/cmdline/apt-mark @@@ -60,5 -60,5 +60,6 @@@ if __name__ == "__main__" else: outfile.write(str(tagfile.Section)+"\n") # all done, rename the tmpfile + os.chmod(outfile.name, 0644) os.rename(outfile.name, STATE_FILE) + os.chmod(outfile.name, 0644)