// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cacheiterators.h,v 1.16 2001/02/20 07:03:17 jgg Exp $
+// $Id: cacheiterators.h,v 1.17 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Cache Iterators - Iterators for navigating the cache structure
inline unsigned long Index() const {return File - Owner->PkgFileP;};
bool IsOk();
-
+ string RelStr();
+
// Constructors
inline PkgFileIterator() : Owner(0), File(0) {};
inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgFileP) {};
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debindexfile.cc,v 1.4 2001/03/13 06:51:46 jgg Exp $
+// $Id: debindexfile.cc,v 1.5 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Debian Specific sources.list types and the three sorts of Debian
// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
// ---------------------------------------------------------------------
/* */
-string debSourcesIndex::Describe() const
+string debSourcesIndex::Describe(bool Short) const
{
char S[300];
- snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
- IndexFile("Sources").c_str());
+ if (Short == true)
+ snprintf(S,sizeof(S),"%s",Info("Packages").c_str());
+ else
+ snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
+ IndexFile("Sources").c_str());
+
return S;
}
/*}}}*/
// ---------------------------------------------------------------------
/* This should help the user find the index in the sources.list and
in the filesystem for problem solving */
-string debPackagesIndex::Describe() const
+string debPackagesIndex::Describe(bool Short) const
{
char S[300];
- snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
- IndexFile("Packages").c_str());
+ if (Short == true)
+ snprintf(S,sizeof(S),"%s",Info("Packages").c_str());
+ else
+ snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
+ IndexFile("Packages").c_str());
return S;
}
/*}}}*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debindexfile.h,v 1.2 2001/02/20 07:03:17 jgg Exp $
+// $Id: debindexfile.h,v 1.3 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Debian Index Files
virtual const Type *GetType() const;
// Interface for acquire
- virtual string Describe() const {return File;};
+ virtual string Describe(bool Short) const {return File;};
// Interface for the Cache Generator
virtual bool Exists() const;
virtual string ArchiveURI(string File) const {return URI + File;};
// Interface for acquire
- virtual string Describe() const;
+ virtual string Describe(bool Short) const;
virtual bool GetIndexes(pkgAcquire *Owner) const;
// Interface for the Cache Generator
virtual string ArchiveURI(string File) const {return URI + File;};
// Interface for acquire
- virtual string Describe() const;
+ virtual string Describe(bool Short) const;
virtual bool GetIndexes(pkgAcquire *Owner) const;
// Interface for the record parsers
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debsystem.cc,v 1.2 2001/02/20 07:03:17 jgg Exp $
+// $Id: debsystem.cc,v 1.3 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
System - Abstraction for running on different systems.
VS = &debVS;
}
/*}}}*/
+// System::~debSystem - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+debSystem::~debSystem()
+{
+ delete StatusFile;
+}
+ /*}}}*/
// System::Lock - Get the lock /*{{{*/
// ---------------------------------------------------------------------
/* This mirrors the operations dpkg does when it starts up. Note the
/* */
bool debSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
{
- List.push_back(new debStatusIndex(_config->FindFile("Dir::State::status")));
+ if (StatusFile == 0)
+ StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status"));
+ List.push_back(StatusFile);
return true;
}
/*}}}*/
+// System::FindIndex - Get an index file for status files /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debSystem::FindIndex(pkgCache::PkgFileIterator File,
+ pkgIndexFile *&Found) const
+{
+ if (StatusFile == 0)
+ return false;
+ if (StatusFile->FindInCache(*File.Cache()) == File)
+ {
+ Found = StatusFile;
+ return true;
+ }
+
+ return false;
+}
+ /*}}}*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debsystem.h,v 1.2 2001/02/20 07:03:17 jgg Exp $
+// $Id: debsystem.h,v 1.3 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
System - Debian version of the System Class
#include <apt-pkg/pkgsystem.h>
+class debStatusIndex;
class debSystem : public pkgSystem
{
// For locking support
unsigned LockCount;
bool CheckUpdates();
+ debStatusIndex *StatusFile;
+
public:
virtual bool Lock();
virtual bool ArchiveSupported(const char *Type);
virtual signed Score(Configuration const &Cnf);
virtual bool AddStatusFiles(vector<pkgIndexFile *> &List);
+ virtual bool FindIndex(pkgCache::PkgFileIterator File,
+ pkgIndexFile *&Found) const;
debSystem();
+ ~debSystem();
};
extern debSystem debSys;
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: indexfile.h,v 1.3 2001/03/11 07:35:49 jgg Exp $
+// $Id: indexfile.h,v 1.4 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Index File - Abstraction for an index of archive/source file.
virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
pkgSrcRecords::File const &File) const;
- virtual string Describe() const = 0;
+ virtual string Describe(bool Short = false) const = 0;
// Interface for acquire
virtual string ArchiveURI(string /*File*/) const {return string();};
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.cc,v 1.33 2001/03/05 02:43:28 jgg Exp $
+// $Id: pkgcache.cc,v 1.34 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
return true;
}
/*}}}*/
+// PkgFileIterator::RelStr - Return the release string /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgCache::PkgFileIterator::RelStr()
+{
+ string Res;
+ if (Version() != 0)
+ Res = Res + (Res.empty() == true?"v=":",v=") + Version();
+ if (Origin() != 0)
+ Res = Res + (Res.empty() == true?"o=":",o=") + Origin();
+ if (Archive() != 0)
+ Res = Res + (Res.empty() == true?"a=":",a=") + Archive();
+ if (Label() != 0)
+ Res = Res + (Res.empty() == true?"l=":",l=") + Label();
+ if (Component() != 0)
+ Res = Res + (Res.empty() == true?"c=":",c=") + Component();
+ return Res;
+}
+ /*}}}*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgsystem.h,v 1.3 2001/03/11 07:35:49 jgg Exp $
+// $Id: pkgsystem.h,v 1.4 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
System - Abstraction for running on different systems.
// Return a list of system index files..
virtual bool AddStatusFiles(vector<pkgIndexFile *> &List) = 0;
+ virtual bool FindIndex(pkgCache::PkgFileIterator File,
+ pkgIndexFile *&Found) const = 0;
/* Evauluate how 'right' we are for this system based on the filesystem
etc.. */
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: policy.cc,v 1.5 2001/03/13 05:23:42 jgg Exp $
+// $Id: policy.cc,v 1.6 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Package Version Policy implementation
pkgVersionMatch Match(I->Data,I->Type);
for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++)
{
-/* hmm?
- if ((F->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource)
- continue;*/
-
if (Match.FileMatch(F) == true && Fixed[F->ID] == false)
{
if (I->Priority != 0 && I->Priority > 0)
best package is. */
pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
{
- const Pin &PPkg = Pins[Pkg->ID];
-
// Look for a package pin and evaluate it.
- signed Max = 0;
- pkgCache::VerIterator Pref(*Cache);
- if (PPkg.Type != pkgVersionMatch::None)
- {
- pkgVersionMatch Match(PPkg.Data,PPkg.Type);
- Pref = Match.Find(Pkg);
- Max = PPkg.Priority;
- if (PPkg.Priority == 0)
- Max = 989;
- }
+ signed Max = GetPriority(Pkg);
+ pkgCache::VerIterator Pref = GetMatch(Pkg);
/* Falling through to the default version.. Setting Max to zero
effectively excludes everything <= 0 which are the non-automatic
P->Data = Data;
}
/*}}}*/
+// Policy::GetMatch - Get the matching version for a package pin /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgCache::VerIterator pkgPolicy::GetMatch(pkgCache::PkgIterator Pkg)
+{
+ const Pin &PPkg = Pins[Pkg->ID];
+ if (PPkg.Type != pkgVersionMatch::None)
+ {
+ pkgVersionMatch Match(PPkg.Data,PPkg.Type);
+ return Match.Find(Pkg);
+ }
+ return pkgCache::VerIterator(*Pkg.Cache());
+}
+ /*}}}*/
+// Policy::GetPriority - Get the priority of the package pin /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
+{
+ if (Pins[Pkg->ID].Type != pkgVersionMatch::None)
+ {
+ // In this case 0 means default priority
+ if (Pins[Pkg->ID].Priority == 0)
+ return 989;
+ return Pins[Pkg->ID].Priority;
+ }
+
+ return 0;
+}
+ /*}}}*/
// ReadPinFile - Load the pin file into a Policy /*{{{*/
// ---------------------------------------------------------------------
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: policy.h,v 1.2 2001/02/20 07:03:17 jgg Exp $
+// $Id: policy.h,v 1.3 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Package Version Policy implementation
public:
+ // Things for manipulating pins
void CreatePin(pkgVersionMatch::MatchType Type,string Pkg,
string Data,signed short Priority);
-
+ inline signed short GetPriority(pkgCache::PkgFileIterator const &File)
+ {return PFPriority[File->ID];};
+ signed short GetPriority(pkgCache::PkgIterator const &Pkg);
+ pkgCache::VerIterator GetMatch(pkgCache::PkgIterator Pkg);
+
+ // Things for the cache interface.
virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg);
virtual bool IsImportantDep(pkgCache::DepIterator Dep) {return pkgDepCache::Policy::IsImportantDep(Dep);};
bool InitDefaults();
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: versionmatch.cc,v 1.2 2001/02/20 07:03:17 jgg Exp $
+// $Id: versionmatch.cc,v 1.3 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
Version Matching
if (Type == Release)
{
/* cout << RelVerStr << ',' << RelOrigin << ',' << RelArchive << ',' << RelLabel << endl;
- cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl;
-*/
+ cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl;*/
+
if (RelVerStr.empty() == true && RelOrigin.empty() == true &&
RelArchive.empty() == true && RelLabel.empty() == true &&
RelComponent.empty() == true)
return false;
if (RelComponent.empty() == false)
if (File->Component == 0 ||
- stringcasecmp(RelLabel,File.Component()) != 0)
+ stringcasecmp(RelComponent,File.Component()) != 0)
return false;
return true;
}
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.46 2001/03/07 04:25:35 jgg Exp $
+// $Id: apt-cache.cc,v 1.47 2001/04/29 05:13:51 jgg Exp $
/* ######################################################################
apt-cache - Manages the cache files
/*}}}*/
pkgCache *GCache = 0;
+pkgSourceList *SrcList = 0;
// LocalitySort - Sort a version list by package file locality /*{{{*/
// ---------------------------------------------------------------------
while ((Parse = SrcRecs.Find(*I,false)) != 0)
cout << Parse->AsStr() << endl;;
}
+ return true;
+}
+ /*}}}*/
+// Policy - Show the results of the preferences file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool Policy(CommandLine &CmdL)
+{
+ if (SrcList == 0)
+ return _error->Error("Generate must be enabled for this function");
+
+ pkgCache &Cache = *GCache;
+ pkgPolicy Plcy(&Cache);
+ if (ReadPinFile(Plcy) == false)
+ return false;
+
+ // Print out all of the package files
+ if (CmdL.FileList[1] == 0)
+ {
+ cout << _("Package Files:") << endl;
+ for (pkgCache::PkgFileIterator F = Cache.FileBegin(); F.end() == false; F++)
+ {
+ // Locate the associated index files so we can derive a description
+ pkgIndexFile *Indx;
+ if (SrcList->FindIndex(F,Indx) == false &&
+ _system->FindIndex(F,Indx) == false)
+ return _error->Error(_("Cache is out of sync, can't x-ref a package file"));
+ printf(_("%4i %s\n"),
+ Plcy.GetPriority(F),Indx->Describe(true).c_str());
+
+ // Print the reference information for the package
+ string Str = F.RelStr();
+ if (Str.empty() == false)
+ printf(" release %s\n",F.RelStr().c_str());
+ if (F.Site() != 0 && F.Site()[0] != 0)
+ printf(" origin %s\n",F.Site());
+ }
+
+ // Show any packages have explicit pins
+ cout << _("Pinned Packages:") << endl;
+ pkgCache::PkgIterator I = Cache.PkgBegin();
+ for (;I.end() != true; I++)
+ {
+ if (Plcy.GetPriority(I) == 0)
+ continue;
+
+ // Print the package name and the version we are forcing to
+ cout << " " << I.Name() << " -> ";
+
+ pkgCache::VerIterator V = Plcy.GetMatch(I);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+ }
+
+ return true;
+ }
+
+ // Print out detailed information for each package
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ {
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
+ if (Pkg.end() == true)
+ {
+ _error->Warning(_("Unable to locate package %s"),*I);
+ continue;
+ }
+
+ cout << Pkg.Name() << ":" << endl;
+
+ // Installed version
+ cout << _(" Installed: ");
+ if (Pkg->CurrentVer == 0)
+ cout << _("(none)") << endl;
+ else
+ cout << Pkg.CurrentVer().VerStr() << endl;
+
+ // Candidate Version
+ cout << _(" Candidate: ");
+ pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
+ if (V.end() == true)
+ cout << _("(none)") << endl;
+ else
+ cout << V.VerStr() << endl;
+
+ // Pinned version
+ if (Plcy.GetPriority(Pkg) != 0)
+ {
+ cout << _(" Package Pin: ");
+ V = Plcy.GetMatch(Pkg);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+ }
+
+ // Show the priority tables
+ cout << _(" Version Table:") << endl;
+ for (V = Pkg.VersionList(); V.end() == false; V++)
+ {
+ if (Pkg.CurrentVer() == V)
+ cout << " *** " << V.VerStr();
+ else
+ cout << " " << V.VerStr();
+ cout << " " << Plcy.GetPriority(Pkg) << endl;
+ for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+ {
+ // Locate the associated index files so we can derive a description
+ pkgIndexFile *Indx;
+ if (SrcList->FindIndex(VF.File(),Indx) == false &&
+ _system->FindIndex(VF.File(),Indx) == false)
+ return _error->Error(_("Cache is out of sync, can't x-ref a package file"));
+ printf(_(" %4i %s\n"),Plcy.GetPriority(VF.File()),
+ Indx->Describe(true).c_str());
+ }
+ }
+ }
+
return true;
}
/*}}}*/
{"dotty",&Dotty},
{"show",&ShowPackage},
{"pkgnames",&ShowPkgNames},
+ {"policy",&Policy},
{0,0}};
CacheInitialize();
else
{
// Open the cache file
- pkgSourceList List;
- List.ReadMainList();
+ SrcList = new pkgSourceList;
+ SrcList->ReadMainList();
// Generate it and map it
OpProgress Prog;
- pkgMakeStatusCache(List,Prog,&Map,true);
+ pkgMakeStatusCache(*SrcList,Prog,&Map,true);
}
if (_error->PendingError() == false)
* French man pages from philippe batailler - well sort of. They
don't build yet..
* run-parts. Closes: #94286
+ * 'apt-cache policy' preferences debug tool.
-- Jason Gunthorpe <jgg@debian.org> Thu, 8 Mar 2001 22:48:06 -0700
<arg>depends <arg choice="plain" rep="repeat"><replaceable>pkg</replaceable></arg></arg>
<arg>pkgnames <arg choice="plain"><replaceable>prefix</replaceable></arg></arg>
<arg>dotty <arg choice="plain" rep="repeat"><replaceable>pkg</replaceable></arg></arg>
+ <arg>policy <arg choice="plain" rep="repeat"><replaceable>pkgs</replaceable></arg></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<para>
Caution, dotty cannot graph larger sets of packages.
+
+ <VarListEntry><Term>policy</Term>
+ <ListItem><Para>
+ <literal/policy/ is ment to help debug issues relating to the
+ preferences file. With no arguments it will print out the
+ priorities of each source. Otherwise it prints out detailed information
+ about the priority selection of the named package.
</VarListEntry>
</VariableList>
</RefSect1>