summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/deblistparser.cc21
-rw-r--r--apt-pkg/deb/deblistparser.h3
-rw-r--r--apt-pkg/pkgcache.cc4
-rw-r--r--apt-pkg/pkgcachegen.cc14
-rw-r--r--apt-pkg/pkgcachegen.h9
5 files changed, 47 insertions, 4 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 18b8b931d..a1bcfb710 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -938,3 +938,24 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
+ pkgCache::VerIterator const &Ver)
+{
+ if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false)
+ return false;
+ // status file has no (Download)Size, but all others are fair game
+ // status file is parsed last, so the first version we encounter is
+ // probably also the version we have downloaded
+ unsigned long long const Size = Section.FindULL("Size");
+ if (Size != 0 && Size != Ver->Size)
+ return false;
+ // available everywhere, but easier to check here than to include in VersionHash
+ unsigned char MultiArch = ParseMultiArch(false);
+ if (MultiArch != Ver->MultiArch)
+ return false;
+ // for all practical proposes (we can check): same version
+ return true;
+}
+ /*}}}*/
+#endif
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 03733ae8c..286244cc9 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -70,6 +70,9 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual std::string DescriptionLanguage();
virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
+#endif
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver);
virtual unsigned long Offset() {return iOffset;};
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index a19b9571c..91b75f52e 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -55,7 +55,11 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
MajorVersion = 8;
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ MinorVersion = 2;
+#else
MinorVersion = 1;
+#endif
Dirty = false;
HeaderSz = sizeof(pkgCache::Header);
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 525f1dfb4..810f0b022 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -356,7 +356,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
map_ptrloc *LastVer = &Pkg->VersionList;
void const * oldMap = Map.Data();
- unsigned long const Hash = List.VersionHash();
+ unsigned short const Hash = List.VersionHash();
if (Ver.end() == false)
{
/* We know the list is sorted so we use that fact in the search.
@@ -369,7 +369,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
if (Res > 0)
break;
// Versionstrings are equal - is hash also equal?
- if (Res == 0 && Ver->Hash == Hash)
+ if (Res == 0 && List.SameVersion(Hash, Ver) == true)
break;
// proceed with the next till we have either the right
// or we found another version (which will be lower)
@@ -558,12 +558,12 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
if (Counter % 100 == 0 && Progress != 0)
Progress->Progress(List.Offset());
- unsigned long Hash = List.VersionHash();
+ unsigned short Hash = List.VersionHash();
pkgCache::VerIterator Ver = Pkg.VersionList();
Dynamic<pkgCache::VerIterator> DynVer(Ver);
for (; Ver.end() == false; ++Ver)
{
- if (Ver->Hash == Hash && Version == Ver.VerStr())
+ if (List.SameVersion(Hash, Ver) == true && Version == Ver.VerStr())
{
if (List.CollectFileProvides(Cache,Ver) == false)
return _error->Error(_("Error occurred while processing %s (%s%d)"),
@@ -1051,6 +1051,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
return true;
}
/*}}}*/
+bool pkgCacheGenerator::ListParser::SameVersion(unsigned short const Hash,/*{{{*/
+ pkgCache::VerIterator const &Ver)
+{
+ return Hash == Ver->Hash;
+}
+ /*}}}*/
// CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/
// ---------------------------------------------------------------------
/* This is used to select which file is to be associated with all newly
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 898b34358..5994dab9f 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -164,6 +164,15 @@ class pkgCacheGenerator::ListParser
virtual std::string DescriptionLanguage() = 0;
virtual MD5SumValue Description_md5() = 0;
virtual unsigned short VersionHash() = 0;
+ /** compare currently parsed version with given version
+ *
+ * \param Hash of the currently parsed version
+ * \param Ver to compare with
+ */
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual
+#endif
+ APT_PURE bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver) = 0;
virtual unsigned long Offset() = 0;