summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:57:45 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:57:45 +0000
commitaf87ab54430b31a0e1840b2c1673c07d74813447 (patch)
tree9f2143bc188495cf84c64c2c54cc9b60e1738bed /apt-pkg
parent70d73d7e0c05939443131ed815fabcd0b087483d (diff)
'apt-cache policy' preferences debug tool.
Author: jgg Date: 2001-04-29 05:13:51 GMT 'apt-cache policy' preferences debug tool.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheiterators.h5
-rw-r--r--apt-pkg/deb/debindexfile.cc21
-rw-r--r--apt-pkg/deb/debindexfile.h8
-rw-r--r--apt-pkg/deb/debsystem.cc31
-rw-r--r--apt-pkg/deb/debsystem.h8
-rw-r--r--apt-pkg/indexfile.h4
-rw-r--r--apt-pkg/pkgcache.cc21
-rw-r--r--apt-pkg/pkgsystem.h4
-rw-r--r--apt-pkg/policy.cc50
-rw-r--r--apt-pkg/policy.h10
-rw-r--r--apt-pkg/versionmatch.cc8
11 files changed, 127 insertions, 43 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index e346f49b7..cb8e0cd94 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -297,7 +297,8 @@ class pkgCache::PkgFileIterator
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) {};
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 2cc1de8a1..38316d17e 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -1,6 +1,6 @@
// -*- 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
@@ -74,11 +74,15 @@ pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
// 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;
}
/*}}}*/
@@ -188,11 +192,14 @@ string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
// ---------------------------------------------------------------------
/* 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;
}
/*}}}*/
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index b4dee3c22..9bce4da83 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -31,7 +31,7 @@ class debStatusIndex : public pkgIndexFile
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;
@@ -62,7 +62,7 @@ class debPackagesIndex : public pkgIndexFile
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
@@ -95,7 +95,7 @@ class debSourcesIndex : public pkgIndexFile
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
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 0abd4c8aa..5a4cbe654 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -1,6 +1,6 @@
// -*- 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.
@@ -42,6 +42,14 @@ debSystem::debSystem()
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
@@ -191,7 +199,26 @@ signed debSystem::Score(Configuration const &Cnf)
/* */
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;
+}
+ /*}}}*/
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 4fd267f77..c4e27ced3 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -16,6 +16,7 @@
#include <apt-pkg/pkgsystem.h>
+class debStatusIndex;
class debSystem : public pkgSystem
{
// For locking support
@@ -23,6 +24,8 @@ class debSystem : public pkgSystem
unsigned LockCount;
bool CheckUpdates();
+ debStatusIndex *StatusFile;
+
public:
virtual bool Lock();
@@ -32,8 +35,11 @@ class debSystem : public pkgSystem
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;
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index 06e5a7f35..beae1e7d8 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -1,6 +1,6 @@
// -*- 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.
@@ -58,7 +58,7 @@ class pkgIndexFile
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();};
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index ea5c264dc..fa231ef37 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -1,6 +1,6 @@
// -*- 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
@@ -578,3 +578,22 @@ bool pkgCache::PkgFileIterator::IsOk()
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;
+}
+ /*}}}*/
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index 0f0a11808..c6b34fd61 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -1,6 +1,6 @@
// -*- 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.
@@ -80,6 +80,8 @@ class pkgSystem
// 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.. */
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index da72f193a..cde0920e6 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -1,6 +1,6 @@
// -*- 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
@@ -83,10 +83,6 @@ bool pkgPolicy::InitDefaults()
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)
@@ -118,19 +114,9 @@ bool pkgPolicy::InitDefaults()
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
@@ -222,6 +208,36 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
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 /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index f89916202..149782b25 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -1,6 +1,6 @@
// -*- 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
@@ -67,9 +67,15 @@ class pkgPolicy : public pkgDepCache::Policy
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();
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc
index 45cdb117e..194df9ebc 100644
--- a/apt-pkg/versionmatch.cc
+++ b/apt-pkg/versionmatch.cc
@@ -1,6 +1,6 @@
// -*- 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
@@ -164,8 +164,8 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
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)
@@ -191,7 +191,7 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
return false;
if (RelComponent.empty() == false)
if (File->Component == 0 ||
- stringcasecmp(RelLabel,File.Component()) != 0)
+ stringcasecmp(RelComponent,File.Component()) != 0)
return false;
return true;
}