Bug#152129: apt: Patch for the source package version selection by release
The patch attached,
Toni
--
Toni Timonen "toni dot timonen at iki dot fi"
NP Solutions Ltd
Helsinki University of Technology
Department of Engineering Physics and Mathematics
diff -rub apt-0.5.9/apt-pkg/cacheiterators.h ../apt-0.5.9/apt-pkg/cacheiterators.h
--- apt-0.5.9/apt-pkg/cacheiterators.h 2001-04-29 08:13:51.000000000 +0300
+++ ../apt-0.5.9/apt-pkg/cacheiterators.h 2003-08-25 06:35:32.000000000 +0300
@@ -259,8 +259,20 @@
};
};
+class pkgReleaseInfo
+{
+ public:
+ virtual const char *Archive() const=0;
+ virtual const char *Component() const=0;
+ virtual const char *Version() const=0;
+ virtual const char *Origin() const=0;
+ virtual const char *Label() const=0;
+ virtual const char *Architecture() const=0;
+};
+
+
// Package file
-class pkgCache::PkgFileIterator
+class pkgCache::PkgFileIterator : public pkgReleaseInfo
{
pkgCache *Owner;
PackageFile *File;
diff -rub apt-0.5.9/apt-pkg/deb/debindexfile.cc ../apt-0.5.9/apt-pkg/deb/debindexfile.cc
--- apt-0.5.9/apt-pkg/deb/debindexfile.cc 2001-04-29 08:13:51.000000000 +0300
+++ ../apt-0.5.9/apt-pkg/deb/debindexfile.cc 2003-08-25 06:54:01.000000000 +0300
@@ -27,11 +27,50 @@
#include <sys/stat.h>
/*}}}*/
+// debpkgReleaseInfo - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+debpkgReleaseInfo::debpkgReleaseInfo(string FileName) :
+ ok(false), fileName(FileName)
+{
+ if (FileExists(fileName) == false)
+ return;
+ FileFd Rel(fileName,FileFd::ReadOnly);
+ if (_error->PendingError())
+ return;
+
+ pkgTagFile Tags(&Rel);
+ pkgTagSection Section;
+ if (Tags.Step(Section) == false)
+ return;
+
+ const char *Start;
+ const char *Stop;
+ if (Section.Find("Archive",Start,Stop))
+ archive=string(Start,Stop);
+ if (Section.Find("Component",Start,Stop))
+ component=string(Start,Stop);
+ if (Section.Find("Version",Start,Stop))
+ version=string(Start,Stop);
+ if (Section.Find("Origin",Start,Stop))
+ origin=string(Start,Stop);
+ if (Section.Find("Label",Start,Stop))
+ label=string(Start,Stop);
+ if (Section.Find("Architecture",Start,Stop))
+ architecture=string(Start,Stop);
+
+ if(_error->PendingError())
+ return;
+
+ ok=true;
+
+}
+ /*}}}*/
// SourcesIndex::debSourcesIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section) :
- URI(URI), Dist(Dist), Section(Section)
+ URI(URI), Dist(Dist), Section(Section), releaseInfo(IndexFile("Release"))
{
}
/*}}}*/
@@ -109,7 +148,7 @@
/* */
inline string debSourcesIndex::IndexFile(const char *Type) const
{
- return URItoFileName(IndexURI(Type));
+ return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
}
string debSourcesIndex::IndexURI(const char *Type) const
{
diff -rub apt-0.5.9/apt-pkg/deb/debindexfile.h ../apt-0.5.9/apt-pkg/deb/debindexfile.h
--- apt-0.5.9/apt-pkg/deb/debindexfile.h 2001-04-29 08:13:51.000000000 +0300
+++ ../apt-0.5.9/apt-pkg/deb/debindexfile.h 2003-08-25 06:50:04.000000000 +0300
@@ -22,6 +22,31 @@
#include <apt-pkg/indexfile.h>
+class debpkgReleaseInfo : public pkgReleaseInfo
+{
+ bool ok;
+ string fileName;
+
+ string archive;
+ string component;
+ string version;
+ string origin;
+ string label;
+ string architecture;
+
+ public:
+ // virtual const char *FileName() const=0;
+ const char *Archive() const { return ok?archive.c_str():0; };
+ const char *Component() const { return ok?component.c_str():0; };
+ const char *Version() const { return ok?version.c_str():0; }
+ const char *Origin() const { return ok?origin.c_str():0; };
+ const char *Label() const { return ok?label.c_str():0; }
+ const char *Architecture() const { return ok?architecture.c_str():0; }
+ // virtual const char *Site() const=0;
+ debpkgReleaseInfo(string FileName);
+
+};
+
class debStatusIndex : public pkgIndexFile
{
string File;
@@ -81,6 +106,8 @@
string Dist;
string Section;
+ const debpkgReleaseInfo releaseInfo;
+
string Info(const char *Type) const;
string IndexFile(const char *Type) const;
string IndexURI(const char *Type) const;
@@ -100,6 +127,7 @@
// Interface for the record parsers
virtual pkgSrcRecords::Parser *CreateSrcParser() const;
+ inline const pkgReleaseInfo *ReleaseInfo() const { return &releaseInfo; }
// Interface for the Cache Generator
virtual bool Exists() const;
diff -rub apt-0.5.9/apt-pkg/indexfile.h ../apt-0.5.9/apt-pkg/indexfile.h
--- apt-0.5.9/apt-pkg/indexfile.h 2002-08-11 23:48:56.000000000 +0300
+++ ../apt-0.5.9/apt-pkg/indexfile.h 2003-08-25 05:47:31.000000000 +0300
@@ -68,6 +68,7 @@
// Interface for the record parsers
virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
+ virtual const pkgReleaseInfo* ReleaseInfo() const { return 0; };
// Interface for the Cache Generator
virtual bool Exists() const = 0;
diff -rub apt-0.5.9/cmdline/apt-get.cc ../apt-0.5.9/cmdline/apt-get.cc
--- apt-0.5.9/cmdline/apt-get.cc 2003-08-09 06:07:03.000000000 +0300
+++ ../apt-0.5.9/cmdline/apt-get.cc 2003-08-25 07:02:14.000000000 +0300
@@ -1141,6 +1141,12 @@
string VerTag;
string TmpSrc = Name;
string::size_type Slash = TmpSrc.rfind('=');
+ bool VerIsRel = false;
+ if (Slash == string::npos)
+ {
+ Slash = TmpSrc.rfind('/');
+ VerIsRel = true;
+ }
if (Slash != string::npos)
{
VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end());
@@ -1197,8 +1203,14 @@
{
/* Don't want to fall through because we are doing exact version
matching. */
+ if(VerIsRel == false) {
if (Cache.VS().CmpVersion(VerTag,Ver) != 0)
continue;
+ } else {
+ if(Parse->Index().ReleaseInfo() == false) continue;
+ if(Parse->Index().ReleaseInfo()->Archive() == false) continue;
+ if(stringcasecmp(VerTag,Parse->Index().ReleaseInfo()->Archive()) !=0 ) continue;
+ }
Last = Parse;
Offset = Parse->Offset();
Reply to: