summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc77
-rw-r--r--apt-pkg/deb/debindexfile.h16
-rw-r--r--apt-pkg/deb/deblistparser.cc6
-rw-r--r--apt-pkg/deb/debmetaindex.cc269
-rw-r--r--apt-pkg/deb/debmetaindex.h48
5 files changed, 335 insertions, 81 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index e9c7b0638..f26265fff 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.6 2004/01/04 07:41:30 mdz Exp $
+// $Id: debindexfile.cc,v 1.5.2.3 2004/01/04 19:11:00 mdz Exp $
/* ######################################################################
Debian Specific sources.list types and the three sorts of Debian
@@ -23,6 +23,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/debmetaindex.h>
#include <sys/stat.h>
/*}}}*/
@@ -30,8 +31,8 @@
// SourcesIndex::debSourcesIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section) :
- URI(URI), Dist(Dist), Section(Section)
+debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trusted) :
+ pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
{
}
/*}}}*/
@@ -129,16 +130,6 @@ string debSourcesIndex::IndexURI(const char *Type) const
return Res;
}
/*}}}*/
-// SourcesIndex::GetIndexes - Fetch the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debSourcesIndex::GetIndexes(pkgAcquire *Owner) const
-{
- new pkgAcqIndex(Owner,IndexURI("Sources"),Info("Sources"),"Sources");
- new pkgAcqIndexRel(Owner,IndexURI("Release"),Info("Release"),"Release");
- return true;
-}
- /*}}}*/
// SourcesIndex::Exists - Check if the index is available /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -162,8 +153,8 @@ unsigned long debSourcesIndex::Size() const
// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debPackagesIndex::debPackagesIndex(string URI,string Dist,string Section) :
- URI(URI), Dist(Dist), Section(Section)
+debPackagesIndex::debPackagesIndex(string URI,string Dist,string Section,bool Trusted) :
+ pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
{
}
/*}}}*/
@@ -246,16 +237,6 @@ string debPackagesIndex::IndexURI(const char *Type) const
return Res;
}
/*}}}*/
-// PackagesIndex::GetIndexes - Fetch the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debPackagesIndex::GetIndexes(pkgAcquire *Owner) const
-{
- new pkgAcqIndex(Owner,IndexURI("Packages"),Info("Packages"),"Packages");
- new pkgAcqIndexRel(Owner,IndexURI("Release"),Info("Release"),"Release");
- return true;
-}
- /*}}}*/
// PackagesIndex::Exists - Check if the index is available /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -303,7 +284,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
return _error->Error("Problem with MergeList %s",PackageFile.c_str());
// Check the release file
- string ReleaseFile = IndexFile("Release");
+ string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
if (FileExists(ReleaseFile) == true)
{
FileFd Rel(ReleaseFile,FileFd::ReadOnly);
@@ -342,7 +323,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
// StatusIndex::debStatusIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debStatusIndex::debStatusIndex(string File) : File(File)
+debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), File(File)
{
}
/*}}}*/
@@ -418,48 +399,6 @@ bool debStatusIndex::Exists() const
}
/*}}}*/
-// Source List types for Debian /*{{{*/
-class debSLTypeDeb : public pkgSourceList::Type
-{
- public:
-
- bool CreateItem(vector<pkgIndexFile *> &List,string URI,
- string Dist,string Section,
- pkgSourceList::Vendor const *Vendor) const
- {
- List.push_back(new debPackagesIndex(URI,Dist,Section));
- return true;
- };
-
- debSLTypeDeb()
- {
- Name = "deb";
- Label = "Standard Debian binary tree";
- }
-};
-
-class debSLTypeDebSrc : public pkgSourceList::Type
-{
- public:
-
- bool CreateItem(vector<pkgIndexFile *> &List,string URI,
- string Dist,string Section,
- pkgSourceList::Vendor const *Vendor) const
- {
- List.push_back(new debSourcesIndex(URI,Dist,Section));
- return true;
- };
-
- debSLTypeDebSrc()
- {
- Name = "deb-src";
- Label = "Standard Debian source tree";
- }
-};
-
-debSLTypeDeb _apt_DebType;
-debSLTypeDebSrc _apt_DebSrcType;
- /*}}}*/
// Index File types for Debian /*{{{*/
class debIFTypeSrc : public pkgIndexFile::Type
{
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 9bce4da83..a1b9583a4 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.3 2001/04/29 05:13:51 jgg Exp $
+// $Id: debindexfile.h,v 1.3.2.1 2003/12/24 23:09:17 mdz Exp $
/* ######################################################################
Debian Index Files
@@ -48,10 +48,10 @@ class debPackagesIndex : public pkgIndexFile
string URI;
string Dist;
string Section;
-
+
string Info(const char *Type) const;
string IndexFile(const char *Type) const;
- string IndexURI(const char *Type) const;
+ string IndexURI(const char *Type) const;
public:
@@ -63,7 +63,6 @@ class debPackagesIndex : public pkgIndexFile
// Interface for acquire
virtual string Describe(bool Short) const;
- virtual bool GetIndexes(pkgAcquire *Owner) const;
// Interface for the Cache Generator
virtual bool Exists() const;
@@ -71,8 +70,8 @@ class debPackagesIndex : public pkgIndexFile
virtual unsigned long Size() const;
virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
-
- debPackagesIndex(string URI,string Dist,string Section);
+
+ debPackagesIndex(string URI,string Dist,string Section,bool Trusted);
};
class debSourcesIndex : public pkgIndexFile
@@ -83,7 +82,7 @@ class debSourcesIndex : public pkgIndexFile
string Info(const char *Type) const;
string IndexFile(const char *Type) const;
- string IndexURI(const char *Type) const;
+ string IndexURI(const char *Type) const;
public:
@@ -96,7 +95,6 @@ class debSourcesIndex : public pkgIndexFile
// Interface for acquire
virtual string Describe(bool Short) const;
- virtual bool GetIndexes(pkgAcquire *Owner) const;
// Interface for the record parsers
virtual pkgSrcRecords::Parser *CreateSrcParser() const;
@@ -106,7 +104,7 @@ class debSourcesIndex : public pkgIndexFile
virtual bool HasPackages() const {return false;};
virtual unsigned long Size() const;
- debSourcesIndex(string URI,string Dist,string Section);
+ debSourcesIndex(string URI,string Dist,string Section,bool Trusted);
};
#endif
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index cf81690e2..96a80582d 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.cc,v 1.29 2003/09/22 04:16:26 mdz Exp $
+// $Id: deblistparser.cc,v 1.29.2.5 2004/01/06 01:43:44 mdz Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -566,14 +566,14 @@ bool debListParser::Step()
bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
FileFd &File)
{
- pkgTagFile Tags(&File);
+ pkgTagFile Tags(&File, File.Size() + 256); // XXX
pkgTagSection Section;
if (Tags.Step(Section) == false)
return false;
const char *Start;
const char *Stop;
- if (Section.Find("Archive",Start,Stop) == true)
+ if (Section.Find("Suite",Start,Stop) == true)
FileI->Archive = WriteUniqString(Start,Stop - Start);
if (Section.Find("Component",Start,Stop) == true)
FileI->Component = WriteUniqString(Start,Stop - Start);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
new file mode 100644
index 000000000..526c8c0b2
--- /dev/null
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -0,0 +1,269 @@
+// ijones, walters
+
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/debmetaindex.h"
+#endif
+
+#include <apt-pkg/debmetaindex.h>
+#include <apt-pkg/debindexfile.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+
+using namespace std;
+
+string debReleaseIndex::Info(const char *Type, const string Section) const
+{
+ string Info = ::URI::SiteOnly(URI) + ' ';
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ if (Dist != "/")
+ Info += Dist;
+ }
+ else
+ Info += Dist + '/' + Section;
+ Info += " ";
+ Info += Type;
+ return Info;
+}
+
+string debReleaseIndex::MetaIndexInfo(const char *Type) const
+{
+ string Info = ::URI::SiteOnly(URI) + ' ';
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ if (Dist != "/")
+ Info += Dist;
+ }
+ else
+ Info += Dist;
+ Info += " ";
+ Info += Type;
+ return Info;
+}
+
+string debReleaseIndex::MetaIndexFile(const char *Type) const
+{
+ return _config->FindDir("Dir::State::lists") +
+ URItoFileName(MetaIndexURI(Type));
+}
+
+string debReleaseIndex::MetaIndexURI(const char *Type) const
+{
+ string Res;
+
+ if (Dist == "/")
+ Res = URI;
+ else if (Dist[Dist.size()-1] == '/')
+ Res = URI + Dist;
+ else
+ Res = URI + "dists/" + Dist + "/";
+
+ Res += Type;
+ return Res;
+}
+
+string debReleaseIndex::IndexURISuffix(const char *Type, const string Section) const
+{
+ string Res ="";
+ if (Dist[Dist.size() - 1] != '/')
+ Res += Section + "/binary-" + _config->Find("APT::Architecture") + '/';
+ return Res + Type;
+}
+
+
+string debReleaseIndex::IndexURI(const char *Type, const string Section) const
+{
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ string Res;
+ if (Dist != "/")
+ Res = URI + Dist;
+ else
+ Res = URI;
+ return Res + Type;
+ }
+ else
+ return URI + "dists/" + Dist + '/' + IndexURISuffix(Type, Section);
+ }
+
+string debReleaseIndex::SourceIndexURISuffix(const char *Type, const string Section) const
+{
+ string Res ="";
+ if (Dist[Dist.size() - 1] != '/')
+ Res += Section + "/source/";
+ return Res + Type;
+}
+
+string debReleaseIndex::SourceIndexURI(const char *Type, const string Section) const
+{
+ string Res;
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ if (Dist != "/")
+ Res = URI + Dist;
+ else
+ Res = URI;
+ return Res + Type;
+ }
+ else
+ return URI + "dists/" + Dist + "/" + SourceIndexURISuffix(Type, Section);
+}
+
+debReleaseIndex::debReleaseIndex(string URI,string Dist)
+{
+ this->URI = URI;
+ this->Dist = Dist;
+ this->Indexes = NULL;
+ this->Type = "deb";
+}
+
+vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
+{
+ vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
+ for (vector <const debSectionEntry *>::const_iterator I = SectionEntries.begin();
+ I != SectionEntries.end();
+ I++)
+ {
+ IndexTarget * Target = new IndexTarget();
+ Target->ShortDesc = (*I)->IsSrc ? "Sources" : "Packages";
+ Target->MetaKey
+ = (*I)->IsSrc ? SourceIndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section)
+ : IndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section);
+ Target->URI
+ = (*I)->IsSrc ? SourceIndexURI(Target->ShortDesc.c_str(), (*I)->Section)
+ : IndexURI(Target->ShortDesc.c_str(), (*I)->Section);
+
+ Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section);
+ IndexTargets->push_back (Target);
+ }
+ return IndexTargets;
+}
+ /*}}}*/
+bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
+{
+ // special case for --print-uris
+ if (GetAll) {
+ vector <struct IndexTarget *> *targets = ComputeIndexTargets();
+ for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); Target++) {
+ new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
+ (*Target)->ShortDesc, "");
+ }
+ }
+ new pkgAcqMetaSig(Owner, MetaIndexURI("Release.gpg"),
+ MetaIndexInfo("Release.gpg"), "Release.gpg",
+ MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
+ ComputeIndexTargets(),
+ new indexRecords (Dist));
+
+ return true;
+}
+
+bool debReleaseIndex::IsTrusted() const
+{
+ string VerifiedSigFile = _config->FindDir("Dir::State::lists") +
+ URItoFileName(MetaIndexURI("Release")) + ".gpg";
+
+ if (FileExists(VerifiedSigFile))
+ return true;
+ return false;
+}
+
+vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
+{
+ if (Indexes != NULL)
+ return Indexes;
+
+ Indexes = new vector <pkgIndexFile*>;
+ for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
+ I != SectionEntries.end(); I++)
+ if ((*I)->IsSrc)
+ Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
+ else
+ Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
+ return Indexes;
+}
+
+void debReleaseIndex::PushSectionEntry(const debSectionEntry *Entry)
+{
+ SectionEntries.push_back(Entry);
+}
+
+debReleaseIndex::debSectionEntry::debSectionEntry (string Section, bool IsSrc): Section(Section)
+{
+ this->IsSrc = IsSrc;
+}
+
+class debSLTypeDebian : public pkgSourceList::Type
+{
+ protected:
+
+ bool CreateItemInternal(vector<metaIndex *> &List,string URI,
+ string Dist,string Section,
+ bool IsSrc) const
+ {
+ for (vector<metaIndex *>::const_iterator I = List.begin();
+ I != List.end(); I++)
+ {
+ // This check insures that there will be only one Release file
+ // queued for all the Packages files and Sources files it
+ // corresponds to.
+ if ((*I)->GetType() == "deb")
+ {
+ debReleaseIndex *Deb = (debReleaseIndex *) (*I);
+ // This check insures that there will be only one Release file
+ // queued for all the Packages files and Sources files it
+ // corresponds to.
+ if (Deb->GetURI() == URI && Deb->GetDist() == Dist)
+ {
+ Deb->PushSectionEntry(new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ return true;
+ }
+ }
+ }
+ // No currently created Release file indexes this entry, so we create a new one.
+ // XXX determine whether this release is trusted or not
+ debReleaseIndex *Deb = new debReleaseIndex(URI,Dist);
+ Deb->PushSectionEntry (new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ List.push_back(Deb);
+ return true;
+ }
+};
+
+class debSLTypeDeb : public debSLTypeDebian
+{
+ public:
+
+ bool CreateItem(vector<metaIndex *> &List,string URI,
+ string Dist,string Section) const
+ {
+ return CreateItemInternal(List, URI, Dist, Section, false);
+ }
+
+ debSLTypeDeb()
+ {
+ Name = "deb";
+ Label = "Standard Debian binary tree";
+ }
+};
+
+class debSLTypeDebSrc : public debSLTypeDebian
+{
+ public:
+
+ bool CreateItem(vector<metaIndex *> &List,string URI,
+ string Dist,string Section) const
+ {
+ return CreateItemInternal(List, URI, Dist, Section, true);
+ }
+
+ debSLTypeDebSrc()
+ {
+ Name = "deb-src";
+ Label = "Standard Debian source tree";
+ }
+};
+
+debSLTypeDeb _apt_DebType;
+debSLTypeDebSrc _apt_DebSrcType;
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
new file mode 100644
index 000000000..2b9922987
--- /dev/null
+++ b/apt-pkg/deb/debmetaindex.h
@@ -0,0 +1,48 @@
+// ijones, walters
+#ifndef PKGLIB_DEBMETAINDEX_H
+#define PKGLIB_DEBMETAINDEX_H
+
+#ifdef __GNUG__
+#pragma interface "apt-pkg/debmetaindex.h"
+#endif
+
+#include <apt-pkg/metaindex.h>
+#include <apt-pkg/sourcelist.h>
+
+class debReleaseIndex : public metaIndex {
+ public:
+
+ class debSectionEntry
+ {
+ public:
+ debSectionEntry (string Section, bool IsSrc);
+ bool IsSrc;
+ string Section;
+ };
+
+ private:
+ vector <const debSectionEntry *> SectionEntries;
+
+ public:
+
+ debReleaseIndex(string URI, string Dist);
+
+ virtual string ArchiveURI(string File) const {return URI + File;};
+ virtual bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
+ vector <struct IndexTarget *>* ComputeIndexTargets() const;
+ string Info(const char *Type, const string Section) const;
+ string MetaIndexInfo(const char *Type) const;
+ string MetaIndexFile(const char *Types) const;
+ string MetaIndexURI(const char *Type) const;
+ string IndexURI(const char *Type, const string Section) const;
+ string IndexURISuffix(const char *Type, const string Section) const;
+ string SourceIndexURI(const char *Type, const string Section) const;
+ string SourceIndexURISuffix(const char *Type, const string Section) const;
+ virtual vector <pkgIndexFile *> *GetIndexFiles();
+
+ virtual bool IsTrusted() const;
+
+ void PushSectionEntry(const debSectionEntry *Entry);
+};
+
+#endif