#include <apt-pkg/algorithms.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/tagfile.h>
return false;
}
-
pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) :
cache(cache), released(false)
{
pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) :
group_level(0), Cache(pCache), PkgState(0), DepState(0)
{
+ DebugMarker = _config->FindB("Debug::pkgDepCache::Marker", false);
+ DebugAutoInstall = _config->FindB("Debug::pkgDepCache::AutoInstall", false);
delLocalPolicy = 0;
LocalPolicy = Plcy;
if (LocalPolicy == 0)
ostr.str(string(""));
ostr << "Package: " << pkg.Name()
<< "\nAuto-Installed: 1\n\n";
- fprintf(OutFile,ostr.str().c_str());
+ fprintf(OutFile,"%s",ostr.str().c_str());
fprintf(OutFile,"\n");
}
}
// DepCache::MarkKeep - Put the package in the keep state /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
+void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser,
+ unsigned long Depth)
{
// Simplifies other routines.
if (Pkg.end() == true)
P.Flags &= ~Flag::Auto;
#endif
+ if (DebugMarker == true)
+ std::clog << OutputInDepth(Depth) << "MarkKeep " << Pkg << std::endl;
+
RemoveSizes(Pkg);
RemoveStates(Pkg);
// DepCache::MarkDelete - Put the package in the delete state /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
+void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge,
+ unsigned long Depth)
{
// Simplifies other routines.
if (Pkg.end() == true)
if (Pkg->VersionList == 0)
return;
+ if (DebugMarker == true)
+ std::clog << OutputInDepth(Depth) << "MarkDelete " << Pkg << std::endl;
+
RemoveSizes(Pkg);
RemoveStates(Pkg);
P.CandidateVer == (Version *)Pkg.CurrentVer()))
{
if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0)
- MarkKeep(Pkg, false, FromUser);
+ MarkKeep(Pkg, false, FromUser, Depth+1);
return;
}
if (AutoInst == false)
return;
+ if (DebugMarker == true)
+ std::clog << OutputInDepth(Depth) << "MarkInstall " << Pkg << std::endl;
+
DepIterator Dep = P.InstVerIter(*this).DependsList();
for (; Dep.end() != true;)
{
{
//FIXME: deal better with or-groups(?)
DepIterator LocalStart = D;
-
- if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg())
+
+ if(IsImportantDep(D) && !D.IsCritical() &&
+ Start.TargetPkg() == D.TargetPkg())
{
if(!isPreviouslySatisfiedImportantDep)
{
}
}
if(isNewImportantDep)
- if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
- std::clog << "new important dependency: "
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "new important dependency: "
<< Start.TargetPkg().Name() << std::endl;
if(isPreviouslySatisfiedImportantDep)
- if(_config->FindB("Debug::pkgDepCache::AutoInstall", false) == true)
- std::clog << "previously satisfied important dependency on "
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
<< Start.TargetPkg().Name() << std::endl;
// skip important deps if the package is already installed
}
}
- if (InstPkg.end() == false)
+ if (InstPkg.end() == false &&
+ AutoInstOk(InstPkg, (*this)[InstPkg].CandidateVerIter(*this), Start))
{
- if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
- std::clog << "Installing " << InstPkg.Name()
- << " as dep of " << Pkg.Name()
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name()
+ << " as " << Start.DepType() << " of " << Pkg.Name()
<< std::endl;
// now check if we should consider it a automatic dependency or not
if(Pkg.Section() && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section()))
{
- if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
- std::clog << "Setting NOT as auto-installed (direct dep of pkg in APT::Never-MarkAuto-Section)" << std::endl;
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "Setting NOT as auto-installed (direct "
+ << Start.DepType() << " of pkg in APT::Never-MarkAuto-Sections)" << std::endl;
MarkInstall(InstPkg,true,Depth + 1, true);
}
else
PkgIterator Pkg = Ver.ParentPkg();
if (Start->Type != Dep::DpkgBreaks)
- MarkDelete(Pkg);
+ {
+ if(AutoInstOk(Pkg, VerIterator(*this), Start))
+ MarkDelete(Pkg);
+ }
else
- if (PkgState[Pkg->ID].CandidateVer != *I)
+ if (PkgState[Pkg->ID].CandidateVer != *I &&
+ AutoInstOk(Pkg, VerIterator(*this, PkgState[Pkg->ID].CandidateVer), Start))
MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
}
continue;
}
}
}
+
+// DepCache::AutoInstOk - check if it is to install this package /*{{{*/
+// ---------------------------------------------------------------------
+/* The default implementation just honors dpkg hold
+ But an application using this library can override this method
+ to control the MarkInstall behaviour */
+bool pkgDepCache::AutoInstOk(const PkgIterator &Pkg,
+ const VerIterator &v,
+ const DepIterator &d)
+{
+ return (Pkg->SelectedState != pkgCache::State::Hold);
+}
/*}}}*/
// DepCache::SetReInstall - Set the reinstallation flag /*{{{*/
// ---------------------------------------------------------------------