summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
committerMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
commitb53c9cea2902572822bbbece5bac236c1bbf846e (patch)
tree6c6b0524e0971c0623ccbff71383523ee0b2a5cc /apt-pkg/deb
parent21248c0f00ee71412dbadc6ebf84011cf974346d (diff)
parent2a22cd60f04c4291ea9b9b72e15b6d2ec378b001 (diff)
Merge remote-tracking branch 'upstream/debian/experimental' into feature/srv-records
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc779
-rw-r--r--apt-pkg/deb/debindexfile.h205
-rw-r--r--apt-pkg/deb/deblistparser.cc162
-rw-r--r--apt-pkg/deb/deblistparser.h56
-rw-r--r--apt-pkg/deb/debmetaindex.cc1008
-rw-r--r--apt-pkg/deb/debmetaindex.h98
-rw-r--r--apt-pkg/deb/debrecords.cc13
-rw-r--r--apt-pkg/deb/debrecords.h41
-rw-r--r--apt-pkg/deb/debsrcrecords.cc4
-rw-r--r--apt-pkg/deb/debsrcrecords.h30
-rw-r--r--apt-pkg/deb/debsystem.cc5
-rw-r--r--apt-pkg/deb/debsystem.h18
-rw-r--r--apt-pkg/deb/debversion.cc48
-rw-r--r--apt-pkg/deb/debversion.h9
-rw-r--r--apt-pkg/deb/dpkgpm.cc27
-rw-r--r--apt-pkg/deb/dpkgpm.h14
16 files changed, 997 insertions, 1520 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index d672b4fd8..c43ee7b91 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -16,56 +16,34 @@
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debrecords.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/debmetaindex.h>
-#include <apt-pkg/gpgv.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexfile.h>
-#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
-#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/sptr.h>
#include <stdio.h>
#include <iostream>
-#include <sstream>
#include <string>
+#include <sstream>
+
#include <sys/stat.h>
/*}}}*/
-using std::string;
-
-// SourcesIndex::debSourcesIndex - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trusted) :
- pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
+// Sources Index /*{{{*/
+debSourcesIndex::debSourcesIndex(IndexTarget const &Target,bool const Trusted) :
+ pkgDebianIndexTargetFile(Target, Trusted), d(NULL)
{
}
- /*}}}*/
-// SourcesIndex::SourceInfo - Short 1 liner describing a source /*{{{*/
-// ---------------------------------------------------------------------
-/* The result looks like:
- http://foo/debian/ stable/main src 1.1.1 (dsc) */
-string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
+std::string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
pkgSrcRecords::File const &File) const
{
- string Res;
- Res = ::URI::NoUserPassword(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res += Dist;
- }
- else
- Res += Dist + '/' + Section;
-
+ // The result looks like: http://foo/debian/ stable/main src 1.1.1 (dsc)
+ std::string Res = Target.Description;
+ Res.erase(Target.Description.rfind(' '));
+
Res += " ";
Res += Record.Package();
Res += " ";
@@ -74,622 +52,111 @@ string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
Res += " (" + File.Type + ")";
return Res;
}
- /*}}}*/
-// SourcesIndex::CreateSrcParser - Get a parser for the source files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
{
- string SourcesURI = _config->FindDir("Dir::State::lists") +
- URItoFileName(IndexURI("Sources"));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p;
- p = SourcesURI + '.' + *t;
- if (FileExists(p))
- return new debSrcRecordParser(p, this);
- }
+ std::string const SourcesURI = IndexFileName();
if (FileExists(SourcesURI))
return new debSrcRecordParser(SourcesURI, this);
return NULL;
}
- /*}}}*/
-// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::Describe(bool Short) const
-{
- char S[300];
- if (Short == true)
- snprintf(S,sizeof(S),"%s",Info("Sources").c_str());
- else
- snprintf(S,sizeof(S),"%s (%s)",Info("Sources").c_str(),
- IndexFile("Sources").c_str());
-
- return S;
-}
- /*}}}*/
-// SourcesIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::Info(const char *Type) const
+bool debSourcesIndex::OpenListFile(FileFd &, std::string const &)
{
- string Info = ::URI::NoUserPassword(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- Info += Type;
- return Info;
+ return true;
}
- /*}}}*/
-// SourcesIndex::Index* - Return the URI to the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::IndexFile(const char *Type) const
+pkgCacheListParser * debSourcesIndex::CreateListParser(FileFd &)
{
- string s = URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
+ return NULL;
}
-
-string debSourcesIndex::IndexURI(const char *Type) const
+uint8_t debSourcesIndex::GetIndexFlags() const
{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/source/";
-
- Res += Type;
- return Res;
+ return 0;
}
/*}}}*/
-// SourcesIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debSourcesIndex::Exists() const
+// Packages Index /*{{{*/
+debPackagesIndex::debPackagesIndex(IndexTarget const &Target, bool const Trusted) :
+ pkgDebianIndexTargetFile(Target, Trusted), d(NULL)
{
- return FileExists(IndexFile("Sources"));
}
- /*}}}*/
-// SourcesIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned long debSourcesIndex::Size() const
+std::string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator const &Ver) const
{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
- _error->PushToStack();
-
- FileFd f(IndexFile("Sources"), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
+ std::string Res = Target.Description;
+ Res.erase(Target.Description.rfind(' '));
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
-}
- /*}}}*/
-
-// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string const &Section,
- bool const &Trusted, string const &Arch) :
- pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section), Architecture(Arch)
-{
- if (Architecture == "native")
- Architecture = _config->Find("APT::Architecture");
-}
- /*}}}*/
-// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
-// ---------------------------------------------------------------------
-/* This is a shorter version that is designed to be < 60 chars or so */
-string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
-{
- string Res = ::URI::NoUserPassword(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res += Dist;
- }
- else
- Res += Dist + '/' + Section;
-
Res += " ";
Res += Ver.ParentPkg().Name();
Res += " ";
- if (Dist[Dist.size() - 1] != '/')
+ std::string const Dist = Target.Option(IndexTarget::RELEASE);
+ if (Dist.empty() == false && Dist[Dist.size() - 1] != '/')
Res.append(Ver.Arch()).append(" ");
Res += Ver.VerStr();
return Res;
}
- /*}}}*/
-// PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This should help the user find the index in the sources.list and
- in the filesystem for problem solving */
-string debPackagesIndex::Describe(bool Short) const
-{
- char S[300];
- 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;
-}
- /*}}}*/
-// PackagesIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debPackagesIndex::Info(const char *Type) const
+uint8_t debPackagesIndex::GetIndexFlags() const
{
- string Info = ::URI::NoUserPassword(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- if (Dist[Dist.size() - 1] != '/')
- Info += Architecture + " ";
- Info += Type;
- return Info;
-}
- /*}}}*/
-// PackagesIndex::Index* - Return the URI to the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debPackagesIndex::IndexFile(const char *Type) const
-{
- string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
-}
-string debPackagesIndex::IndexURI(const char *Type) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/binary-" + Architecture + '/';
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// PackagesIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debPackagesIndex::Exists() const
-{
- return FileExists(IndexFile("Packages"));
-}
- /*}}}*/
-// PackagesIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This is really only used for progress reporting. */
-unsigned long debPackagesIndex::Size() const
-{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
- _error->PushToStack();
-
- FileFd f(IndexFile("Packages"), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
-
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
-}
- /*}}}*/
-// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
-{
- string PackageFile = IndexFile("Packages");
- FileFd Pkg(PackageFile,FileFd::ReadOnly, FileFd::Extension);
- debListParser Parser(&Pkg, Architecture);
-
- if (_error->PendingError() == true)
- return _error->Error("Problem opening %s",PackageFile.c_str());
- if (Prog != NULL)
- Prog->SubProgress(0,Info("Packages"));
- ::URI Tmp(URI);
- if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
- return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator File = Gen.GetCurFile();
- pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
- File->Size = Pkg.FileSize();
- File->mtime = Pkg.ModificationTime();
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeList %s",PackageFile.c_str());
-
- // Check the release file
- string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("InRelease");
- bool releaseExists = false;
- if (FileExists(ReleaseFile) == true)
- releaseExists = true;
- else
- ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
-
- if (releaseExists == true || FileExists(ReleaseFile) == true)
- {
- FileFd Rel;
- // Beware: The 'Release' file might be clearsigned in case the
- // signature for an 'InRelease' file couldn't be checked
- if (OpenMaybeClearSignedFile(ReleaseFile, Rel) == false)
- return false;
-
- if (_error->PendingError() == true)
- return false;
- Parser.LoadReleaseInfo(File,Rel,Section);
- }
-
- return true;
-}
- /*}}}*/
-// PackagesIndex::FindInCache - Find this index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
-{
- string FileName = IndexFile("Packages");
- pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; ++File)
- {
- if (File.FileName() == NULL || FileName != File.FileName())
- continue;
-
- struct stat St;
- if (stat(File.FileName(),&St) != 0)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
- << ") or mtime (" << St.st_mtime << " <> " << File->mtime
- << ") doesn't match for " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- return File;
- }
-
- return File;
+ return 0;
}
/*}}}*/
-
-// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debTranslationsIndex::debTranslationsIndex(std::string const &URI, std::string const &Dist,
- std::string const &Section, std::string const &Translation) :
- pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
- Language(Translation)
+// Translation-* Index /*{{{*/
+debTranslationsIndex::debTranslationsIndex(IndexTarget const &Target) :
+ pkgDebianIndexTargetFile(Target, true), d(NULL)
{}
- /*}}}*/
-// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debTranslationsIndex::IndexFile(const char *Type) const
+bool debTranslationsIndex::HasPackages() const
{
- string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
+ return Exists();
}
-string debTranslationsIndex::IndexURI(const char *Type) const
+bool debTranslationsIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/i18n/Translation-";
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This should help the user find the index in the sources.list and
- in the filesystem for problem solving */
-string debTranslationsIndex::Describe(bool Short) const
-{
- std::string S;
- if (Short == true)
- strprintf(S,"%s",Info(TranslationFile().c_str()).c_str());
- else
- strprintf(S,"%s (%s)",Info(TranslationFile().c_str()).c_str(),
- IndexFile(Language.c_str()).c_str());
- return S;
-}
- /*}}}*/
-// TranslationsIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debTranslationsIndex::Info(const char *Type) const
-{
- string Info = ::URI::NoUserPassword(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- Info += Type;
- return Info;
+ if (FileExists(FileName))
+ return pkgDebianIndexTargetFile::OpenListFile(Pkg, FileName);
+ return true;
}
- /*}}}*/
-bool debTranslationsIndex::HasPackages() const /*{{{*/
+uint8_t debTranslationsIndex::GetIndexFlags() const
{
- return FileExists(IndexFile(Language.c_str()));
+ return pkgCache::Flag::NotSource | pkgCache::Flag::NoPackages;
}
- /*}}}*/
-// TranslationsIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::Exists() const
+std::string debTranslationsIndex::GetArchitecture() const
{
- return FileExists(IndexFile(Language.c_str()));
+ return std::string();
}
- /*}}}*/
-// TranslationsIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This is really only used for progress reporting. */
-unsigned long debTranslationsIndex::Size() const
+pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
+ if (Pkg.IsOpen() == false)
+ return NULL;
_error->PushToStack();
-
- FileFd f(IndexFile(Language.c_str()), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
-
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
+ pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? NULL : Parser;
}
/*}}}*/
-// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
-{
- // Check the translation file, if in use
- string TranslationFile = IndexFile(Language.c_str());
- if (FileExists(TranslationFile))
- {
- FileFd Trans(TranslationFile,FileFd::ReadOnly, FileFd::Extension);
- debTranslationsParser TransParser(&Trans);
- if (_error->PendingError() == true)
- return false;
-
- if (Prog != NULL)
- Prog->SubProgress(0, Info(TranslationFile.c_str()));
- if (Gen.SelectFile(TranslationFile,string(),*this) == false)
- return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator TransFile = Gen.GetCurFile();
- TransFile->Size = Trans.FileSize();
- TransFile->mtime = Trans.ModificationTime();
-
- if (Gen.MergeList(TransParser) == false)
- return _error->Error("Problem with MergeList %s",TranslationFile.c_str());
- }
-
- return true;
-}
- /*}}}*/
-// TranslationsIndex::FindInCache - Find this index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
+// dpkg/status Index /*{{{*/
+debStatusIndex::debStatusIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL)
{
- string FileName = IndexFile(Language.c_str());
-
- pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; ++File)
- {
- if (FileName != File.FileName())
- continue;
-
- struct stat St;
- if (stat(File.FileName(),&St) != 0)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
- << ") or mtime (" << St.st_mtime << " <> " << File->mtime
- << ") doesn't match for " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- return File;
- }
- return File;
}
- /*}}}*/
-// StatusIndex::debStatusIndex - Constructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debStatusIndex::debStatusIndex(string File) : pkgIndexFile(true), File(File)
+std::string debStatusIndex::GetArchitecture() const
{
+ return std::string();
}
- /*}}}*/
-// StatusIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned long debStatusIndex::Size() const
-{
- struct stat S;
- if (stat(File.c_str(),&S) != 0)
- return 0;
- return S.st_size;
-}
- /*}}}*/
-// StatusIndex::Merge - Load the index file into a cache /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
-{
- FileFd Pkg(File,FileFd::ReadOnly, FileFd::Extension);
- if (_error->PendingError() == true)
- return false;
- debListParser Parser(&Pkg);
- if (_error->PendingError() == true)
- return false;
-
- if (Prog != NULL)
- Prog->SubProgress(0,File);
- if (Gen.SelectFile(File,string(),*this,pkgCache::Flag::NotSource) == false)
- return _error->Error("Problem with SelectFile %s",File.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
- CFile->Size = Pkg.FileSize();
- CFile->mtime = Pkg.ModificationTime();
- map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::MIXED, "now");
- CFile->Archive = storage;
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeList %s",File.c_str());
- return true;
-}
- /*}}}*/
-// StatusIndex::FindInCache - Find this index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
+std::string debStatusIndex::GetComponent() const
{
- pkgCache::PkgFileIterator File = Cache.FileBegin();
- for (; File.end() == false; ++File)
- {
- if (this->File != File.FileName())
- continue;
-
- struct stat St;
- if (stat(File.FileName(),&St) != 0)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
- {
- if (_config->FindB("Debug::pkgCacheGen", false))
- std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
- << ") or mtime (" << St.st_mtime << " <> " << File->mtime
- << ") doesn't match for " << File.FileName() << std::endl;
- return pkgCache::PkgFileIterator(Cache);
- }
- return File;
- }
- return File;
+ return "now";
}
- /*}}}*/
-// StatusIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-APT_CONST bool debStatusIndex::Exists() const
+uint8_t debStatusIndex::GetIndexFlags() const
{
- // Abort if the file does not exist.
- return true;
+ return pkgCache::Flag::NotSource;
}
/*}}}*/
-
-// debDebPkgFile - Single .deb file /*{{{*/
-debDebPkgFileIndex::debDebPkgFileIndex(std::string DebFile)
- : pkgIndexFile(true), DebFile(DebFile)
-{
- DebFileFullPath = flAbsPath(DebFile);
-}
-
-std::string debDebPkgFileIndex::ArchiveURI(std::string /*File*/) const
-{
- return "file:" + DebFileFullPath;
-}
-
-bool debDebPkgFileIndex::Exists() const
+// DebPkgFile Index - a single .deb file as an index /*{{{*/
+debDebPkgFileIndex::debDebPkgFileIndex(std::string const &DebFile)
+ : pkgDebianIndexRealFile(DebFile, true), d(NULL), DebFile(DebFile)
{
- return FileExists(DebFile);
}
bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &debfile)
{
+ struct stat Buf;
+ if (stat(debfile.c_str(), &Buf) != 0)
+ return false;
+
// get the control data out of the deb file via dpkg-deb -I
std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg-deb");
std::vector<const char *> Args;
@@ -716,106 +183,86 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de
ExecWait(Child, "Popen");
content << "Filename: " << debfile << "\n";
- struct stat Buf;
- if (stat(debfile.c_str(), &Buf) != 0)
- return false;
content << "Size: " << Buf.st_size << "\n";
return true;
}
-bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
+bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
{
- if(Prog)
- Prog->SubProgress(0, "Reading deb file");
-
// write the control data to a tempfile
- SPtr<FileFd> DebControl = GetTempFile("deb-file-" + flNotDir(DebFile));
- if(DebControl == NULL)
+ if (GetTempFile("deb-file-" + flNotDir(FileName), true, &Pkg) == NULL)
return false;
std::ostringstream content;
- if (GetContent(content, DebFile) == false)
+ if (GetContent(content, FileName) == false)
return false;
std::string const contentstr = content.str();
- DebControl->Write(contentstr.c_str(), contentstr.length());
- // rewind for the listparser
- DebControl->Seek(0);
-
- // and give it to the list parser
- debDebFileParser Parser(DebControl, DebFile);
- if(Gen.SelectFile(DebFile, "local", *this) == false)
- return _error->Error("Problem with SelectFile %s", DebFile.c_str());
-
- pkgCache::PkgFileIterator File = Gen.GetCurFile();
- File->Size = DebControl->Size();
- File->mtime = DebControl->ModificationTime();
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeLister for %s", DebFile.c_str());
-
+ if (contentstr.empty())
+ return true;
+ if (Pkg.Write(contentstr.c_str(), contentstr.length()) == false || Pkg.Seek(0) == false)
+ return false;
return true;
}
+pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return NULL;
+ _error->PushToStack();
+ pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? NULL : Parser;
+}
+uint8_t debDebPkgFileIndex::GetIndexFlags() const
+{
+ return pkgCache::Flag::LocalSource;
+}
+std::string debDebPkgFileIndex::GetArchitecture() const
+{
+ return std::string();
+}
+std::string debDebPkgFileIndex::GetComponent() const
+{
+ return "local-deb";
+}
pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const
{
+ std::string const FileName = IndexFileName();
pkgCache::PkgFileIterator File = Cache.FileBegin();
for (; File.end() == false; ++File)
{
- if (File.FileName() == NULL || DebFile != File.FileName())
+ if (File.FileName() == NULL || FileName != File.FileName())
continue;
-
- return File;
+ // we can't do size checks here as file size != content size
+ return File;
}
-
- return File;
-}
-unsigned long debDebPkgFileIndex::Size() const
-{
- struct stat buf;
- if(stat(DebFile.c_str(), &buf) != 0)
- return 0;
- return buf.st_size;
-}
- /*}}}*/
-// debDscFileIndex stuff
-debDscFileIndex::debDscFileIndex(std::string &DscFile)
- : pkgIndexFile(true), DscFile(DscFile)
-{
-}
-
-bool debDscFileIndex::Exists() const
-{
- return FileExists(DscFile);
+ return File;
}
-unsigned long debDscFileIndex::Size() const
+ /*}}}*/
+// DscFile Index - a single .dsc file as an index /*{{{*/
+debDscFileIndex::debDscFileIndex(std::string const &DscFile)
+ : pkgDebianIndexRealFile(DscFile, true), d(NULL)
{
- struct stat buf;
- if(stat(DscFile.c_str(), &buf) == 0)
- return buf.st_size;
- return 0;
}
-
-// DscFileIndex::CreateSrcParser - Get a parser for the .dsc file /*{{{*/
pkgSrcRecords::Parser *debDscFileIndex::CreateSrcParser() const
{
- if (!FileExists(DscFile))
+ if (Exists() == false)
return NULL;
-
- return new debDscRecordParser(DscFile,this);
+ return new debDscRecordParser(File, this);
}
/*}}}*/
+
// Index File types for Debian /*{{{*/
class APT_HIDDEN debIFTypeSrc : public pkgIndexFile::Type
{
public:
-
debIFTypeSrc() {Label = "Debian Source Index";};
};
class APT_HIDDEN debIFTypePkg : public pkgIndexFile::Type
{
public:
-
- virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE
{
return new debRecordParser(File.FileName(),*File.Cache());
};
@@ -829,8 +276,7 @@ class APT_HIDDEN debIFTypeTrans : public debIFTypePkg
class APT_HIDDEN debIFTypeStatus : public pkgIndexFile::Type
{
public:
-
- virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE
{
return new debRecordParser(File.FileName(),*File.Cache());
};
@@ -839,29 +285,29 @@ class APT_HIDDEN debIFTypeStatus : public pkgIndexFile::Type
class APT_HIDDEN debIFTypeDebPkgFile : public pkgIndexFile::Type
{
public:
- virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &File) const APT_OVERRIDE
{
return new debDebFileRecordParser(File.FileName());
};
- debIFTypeDebPkgFile() {Label = "deb Package file";};
+ debIFTypeDebPkgFile() {Label = "Debian deb file";};
};
class APT_HIDDEN debIFTypeDscFile : public pkgIndexFile::Type
{
public:
- virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string DscFile) const
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &DscFile) const APT_OVERRIDE
{
return new debDscRecordParser(DscFile, NULL);
};
- debIFTypeDscFile() {Label = "dsc File Source Index";};
+ debIFTypeDscFile() {Label = "Debian dsc file";};
};
class APT_HIDDEN debIFTypeDebianSourceDir : public pkgIndexFile::Type
{
public:
- virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string SourceDir) const
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &SourceDir) const APT_OVERRIDE
{
- return new debDscRecordParser(SourceDir + string("/debian/control"), NULL);
+ return new debDscRecordParser(SourceDir + std::string("/debian/control"), NULL);
};
- debIFTypeDebianSourceDir() {Label = "debian/control File Source Index";};
+ debIFTypeDebianSourceDir() {Label = "Debian control file";};
};
APT_HIDDEN debIFTypeSrc _apt_Src;
@@ -909,3 +355,4 @@ debTranslationsIndex::~debTranslationsIndex() {}
debSourcesIndex::~debSourcesIndex() {}
debDebPkgFileIndex::~debDebPkgFileIndex() {}
+debDscFileIndex::~debDscFileIndex() {}
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 1e5882071..dc75a01ab 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debindexfile.h,v 1.3.2.1 2003/12/24 23:09:17 mdz Exp $
/* ######################################################################
Debian Index Files
@@ -27,155 +26,105 @@ class OpProgress;
class pkgAcquire;
class pkgCacheGenerator;
-
-class APT_HIDDEN debStatusIndex : public pkgIndexFile
+class debStatusIndex : public pkgDebianIndexRealFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
+protected:
+ virtual std::string GetArchitecture() const APT_OVERRIDE;
+ virtual std::string GetComponent() const APT_OVERRIDE;
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
- protected:
- std::string File;
+public:
- public:
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
- virtual const Type *GetType() const APT_CONST;
-
- // Interface for acquire
- virtual std::string Describe(bool /*Short*/) const {return File;};
-
// Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const {return true;};
- virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
- bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const;
- virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
-
- debStatusIndex(std::string File);
+ virtual bool HasPackages() const APT_OVERRIDE {return true;};
+ // Abort if the file does not exist.
+ virtual bool Exists() const APT_OVERRIDE {return true;};
+
+ debStatusIndex(std::string const &File);
virtual ~debStatusIndex();
};
-
-class APT_HIDDEN debPackagesIndex : public pkgIndexFile
-{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- std::string URI;
- std::string Dist;
- std::string Section;
- std::string Architecture;
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
+class debPackagesIndex : public pkgDebianIndexTargetFile
+{
+ void * const d;
+protected:
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
- public:
-
- virtual const Type *GetType() const APT_CONST;
+public:
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
// Stuff for accessing files on remote items
- virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
- virtual std::string ArchiveURI(std::string File) const {return URI + File;};
-
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
-
+ virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const APT_OVERRIDE;
+
// Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const {return true;};
- virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
- virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
-
- debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
- bool const &Trusted, std::string const &Arch = "native");
+ virtual bool HasPackages() const APT_OVERRIDE {return true;};
+
+ debPackagesIndex(IndexTarget const &Target, bool const Trusted);
virtual ~debPackagesIndex();
};
-class APT_HIDDEN debTranslationsIndex : public pkgIndexFile
+class debTranslationsIndex : public pkgDebianIndexTargetFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
+protected:
+ virtual std::string GetArchitecture() const APT_OVERRIDE;
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
+ virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
+ APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
- std::string const URI;
- std::string const Dist;
- std::string const Section;
- std::string const Language;
+public:
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
-
- APT_HIDDEN std::string TranslationFile() const {return std::string("Translation-").append(Language);};
-
- public:
-
- virtual const Type *GetType() const APT_CONST;
-
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
// Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const;
- virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
- virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
+ virtual bool HasPackages() const APT_OVERRIDE;
- debTranslationsIndex(std::string const &URI,std::string const &Dist,std::string const &Section, std::string const &Language);
+ debTranslationsIndex(IndexTarget const &Target);
virtual ~debTranslationsIndex();
};
-class APT_HIDDEN debSourcesIndex : public pkgIndexFile
+class debSourcesIndex : public pkgDebianIndexTargetFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- std::string URI;
- std::string Dist;
- std::string Section;
-
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
+ void * const d;
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
+ virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
+ APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
public:
- virtual const Type *GetType() const APT_CONST;
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
// Stuff for accessing files on remote items
virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
- pkgSrcRecords::File const &File) const;
- virtual std::string ArchiveURI(std::string File) const {return URI + File;};
-
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
+ pkgSrcRecords::File const &File) const APT_OVERRIDE;
// Interface for the record parsers
- virtual pkgSrcRecords::Parser *CreateSrcParser() const;
-
+ virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
+
// Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const {return false;};
- virtual unsigned long Size() const;
-
- debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
+ virtual bool HasPackages() const APT_OVERRIDE {return false;};
+
+ debSourcesIndex(IndexTarget const &Target, bool const Trusted);
virtual ~debSourcesIndex();
};
-class APT_HIDDEN debDebPkgFileIndex : public pkgIndexFile
+class debDebPkgFileIndex : public pkgDebianIndexRealFile
{
- private:
- void *d;
+ void * const d;
std::string DebFile;
- std::string DebFileFullPath;
- public:
- virtual const Type *GetType() const APT_CONST;
+protected:
+ virtual std::string GetComponent() const APT_OVERRIDE;
+ virtual std::string GetArchitecture() const APT_OVERRIDE;
+ virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
+ virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
+ APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
- virtual std::string Describe(bool /*Short*/) const {
- return DebFile;
- }
+public:
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
/** get the control (file) content of the deb file
*
@@ -186,43 +135,31 @@ class APT_HIDDEN debDebPkgFileIndex : public pkgIndexFile
static bool GetContent(std::ostream &content, std::string const &debfile);
// Interface for the Cache Generator
- virtual bool Exists() const;
- virtual bool HasPackages() const {
- return true;
- };
- virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
- virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
+ virtual bool HasPackages() const APT_OVERRIDE {return true;}
+ virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
// Interface for acquire
- virtual std::string ArchiveURI(std::string /*File*/) const;
- debDebPkgFileIndex(std::string DebFile);
+ debDebPkgFileIndex(std::string const &DebFile);
virtual ~debDebPkgFileIndex();
};
-class APT_HIDDEN debDscFileIndex : public pkgIndexFile
+class debDscFileIndex : public pkgDebianIndexRealFile
{
- private:
- std::string DscFile;
+ void * const d;
public:
- virtual const Type *GetType() const APT_CONST;
- virtual pkgSrcRecords::Parser *CreateSrcParser() const;
- virtual bool Exists() const;
- virtual bool HasPackages() const {return false;};
- virtual unsigned long Size() const;
- virtual std::string Describe(bool /*Short*/) const {
- return DscFile;
- };
-
- debDscFileIndex(std::string &DscFile);
- virtual ~debDscFileIndex() {};
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
+ virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
+ virtual bool HasPackages() const APT_OVERRIDE {return false;};
+
+ debDscFileIndex(std::string const &DscFile);
+ virtual ~debDscFileIndex();
};
-class APT_HIDDEN debDebianSourceDirIndex : public debDscFileIndex
+class debDebianSourceDirIndex : public debDscFileIndex
{
public:
- virtual const Type *GetType() const APT_CONST;
+ virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
};
#endif
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index b80b57bc4..42eca8677 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -18,10 +18,8 @@
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/crc-16.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/mmap.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/tagfile.h>
@@ -50,12 +48,9 @@ static debListParser::WordList PrioList[] = {
/* Provide an architecture and only this one and "all" will be accepted
in Step(), if no Architecture is given we will accept every arch
we would accept in general with checkArchitecture() */
-debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File),
- Arch(Arch) {
- if (Arch == "native")
- this->Arch = _config->Find("APT::Architecture");
- Architectures = APT::Configuration::getArchitectures();
- MultiArchEnabled = Architectures.size() > 1;
+debListParser::debListParser(FileFd *File) :
+ pkgCacheListParser(), d(NULL), Tags(File)
+{
}
/*}}}*/
// ListParser::Package - Return the package name /*{{{*/
@@ -72,7 +67,8 @@ string debListParser::Package() {
// ---------------------------------------------------------------------
/* This will return the Architecture of the package this section describes */
string debListParser::Architecture() {
- return Section.FindS("Architecture");
+ std::string const Arch = Section.FindS("Architecture");
+ return Arch.empty() ? "none" : Arch;
}
/*}}}*/
// ListParser::ArchitectureAll /*{{{*/
@@ -97,14 +93,14 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
unsigned char MA;
string const MultiArch = Section.FindS("Multi-Arch");
if (MultiArch.empty() == true || MultiArch == "no")
- MA = pkgCache::Version::None;
+ MA = pkgCache::Version::No;
else if (MultiArch == "same") {
if (ArchitectureAll() == true)
{
if (showErrors == true)
_error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
Section.FindS("Package").c_str());
- MA = pkgCache::Version::None;
+ MA = pkgCache::Version::No;
}
else
MA = pkgCache::Version::Same;
@@ -118,7 +114,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
if (showErrors == true)
_error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
MultiArch.c_str(), Section.FindS("Package").c_str());
- MA = pkgCache::Version::None;
+ MA = pkgCache::Version::No;
}
if (ArchitectureAll() == true)
@@ -141,7 +137,6 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
map_stringitem_t const idx = StoreString(pkgCacheGenerator::SECTION, Start, Stop - Start);
Ver->Section = idx;
}
-#if APT_PKG_ABI >= 413
// Parse the source package name
pkgCache::GrpIterator const G = Ver.ParentPkg().Group();
Ver->SourcePkgName = G->Name;
@@ -193,7 +188,6 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
}
}
}
-#endif
Ver->MultiArch = ParseMultiArch(true);
// Archive Size
@@ -209,23 +203,22 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
Ver->Priority = pkgCache::State::Extra;
}
- if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
- return false;
if (ParseDepends(Ver,"Pre-Depends",pkgCache::Dep::PreDepends) == false)
return false;
- if (ParseDepends(Ver,"Suggests",pkgCache::Dep::Suggests) == false)
- return false;
- if (ParseDepends(Ver,"Recommends",pkgCache::Dep::Recommends) == false)
+ if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
return false;
if (ParseDepends(Ver,"Conflicts",pkgCache::Dep::Conflicts) == false)
return false;
if (ParseDepends(Ver,"Breaks",pkgCache::Dep::DpkgBreaks) == false)
return false;
+ if (ParseDepends(Ver,"Recommends",pkgCache::Dep::Recommends) == false)
+ return false;
+ if (ParseDepends(Ver,"Suggests",pkgCache::Dep::Suggests) == false)
+ return false;
if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
return false;
if (ParseDepends(Ver,"Enhances",pkgCache::Dep::Enhances) == false)
return false;
-
// Obsolete.
if (ParseDepends(Ver,"Optional",pkgCache::Dep::Suggests) == false)
return false;
@@ -793,43 +786,23 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
return _error->Error("Problem parsing dependency %s",Tag);
size_t const found = Package.rfind(':');
- // If negative is unspecific it needs to apply on all architectures
- if (MultiArchEnabled == true && found == string::npos &&
- (Type == pkgCache::Dep::Conflicts ||
- Type == pkgCache::Dep::DpkgBreaks ||
- Type == pkgCache::Dep::Replaces))
+ if (found == string::npos || strcmp(Package.c_str() + found, ":any") == 0)
{
- for (std::vector<std::string>::const_iterator a = Architectures.begin();
- a != Architectures.end(); ++a)
- if (NewDepends(Ver,Package,*a,Version,Op,Type) == false)
- return false;
- if (NewDepends(Ver,Package,"none",Version,Op,Type) == false)
+ if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
return false;
}
- else if (found != string::npos &&
- strcmp(Package.c_str() + found, ":any") != 0)
+ else
{
string Arch = Package.substr(found+1, string::npos);
Package = Package.substr(0, found);
// Such dependencies are not supposed to be accepted …
- // … but this is probably the best thing to do.
+ // … but this is probably the best thing to do anyway
if (Arch == "native")
Arch = _config->Find("APT::Architecture");
- if (NewDepends(Ver,Package,Arch,Version,Op,Type) == false)
- return false;
- }
- else
- {
- if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
- return false;
- if ((Type == pkgCache::Dep::Conflicts ||
- Type == pkgCache::Dep::DpkgBreaks ||
- Type == pkgCache::Dep::Replaces) &&
- NewDepends(Ver, Package,
- (pkgArch != "none") ? "none" : _config->Find("APT::Architecture"),
- Version,Op,Type) == false)
+ if (NewDepends(Ver,Package,Arch,Version,Op | pkgCache::Dep::ArchSpecific,Type) == false)
return false;
}
+
if (Start == Stop)
break;
}
@@ -861,13 +834,13 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
} else if (archfound != string::npos) {
string OtherArch = Package.substr(archfound+1, string::npos);
Package = Package.substr(0, archfound);
- if (NewProvides(Ver, Package, OtherArch, Version) == false)
+ if (NewProvides(Ver, Package, OtherArch, Version, pkgCache::Flag::ArchSpecific) == false)
return false;
} else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
- if (NewProvidesAllArch(Ver, Package, Version) == false)
+ if (NewProvidesAllArch(Ver, Package, Version, 0) == false)
return false;
} else {
- if (NewProvides(Ver, Package, Arch, Version) == false)
+ if (NewProvides(Ver, Package, Arch, Version, 0) == false)
return false;
}
@@ -879,26 +852,14 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
{
string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
- return NewProvidesAllArch(Ver, Package, Ver.VerStr());
+ return NewProvidesAllArch(Ver, Package, Ver.VerStr(), pkgCache::Flag::MultiArchImplicit);
}
else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
- return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr());
+ return NewProvidesAllArch(Ver, Ver.ParentPkg().Name(), Ver.VerStr(), pkgCache::Flag::MultiArchImplicit);
return true;
}
/*}}}*/
-// ListParser::NewProvides - add provides for all architectures /*{{{*/
-bool debListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package,
- string const &Version) {
- for (std::vector<string>::const_iterator a = Architectures.begin();
- a != Architectures.end(); ++a)
- {
- if (NewProvides(Ver, Package, *a, Version) == false)
- return false;
- }
- return true;
-}
- /*}}}*/
// ListParser::GrabWord - Matches a word and returns /*{{{*/
// ---------------------------------------------------------------------
/* Looks for a word in a list of words - for ParseStatus */
@@ -921,71 +882,7 @@ bool debListParser::GrabWord(string Word,WordList *List,unsigned char &Out)
bool debListParser::Step()
{
iOffset = Tags.Offset();
- while (Tags.Step(Section) == true)
- {
- /* See if this is the correct Architecture, if it isn't then we
- drop the whole section. A missing arch tag only happens (in theory)
- inside the Status file, so that is a positive return */
- string const Architecture = Section.FindS("Architecture");
-
- if (Arch.empty() == true || Arch == "any" || MultiArchEnabled == false)
- {
- if (APT::Configuration::checkArchitecture(Architecture) == true)
- return true;
- /* parse version stanzas without an architecture only in the status file
- (and as misfortune bycatch flat-archives) */
- if ((Arch.empty() == true || Arch == "any") && Architecture.empty() == true)
- return true;
- }
- else
- {
- if (Architecture == Arch)
- return true;
-
- if (Architecture == "all" && Arch == _config->Find("APT::Architecture"))
- return true;
- }
-
- iOffset = Tags.Offset();
- }
- return false;
-}
- /*}}}*/
-// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
- FileFd &File, string component)
-{
- // apt-secure does no longer download individual (per-section) Release
- // file. to provide Component pinning we use the section name now
- map_stringitem_t const storage = StoreString(pkgCacheGenerator::MIXED, component);
- FileI->Component = storage;
-
- pkgTagFile TagFile(&File, File.Size());
- pkgTagSection Section;
- if (_error->PendingError() == true || TagFile.Step(Section) == false)
- return false;
-
- std::string data;
- #define APT_INRELEASE(TYPE, TAG, STORE) \
- data = Section.FindS(TAG); \
- if (data.empty() == false) \
- { \
- map_stringitem_t const storage = StoreString(pkgCacheGenerator::TYPE, data); \
- STORE = storage; \
- }
- APT_INRELEASE(MIXED, "Suite", FileI->Archive)
- APT_INRELEASE(MIXED, "Component", FileI->Component)
- APT_INRELEASE(VERSIONNUMBER, "Version", FileI->Version)
- APT_INRELEASE(MIXED, "Origin", FileI->Origin)
- APT_INRELEASE(MIXED, "Codename", FileI->Codename)
- APT_INRELEASE(MIXED, "Label", FileI->Label)
- #undef APT_INRELEASE
- Section.FindFlag("NotAutomatic", FileI->Flags, pkgCache::Flag::NotAutomatic);
- Section.FindFlag("ButAutomaticUpgrades", FileI->Flags, pkgCache::Flag::ButAutomaticUpgrades);
-
- return !_error->PendingError();
+ return Tags.Step(Section);
}
/*}}}*/
// ListParser::GetPrio - Convert the priority from a string /*{{{*/
@@ -1000,11 +897,10 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
-#if APT_PKG_ABI >= 413
bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
pkgCache::VerIterator const &Ver)
{
- if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false)
+ if (pkgCacheListParser::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
@@ -1020,11 +916,9 @@ bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
return true;
}
/*}}}*/
-#endif
-
debDebFileParser::debDebFileParser(FileFd *File, std::string const &DebFile)
- : debListParser(File, ""), DebFile(DebFile)
+ : debListParser(File), DebFile(DebFile)
{
}
@@ -1034,7 +928,7 @@ bool debDebFileParser::UsePackage(pkgCache::PkgIterator &Pkg,
bool res = debListParser::UsePackage(Pkg, Ver);
// we use the full file path as a provides so that the file is found
// by its name
- if(NewProvidesAllArch(Ver, DebFile, Ver.VerStr()) == false)
+ if(NewProvides(Ver, DebFile, Pkg.Cache()->NativeArch(), Ver.VerStr(), 0) == false)
return false;
return res;
}
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 6279d8399..747e022d8 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -26,7 +26,7 @@
class FileFd;
-class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser
+class APT_HIDDEN debListParser : public pkgCacheListParser
{
public:
@@ -39,21 +39,17 @@ class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser
private:
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
protected:
pkgTagFile Tags;
pkgTagSection Section;
map_filesize_t iOffset;
- std::string Arch;
- std::vector<std::string> Architectures;
- bool MultiArchEnabled;
virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
unsigned int Type);
bool ParseProvides(pkgCache::VerIterator &Ver);
- bool NewProvidesAllArch(pkgCache::VerIterator &Ver, std::string const &Package, std::string const &Version);
static bool GrabWord(std::string Word,WordList *List,unsigned char &Out);
APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
@@ -62,27 +58,25 @@ class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser
APT_PUBLIC static unsigned char GetPrio(std::string Str);
// These all operate against the current section
- virtual std::string Package();
- virtual std::string Architecture();
- virtual bool ArchitectureAll();
- virtual std::string Version();
- virtual bool NewVersion(pkgCache::VerIterator &Ver);
- virtual std::string Description(std::string const &lang);
- virtual std::vector<std::string> AvailableDescriptionLanguages();
- virtual MD5SumValue Description_md5();
- virtual unsigned short VersionHash();
-#if APT_PKG_ABI >= 413
- virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
-#endif
+ virtual std::string Package() APT_OVERRIDE;
+ virtual std::string Architecture() APT_OVERRIDE;
+ virtual bool ArchitectureAll() APT_OVERRIDE;
+ virtual std::string Version() APT_OVERRIDE;
+ virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
+ virtual std::string Description(std::string const &lang) APT_OVERRIDE;
+ virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
+ virtual MD5SumValue Description_md5() APT_OVERRIDE;
+ virtual unsigned short VersionHash() APT_OVERRIDE;
+ virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
- pkgCache::VerIterator &Ver);
- virtual map_filesize_t Offset() {return iOffset;};
- virtual map_filesize_t Size() {return Section.size();};
+ pkgCache::VerIterator &Ver) APT_OVERRIDE;
+ virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
+ virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
- virtual bool Step();
-
- bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
- std::string section);
+ virtual bool Step() APT_OVERRIDE;
+
+ bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
+ std::string const &section);
APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op);
@@ -99,7 +93,7 @@ class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser
APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
- debListParser(FileFd *File, std::string const &Arch = "");
+ debListParser(FileFd *File);
virtual ~debListParser();
};
@@ -111,18 +105,18 @@ class APT_HIDDEN debDebFileParser : public debListParser
public:
debDebFileParser(FileFd *File, std::string const &DebFile);
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
- pkgCache::VerIterator &Ver);
+ pkgCache::VerIterator &Ver) APT_OVERRIDE;
};
class APT_HIDDEN debTranslationsParser : public debListParser
{
public:
// a translation can never be a real package
- virtual std::string Architecture() { return ""; }
- virtual std::string Version() { return ""; }
+ virtual std::string Architecture() APT_OVERRIDE { return ""; }
+ virtual std::string Version() APT_OVERRIDE { return ""; }
- debTranslationsParser(FileFd *File, std::string const &Arch = "")
- : debListParser(File, Arch) {};
+ debTranslationsParser(FileFd *File)
+ : debListParser(File) {};
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index aa2db8149..b2e9eeb00 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -1,5 +1,6 @@
#include <config.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/debmetaindex.h>
#include <apt-pkg/debindexfile.h>
#include <apt-pkg/strutl.h>
@@ -7,44 +8,50 @@
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/indexrecords.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/hashes.h>
-#include <apt-pkg/macros.h>
#include <apt-pkg/metaindex.h>
+#include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/gpgv.h>
+#include <apt-pkg/macros.h>
-#include <string.h>
#include <map>
#include <string>
#include <utility>
#include <vector>
-#include <set>
#include <algorithm>
-using namespace std;
+#include <sys/stat.h>
+#include <string.h>
+
+#include <apti18n.h>
-string debReleaseIndex::Info(const char *Type, string const &Section, string const &Arch) const
+class APT_HIDDEN debReleaseIndexPrivate /*{{{*/
{
- string Info = ::URI::SiteOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
+ public:
+ struct APT_HIDDEN debSectionEntry
{
- Info += Dist + '/' + Section;
- if (Arch.empty() != true)
- Info += " " + Arch;
- }
- Info += " ";
- Info += Type;
- return Info;
-}
+ std::string Name;
+ std::vector<std::string> Targets;
+ std::vector<std::string> Architectures;
+ std::vector<std::string> Languages;
+ };
+
+ std::vector<debSectionEntry> DebEntries;
+ std::vector<debSectionEntry> DebSrcEntries;
-string debReleaseIndex::MetaIndexInfo(const char *Type) const
+ metaIndex::TriState CheckValidUntil;
+ time_t ValidUntilMin;
+ time_t ValidUntilMax;
+
+ debReleaseIndexPrivate() : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0) {}
+};
+ /*}}}*/
+// ReleaseIndex::MetaIndex* - display helpers /*{{{*/
+std::string debReleaseIndex::MetaIndexInfo(const char *Type) const
{
- string Info = ::URI::SiteOnly(URI) + ' ';
+ std::string Info = ::URI::ArchiveOnly(URI) + ' ';
if (Dist[Dist.size() - 1] == '/')
{
if (Dist != "/")
@@ -56,16 +63,20 @@ string debReleaseIndex::MetaIndexInfo(const char *Type) const
Info += Type;
return Info;
}
+std::string debReleaseIndex::Describe() const
+{
+ return MetaIndexInfo("Release");
+}
-string debReleaseIndex::MetaIndexFile(const char *Type) const
+std::string debReleaseIndex::MetaIndexFile(const char *Type) const
{
return _config->FindDir("Dir::State::lists") +
URItoFileName(MetaIndexURI(Type));
}
-string debReleaseIndex::MetaIndexURI(const char *Type) const
+std::string debReleaseIndex::MetaIndexURI(const char *Type) const
{
- string Res;
+ std::string Res;
if (Dist == "/")
Res = URI;
@@ -77,235 +88,410 @@ string debReleaseIndex::MetaIndexURI(const char *Type) const
Res += Type;
return Res;
}
-
-std::string debReleaseIndex::LocalFileName() const
+ /*}}}*/
+// ReleaseIndex Con- and Destructors /*{{{*/
+debReleaseIndex::debReleaseIndex(std::string const &URI, std::string const &Dist) :
+ metaIndex(URI, Dist, "deb"), d(new debReleaseIndexPrivate())
+{}
+debReleaseIndex::debReleaseIndex(std::string const &URI, std::string const &Dist, bool const pTrusted) :
+ metaIndex(URI, Dist, "deb"), d(new debReleaseIndexPrivate())
{
- // see if we have a InRelease file
- std::string PathInRelease = MetaIndexFile("InRelease");
- if (FileExists(PathInRelease))
- return PathInRelease;
-
- // and if not return the normal one
- if (FileExists(PathInRelease))
- return MetaIndexFile("Release");
-
- return "";
+ Trusted = pTrusted ? TRI_YES : TRI_NO;
}
-
-string debReleaseIndex::IndexURISuffix(const char *Type, string const &Section, string const &Arch) const
-{
- string Res ="";
- if (Dist[Dist.size() - 1] != '/')
- {
- if (Arch == "native")
- Res += Section + "/binary-" + _config->Find("APT::Architecture") + '/';
- else
- Res += Section + "/binary-" + Arch + '/';
- }
- return Res + Type;
+debReleaseIndex::~debReleaseIndex() {
+ if (d != NULL)
+ delete d;
}
-
-
-string debReleaseIndex::IndexURI(const char *Type, string const &Section, string const &Arch) const
+ /*}}}*/
+// ReleaseIndex::GetIndexTargets /*{{{*/
+static void GetIndexTargetsFor(char const * const Type, std::string const &URI, std::string const &Dist,
+ std::vector<debReleaseIndexPrivate::debSectionEntry> const &entries,
+ std::vector<IndexTarget> &IndexTargets)
{
- if (Dist[Dist.size() - 1] == '/')
+ bool const flatArchive = (Dist[Dist.length() - 1] == '/');
+ std::string baseURI = URI;
+ if (flatArchive)
{
- string Res;
if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- return Res + Type;
+ baseURI += Dist;
}
else
- return URI + "dists/" + Dist + '/' + IndexURISuffix(Type, Section, Arch);
- }
+ baseURI += "dists/" + Dist + "/";
+ std::string const Release = (Dist == "/") ? "" : Dist;
+ std::string const Site = ::URI::ArchiveOnly(URI);
+
+ bool const GzipIndex = _config->FindB("Acquire::GzipIndexes", false);
+ for (std::vector<debReleaseIndexPrivate::debSectionEntry>::const_iterator E = entries.begin(); E != entries.end(); ++E)
+ {
+ for (std::vector<std::string>::const_iterator T = E->Targets.begin(); T != E->Targets.end(); ++T)
+ {
+#define APT_T_CONFIG(X) _config->Find(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::" + (X))
+ std::string const tplMetaKey = APT_T_CONFIG(flatArchive ? "flatMetaKey" : "MetaKey");
+ std::string const tplShortDesc = APT_T_CONFIG("ShortDescription");
+ std::string const tplLongDesc = "$(SITE) " + APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
+ bool const IsOptional = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::Optional", true);
+ bool const KeepCompressed = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::KeepCompressed", GzipIndex);
+#undef APT_T_CONFIG
+ if (tplMetaKey.empty())
+ continue;
+
+ for (std::vector<std::string>::const_iterator L = E->Languages.begin(); L != E->Languages.end(); ++L)
+ {
+ if (*L == "none" && tplMetaKey.find("$(LANGUAGE)") != std::string::npos)
+ continue;
+
+ for (std::vector<std::string>::const_iterator A = E->Architectures.begin(); A != E->Architectures.end(); ++A)
+ {
-string debReleaseIndex::SourceIndexURISuffix(const char *Type, const string &Section) const
+ std::map<std::string, std::string> Options;
+ Options.insert(std::make_pair("SITE", Site));
+ Options.insert(std::make_pair("RELEASE", Release));
+ if (tplMetaKey.find("$(COMPONENT)") != std::string::npos)
+ Options.insert(std::make_pair("COMPONENT", E->Name));
+ if (tplMetaKey.find("$(LANGUAGE)") != std::string::npos)
+ Options.insert(std::make_pair("LANGUAGE", *L));
+ if (tplMetaKey.find("$(ARCHITECTURE)") != std::string::npos)
+ Options.insert(std::make_pair("ARCHITECTURE", *A));
+ Options.insert(std::make_pair("BASE_URI", baseURI));
+ Options.insert(std::make_pair("REPO_URI", URI));
+ Options.insert(std::make_pair("TARGET_OF", "deb-src"));
+ Options.insert(std::make_pair("CREATED_BY", *T));
+
+ std::string MetaKey = tplMetaKey;
+ std::string ShortDesc = tplShortDesc;
+ std::string LongDesc = tplLongDesc;
+ for (std::map<std::string, std::string>::const_iterator O = Options.begin(); O != Options.end(); ++O)
+ {
+ MetaKey = SubstVar(MetaKey, std::string("$(") + O->first + ")", O->second);
+ ShortDesc = SubstVar(ShortDesc, std::string("$(") + O->first + ")", O->second);
+ LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second);
+ }
+ IndexTarget Target(
+ MetaKey,
+ ShortDesc,
+ LongDesc,
+ Options.find("BASE_URI")->second + MetaKey,
+ IsOptional,
+ KeepCompressed,
+ Options
+ );
+ IndexTargets.push_back(Target);
+
+ if (tplMetaKey.find("$(ARCHITECTURE)") == std::string::npos)
+ break;
+
+ }
+
+ if (tplMetaKey.find("$(LANGUAGE)") == std::string::npos)
+ break;
+
+ }
+
+ }
+ }
+}
+std::vector<IndexTarget> debReleaseIndex::GetIndexTargets() const
{
- string Res ="";
- if (Dist[Dist.size() - 1] != '/')
- Res += Section + "/source/";
- return Res + Type;
+ std::vector<IndexTarget> IndexTargets;
+ GetIndexTargetsFor("deb-src", URI, Dist, d->DebSrcEntries, IndexTargets);
+ GetIndexTargetsFor("deb", URI, Dist, d->DebEntries, IndexTargets);
+ return IndexTargets;
}
-
-string debReleaseIndex::SourceIndexURI(const char *Type, const string &Section) const
+ /*}}}*/
+void debReleaseIndex::AddComponent(bool const isSrc, std::string const &Name,/*{{{*/
+ std::vector<std::string> const &Targets,
+ std::vector<std::string> const &Architectures,
+ std::vector<std::string> Languages)
{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- return Res + Type;
- }
+ if (Languages.empty() == true)
+ Languages.push_back("none");
+ debReleaseIndexPrivate::debSectionEntry const entry = {
+ Name, Targets, Architectures, Languages
+ };
+ if (isSrc)
+ d->DebSrcEntries.push_back(entry);
else
- return URI + "dists/" + Dist + "/" + SourceIndexURISuffix(Type, Section);
+ d->DebEntries.push_back(entry);
}
+ /*}}}*/
-string debReleaseIndex::TranslationIndexURISuffix(const char *Type, const string &Section) const
+bool debReleaseIndex::Load(std::string const &Filename, std::string * const ErrorText)/*{{{*/
{
- string Res ="";
- if (Dist[Dist.size() - 1] != '/')
- Res += Section + "/i18n/Translation-";
- return Res + Type;
-}
+ LoadedSuccessfully = TRI_NO;
+ FileFd Fd;
+ if (OpenMaybeClearSignedFile(Filename, Fd) == false)
+ return false;
-string debReleaseIndex::TranslationIndexURI(const char *Type, const string &Section) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
+ pkgTagFile TagFile(&Fd, Fd.Size());
+ if (_error->PendingError() == true)
{
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- return Res + Type;
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("Unable to parse Release file %s"),Filename.c_str());
+ return false;
}
- else
- return URI + "dists/" + Dist + "/" + TranslationIndexURISuffix(Type, Section);
-}
-debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) :
- metaIndex(URI, Dist, "deb"), Trusted(CHECK_TRUST)
-{}
+ pkgTagSection Section;
+ const char *Start, *End;
+ if (TagFile.Step(Section) == false)
+ {
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("No sections in Release file %s"), Filename.c_str());
+ return false;
+ }
+ // FIXME: find better tag name
+ SupportsAcquireByHash = Section.FindB("Acquire-By-Hash", false);
-debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist, bool const Trusted) :
- metaIndex(URI, Dist, "deb") {
- SetTrusted(Trusted);
-}
+ Suite = Section.FindS("Suite");
+ Codename = Section.FindS("Codename");
-debReleaseIndex::~debReleaseIndex() {
- for (map<string, vector<debSectionEntry const*> >::const_iterator A = ArchEntries.begin();
- A != ArchEntries.end(); ++A)
- for (vector<const debSectionEntry *>::const_iterator S = A->second.begin();
- S != A->second.end(); ++S)
- delete *S;
-}
+ bool FoundHashSum = false;
+ for (int i=0;HashString::SupportedHashes()[i] != NULL; i++)
+ {
+ if (!Section.Find(HashString::SupportedHashes()[i], Start, End))
+ continue;
+
+ std::string Name;
+ std::string Hash;
+ unsigned long long Size;
+ while (Start < End)
+ {
+ if (!parseSumData(Start, End, Name, Hash, Size))
+ return false;
+
+ if (Entries.find(Name) == Entries.end())
+ {
+ metaIndex::checkSum *Sum = new metaIndex::checkSum;
+ Sum->MetaKeyFilename = Name;
+ Sum->Size = Size;
+ Sum->Hashes.FileSize(Size);
+ APT_IGNORE_DEPRECATED(Sum->Hash = HashString(HashString::SupportedHashes()[i],Hash);)
+ Entries[Name] = Sum;
+ }
+ Entries[Name]->Hashes.push_back(HashString(HashString::SupportedHashes()[i],Hash));
+ FoundHashSum = true;
+ }
+ }
+
+ if(FoundHashSum == false)
+ {
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("No Hash entry in Release file %s"), Filename.c_str());
+ return false;
+ }
+
+ std::string const StrDate = Section.FindS("Date");
+ if (RFC1123StrToTime(StrDate.c_str(), Date) == false)
+ {
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
+ return false;
+ }
+
+ bool CheckValidUntil = _config->FindB("Acquire::Check-Valid-Until", true);
+ if (d->CheckValidUntil == metaIndex::TRI_NO)
+ CheckValidUntil = false;
+ else if (d->CheckValidUntil == metaIndex::TRI_YES)
+ CheckValidUntil = true;
+
+ if (CheckValidUntil == true)
+ {
+ std::string const Label = Section.FindS("Label");
+ std::string const StrValidUntil = Section.FindS("Valid-Until");
-vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
- vector <IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
-
- map<string, vector<debSectionEntry const*> >::const_iterator const src = ArchEntries.find("source");
- if (src != ArchEntries.end()) {
- vector<debSectionEntry const*> const SectionEntries = src->second;
- for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); ++I) {
- IndexTarget * Target = new IndexTarget();
- Target->ShortDesc = "Sources";
- Target->MetaKey = SourceIndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section);
- Target->URI = SourceIndexURI(Target->ShortDesc.c_str(), (*I)->Section);
- Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section);
- IndexTargets->push_back (Target);
- }
- }
-
- // Only source release
- if (IndexTargets->empty() == false && ArchEntries.size() == 1)
- return IndexTargets;
-
- std::set<std::string> sections;
- for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
- a != ArchEntries.end(); ++a) {
- if (a->first == "source")
- continue;
- for (vector <const debSectionEntry *>::const_iterator I = a->second.begin();
- I != a->second.end(); ++I) {
- IndexTarget * Target = new IndexTarget();
- Target->ShortDesc = "Packages";
- Target->MetaKey = IndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section, a->first);
- Target->URI = IndexURI(Target->ShortDesc.c_str(), (*I)->Section, a->first);
- Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section, a->first);
- IndexTargets->push_back (Target);
- sections.insert((*I)->Section);
- }
- }
-
- std::vector<std::string> lang = APT::Configuration::getLanguages(true);
- std::vector<std::string>::iterator lend = std::remove(lang.begin(), lang.end(), "none");
- if (lend != lang.end())
- lang.erase(lend);
-
- if (lang.empty() == true)
- return IndexTargets;
-
- // get the Translation-* files, later we will skip download of non-existent if we have an index
- for (std::set<std::string>::const_iterator s = sections.begin();
- s != sections.end(); ++s) {
- for (std::vector<std::string>::const_iterator l = lang.begin();
- l != lang.end(); ++l) {
- IndexTarget * Target = new OptionalIndexTarget();
- Target->ShortDesc = "Translation-" + *l;
- Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
- Target->URI = TranslationIndexURI(l->c_str(), *s);
- Target->Description = Info (Target->ShortDesc.c_str(), *s);
- IndexTargets->push_back(Target);
- }
- }
-
- return IndexTargets;
+ // if we have a Valid-Until header in the Release file, use it as default
+ if (StrValidUntil.empty() == false)
+ {
+ if(RFC1123StrToTime(StrValidUntil.c_str(), ValidUntil) == false)
+ {
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("Invalid 'Valid-Until' entry in Release file %s"), Filename.c_str());
+ return false;
+ }
+ }
+ // get the user settings for this archive and use what expires earlier
+ time_t MaxAge = d->ValidUntilMax;
+ if (MaxAge == 0)
+ {
+ MaxAge = _config->FindI("Acquire::Max-ValidTime", 0);
+ if (Label.empty() == false)
+ MaxAge = _config->FindI(("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge);
+ }
+ time_t MinAge = d->ValidUntilMin;
+ if (MinAge == 0)
+ {
+ MinAge = _config->FindI("Acquire::Min-ValidTime", 0);
+ if (Label.empty() == false)
+ MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
+ }
+
+ if (MinAge != 0 && ValidUntil != 0) {
+ time_t const min_date = Date + MinAge;
+ if (ValidUntil < min_date)
+ ValidUntil = min_date;
+ }
+ if (MaxAge != 0) {
+ time_t const max_date = Date + MaxAge;
+ if (ValidUntil == 0 || ValidUntil > max_date)
+ ValidUntil = max_date;
+ }
+ }
+
+ LoadedSuccessfully = TRI_YES;
+ return true;
+}
+ /*}}}*/
+metaIndex * debReleaseIndex::UnloadedClone() const /*{{{*/
+{
+ if (Trusted == TRI_NO)
+ return new debReleaseIndex(URI, Dist, false);
+ else if (Trusted == TRI_YES)
+ return new debReleaseIndex(URI, Dist, true);
+ else
+ return new debReleaseIndex(URI, Dist);
}
/*}}}*/
-bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
+bool debReleaseIndex::parseSumData(const char *&Start, const char *End, /*{{{*/
+ std::string &Name, std::string &Hash, unsigned long long &Size)
{
- bool const tryInRelease = _config->FindB("Acquire::TryInRelease", true);
+ Name = "";
+ Hash = "";
+ Size = 0;
+ /* Skip over the first blank */
+ while ((*Start == '\t' || *Start == ' ' || *Start == '\n' || *Start == '\r')
+ && Start < End)
+ Start++;
+ if (Start >= End)
+ return false;
+
+ /* Move EntryEnd to the end of the first entry (the hash) */
+ const char *EntryEnd = Start;
+ while ((*EntryEnd != '\t' && *EntryEnd != ' ')
+ && EntryEnd < End)
+ EntryEnd++;
+ if (EntryEnd == End)
+ return false;
- indexRecords * const iR = new indexRecords(Dist);
- if (Trusted == ALWAYS_TRUSTED)
- iR->SetTrusted(true);
- else if (Trusted == NEVER_TRUSTED)
- iR->SetTrusted(false);
+ Hash.append(Start, EntryEnd-Start);
+ /* Skip over intermediate blanks */
+ Start = EntryEnd;
+ while (*Start == '\t' || *Start == ' ')
+ Start++;
+ if (Start >= End)
+ return false;
+
+ EntryEnd = Start;
+ /* Find the end of the second entry (the size) */
+ while ((*EntryEnd != '\t' && *EntryEnd != ' ' )
+ && EntryEnd < End)
+ EntryEnd++;
+ if (EntryEnd == End)
+ return false;
+
+ Size = strtoull (Start, NULL, 10);
+
+ /* Skip over intermediate blanks */
+ Start = EntryEnd;
+ while (*Start == '\t' || *Start == ' ')
+ Start++;
+ if (Start >= End)
+ return false;
+
+ EntryEnd = Start;
+ /* Find the end of the third entry (the filename) */
+ while ((*EntryEnd != '\t' && *EntryEnd != ' ' &&
+ *EntryEnd != '\n' && *EntryEnd != '\r')
+ && EntryEnd < End)
+ EntryEnd++;
+
+ Name.append(Start, EntryEnd-Start);
+ Start = EntryEnd; //prepare for the next round
+ return true;
+}
+ /*}}}*/
+
+bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll)/*{{{*/
+{
+ std::vector<IndexTarget> const targets = GetIndexTargets();
+#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, false, std::map<std::string,std::string>())
+ pkgAcqMetaClearSig * const TransactionManager = new pkgAcqMetaClearSig(Owner,
+ APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
+ targets, this);
+#undef APT_TARGET
// special case for --print-uris
- if (GetAll) {
- vector <IndexTarget *> *targets = ComputeIndexTargets();
- for (vector <IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) {
- new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
- (*Target)->ShortDesc, HashStringList());
- }
- delete targets;
-
- // this is normally created in pkgAcqMetaSig, but if we run
- // in --print-uris mode, we add it here
- if (tryInRelease == false)
- new pkgAcqMetaIndex(Owner, NULL,
- MetaIndexURI("Release"),
- MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
+ if (GetAll)
+ {
+ for (std::vector<IndexTarget>::const_iterator Target = targets.begin(); Target != targets.end(); ++Target)
+ new pkgAcqIndex(Owner, TransactionManager, *Target);
}
- if (tryInRelease == true)
- new pkgAcqMetaClearSig(Owner,
- MetaIndexURI("InRelease"), MetaIndexInfo("InRelease"), "InRelease",
- MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
- else
- new pkgAcqMetaIndex(Owner, NULL,
- MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
return true;
}
-
-void debReleaseIndex::SetTrusted(bool const Trusted)
+ /*}}}*/
+// ReleaseIndex::Set* TriState options /*{{{*/
+bool debReleaseIndex::SetTrusted(TriState const pTrusted)
{
- if (Trusted == true)
- this->Trusted = ALWAYS_TRUSTED;
- else
- this->Trusted = NEVER_TRUSTED;
+ if (Trusted == TRI_UNSET)
+ Trusted = pTrusted;
+ else if (Trusted != pTrusted)
+ // TRANSLATOR: The first is an option name from sources.list manpage, the other two URI and Suite
+ return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Trusted", URI.c_str(), Dist.c_str());
+ return true;
}
-
+bool debReleaseIndex::SetCheckValidUntil(TriState const pCheckValidUntil)
+{
+ if (d->CheckValidUntil == TRI_UNSET)
+ d->CheckValidUntil = pCheckValidUntil;
+ else if (d->CheckValidUntil != pCheckValidUntil)
+ return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str());
+ return true;
+}
+bool debReleaseIndex::SetValidUntilMin(time_t const Valid)
+{
+ if (d->ValidUntilMin == 0)
+ d->ValidUntilMin = Valid;
+ else if (d->ValidUntilMin != Valid)
+ return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str());
+ return true;
+}
+bool debReleaseIndex::SetValidUntilMax(time_t const Valid)
+{
+ if (d->ValidUntilMax == 0)
+ d->ValidUntilMax = Valid;
+ else if (d->ValidUntilMax != Valid)
+ return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str());
+ return true;
+}
+bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy)
+{
+ if (SignedBy.empty() == true && pSignedBy.empty() == false)
+ {
+ if (pSignedBy[0] == '/') // no check for existence as we could be chrooting later or such things
+ ; // absolute path to a keyring file
+ else
+ {
+ // we could go all fancy and allow short/long/string matches as gpgv/apt-key does,
+ // but fingerprints are harder to fake than the others and this option is set once,
+ // not interactively all the time so easy to type is not really a concern.
+ std::string finger = pSignedBy;
+ finger.erase(std::remove(finger.begin(), finger.end(), ' '), finger.end());
+ std::transform(finger.begin(), finger.end(), finger.begin(), ::toupper);
+ if (finger.length() != 40 || finger.find_first_not_of("0123456789ABCDEF") != std::string::npos)
+ return _error->Error(_("Invalid value set for option %s concerning source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint");
+ }
+ SignedBy = pSignedBy;
+ }
+ else if (SignedBy != pSignedBy)
+ return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Signed-By", URI.c_str(), Dist.c_str());
+ return true;
+}
+ /*}}}*/
+// ReleaseIndex::IsTrusted /*{{{*/
bool debReleaseIndex::IsTrusted() const
{
- if (Trusted == ALWAYS_TRUSTED)
+ if (Trusted == TRI_YES)
return true;
- else if (Trusted == NEVER_TRUSTED)
+ else if (Trusted == TRI_NO)
return false;
@@ -313,236 +499,288 @@ bool debReleaseIndex::IsTrusted() const
if(URI.substr(0,strlen("cdrom:")) == "cdrom:")
return true;
- string VerifiedSigFile = _config->FindDir("Dir::State::lists") +
- URItoFileName(MetaIndexURI("Release")) + ".gpg";
-
- if (FileExists(VerifiedSigFile))
+ if (FileExists(MetaIndexFile("Release.gpg")))
return true;
- VerifiedSigFile = _config->FindDir("Dir::State::lists") +
- URItoFileName(MetaIndexURI("InRelease"));
-
- return FileExists(VerifiedSigFile);
+ return FileExists(MetaIndexFile("InRelease"));
}
+ /*}}}*/
+std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() /*{{{*/
+{
+ if (Indexes != NULL)
+ return Indexes;
-vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
- if (Indexes != NULL)
- return Indexes;
-
- Indexes = new vector <pkgIndexFile*>;
- map<string, vector<debSectionEntry const*> >::const_iterator const src = ArchEntries.find("source");
- if (src != ArchEntries.end()) {
- vector<debSectionEntry const*> const SectionEntries = src->second;
- for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); ++I)
- Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
- }
-
- // Only source release
- if (Indexes->empty() == false && ArchEntries.size() == 1)
- return Indexes;
-
- std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
- map<string, set<string> > sections;
- for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
- a != ArchEntries.end(); ++a) {
- if (a->first == "source")
- continue;
- for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
- I != a->second.end(); ++I) {
- Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first));
- sections[(*I)->Section].insert(lang.begin(), lang.end());
- }
- }
-
- for (map<string, set<string> >::const_iterator s = sections.begin();
- s != sections.end(); ++s)
- for (set<string>::const_iterator l = s->second.begin();
- l != s->second.end(); ++l) {
- if (*l == "none") continue;
- Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str()));
- }
-
- return Indexes;
+ Indexes = new std::vector<pkgIndexFile*>();
+ std::vector<IndexTarget> const Targets = GetIndexTargets();
+ bool const istrusted = IsTrusted();
+ for (std::vector<IndexTarget>::const_iterator T = Targets.begin(); T != Targets.end(); ++T)
+ {
+ std::string const TargetName = T->Option(IndexTarget::CREATED_BY);
+ if (TargetName == "Packages")
+ Indexes->push_back(new debPackagesIndex(*T, istrusted));
+ else if (TargetName == "Sources")
+ Indexes->push_back(new debSourcesIndex(*T, istrusted));
+ else if (TargetName == "Translations")
+ Indexes->push_back(new debTranslationsIndex(*T));
+ }
+ return Indexes;
}
+ /*}}}*/
-void debReleaseIndex::PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry) {
- for (vector<string>::const_iterator a = Archs.begin();
- a != Archs.end(); ++a)
- ArchEntries[*a].push_back(new debSectionEntry(Entry->Section, Entry->IsSrc));
- delete Entry;
+static bool ReleaseFileName(debReleaseIndex const * const That, std::string &ReleaseFile)/*{{{*/
+{
+ ReleaseFile = That->MetaIndexFile("InRelease");
+ bool releaseExists = false;
+ if (FileExists(ReleaseFile) == true)
+ releaseExists = true;
+ else
+ {
+ ReleaseFile = That->MetaIndexFile("Release");
+ if (FileExists(ReleaseFile))
+ releaseExists = true;
+ }
+ return releaseExists;
}
+ /*}}}*/
+bool debReleaseIndex::Merge(pkgCacheGenerator &Gen,OpProgress * /*Prog*/) const/*{{{*/
+{
+ std::string ReleaseFile;
+ bool const releaseExists = ReleaseFileName(this, ReleaseFile);
-void debReleaseIndex::PushSectionEntry(string const &Arch, const debSectionEntry *Entry) {
- ArchEntries[Arch].push_back(Entry);
-}
+ ::URI Tmp(URI);
+ if (Gen.SelectReleaseFile(ReleaseFile, Tmp.Host) == false)
+ return _error->Error("Problem with SelectReleaseFile %s", ReleaseFile.c_str());
-void debReleaseIndex::PushSectionEntry(const debSectionEntry *Entry) {
- if (Entry->IsSrc == true)
- PushSectionEntry("source", Entry);
- else {
- for (map<string, vector<const debSectionEntry *> >::iterator a = ArchEntries.begin();
- a != ArchEntries.end(); ++a) {
- a->second.push_back(Entry);
- }
- }
-}
+ if (releaseExists == false)
+ return true;
-debReleaseIndex::debSectionEntry::debSectionEntry (string const &Section,
- bool const &IsSrc): Section(Section), IsSrc(IsSrc)
-{}
+ FileFd Rel;
+ // Beware: The 'Release' file might be clearsigned in case the
+ // signature for an 'InRelease' file couldn't be checked
+ if (OpenMaybeClearSignedFile(ReleaseFile, Rel) == false)
+ return false;
+ if (_error->PendingError() == true)
+ return false;
-class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type
+ // Store the IMS information
+ pkgCache::RlsFileIterator File = Gen.GetCurRlsFile();
+ pkgCacheGenerator::Dynamic<pkgCache::RlsFileIterator> DynFile(File);
+ // Rel can't be used as this is potentially a temporary file
+ struct stat Buf;
+ if (stat(ReleaseFile.c_str(), &Buf) != 0)
+ return _error->Errno("fstat", "Unable to stat file %s", ReleaseFile.c_str());
+ File->Size = Buf.st_size;
+ File->mtime = Buf.st_mtime;
+
+ pkgTagFile TagFile(&Rel, Rel.Size());
+ pkgTagSection Section;
+ if (_error->PendingError() == true || TagFile.Step(Section) == false)
+ return false;
+
+ std::string data;
+ #define APT_INRELEASE(TYPE, TAG, STORE) \
+ data = Section.FindS(TAG); \
+ if (data.empty() == false) \
+ { \
+ map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::TYPE, data); \
+ STORE = storage; \
+ }
+ APT_INRELEASE(MIXED, "Suite", File->Archive)
+ APT_INRELEASE(VERSIONNUMBER, "Version", File->Version)
+ APT_INRELEASE(MIXED, "Origin", File->Origin)
+ APT_INRELEASE(MIXED, "Codename", File->Codename)
+ APT_INRELEASE(MIXED, "Label", File->Label)
+ #undef APT_INRELEASE
+ Section.FindFlag("NotAutomatic", File->Flags, pkgCache::Flag::NotAutomatic);
+ Section.FindFlag("ButAutomaticUpgrades", File->Flags, pkgCache::Flag::ButAutomaticUpgrades);
+
+ return !_error->PendingError();
+}
+ /*}}}*/
+// ReleaseIndex::FindInCache - Find this index /*{{{*/
+pkgCache::RlsFileIterator debReleaseIndex::FindInCache(pkgCache &Cache, bool const ModifyCheck) const
{
- protected:
+ std::string ReleaseFile;
+ bool const releaseExists = ReleaseFileName(this, ReleaseFile);
- bool CreateItemInternal(vector<metaIndex *> &List, string const &URI,
- string const &Dist, string const &Section,
- bool const &IsSrc, map<string, string> const &Options) const
+ pkgCache::RlsFileIterator File = Cache.RlsFileBegin();
+ for (; File.end() == false; ++File)
{
- // parse arch=, arch+= and arch-= settings
- map<string, string>::const_iterator arch = Options.find("arch");
- vector<string> Archs;
- if (arch != Options.end())
- Archs = VectorizeString(arch->second, ',');
- else
- Archs = APT::Configuration::getArchitectures();
+ if (File->FileName == 0 || ReleaseFile != File.FileName())
+ continue;
- if ((arch = Options.find("arch+")) != Options.end())
+ // empty means the file does not exist by "design"
+ if (ModifyCheck == false || (releaseExists == false && File->Size == 0))
+ return File;
+
+ struct stat St;
+ if (stat(File.FileName(),&St) != 0)
{
- std::vector<std::string> const plusArch = VectorizeString(arch->second, ',');
- for (std::vector<std::string>::const_iterator plus = plusArch.begin(); plus != plusArch.end(); ++plus)
- if (std::find(Archs.begin(), Archs.end(), *plus) == Archs.end())
- Archs.push_back(*plus);
+ if (_config->FindB("Debug::pkgCacheGen", false))
+ std::clog << "ReleaseIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
+ return pkgCache::RlsFileIterator(Cache);
}
- if ((arch = Options.find("arch-")) != Options.end())
+ if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
{
- std::vector<std::string> const minusArch = VectorizeString(arch->second, ',');
- for (std::vector<std::string>::const_iterator minus = minusArch.begin(); minus != minusArch.end(); ++minus)
- {
- std::vector<std::string>::iterator kill = std::find(Archs.begin(), Archs.end(), *minus);
- if (kill != Archs.end())
- Archs.erase(kill);
- }
+ if (_config->FindB("Debug::pkgCacheGen", false))
+ std::clog << "ReleaseIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+ << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+ << ") doesn't match for " << File.FileName() << std::endl;
+ return pkgCache::RlsFileIterator(Cache);
}
+ return File;
+ }
- map<string, string>::const_iterator const trusted = Options.find("trusted");
+ return File;
+}
+ /*}}}*/
- for (vector<metaIndex *>::const_iterator I = List.begin();
+static std::vector<std::string> parsePlusMinusOptions(std::string const &Name, /*{{{*/
+ std::map<std::string, std::string> const &Options, std::vector<std::string> const &defaultValues)
+{
+ std::map<std::string, std::string>::const_iterator val = Options.find(Name);
+ std::vector<std::string> Values;
+ if (val != Options.end())
+ Values = VectorizeString(val->second, ',');
+ else
+ Values = defaultValues;
+
+ if ((val = Options.find(Name + "+")) != Options.end())
+ {
+ std::vector<std::string> const plusArch = VectorizeString(val->second, ',');
+ for (std::vector<std::string>::const_iterator plus = plusArch.begin(); plus != plusArch.end(); ++plus)
+ if (std::find(Values.begin(), Values.end(), *plus) == Values.end())
+ Values.push_back(*plus);
+ }
+ if ((val = Options.find(Name + "-")) != Options.end())
+ {
+ std::vector<std::string> const minusArch = VectorizeString(val->second, ',');
+ for (std::vector<std::string>::const_iterator minus = minusArch.begin(); minus != minusArch.end(); ++minus)
+ {
+ std::vector<std::string>::iterator kill = std::find(Values.begin(), Values.end(), *minus);
+ if (kill != Values.end())
+ Values.erase(kill);
+ }
+ }
+ return Values;
+}
+ /*}}}*/
+class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
+{
+ metaIndex::TriState GetTriStateOption(std::map<std::string, std::string>const &Options, char const * const name) const
+ {
+ std::map<std::string, std::string>::const_iterator const opt = Options.find(name);
+ if (opt != Options.end())
+ return StringToBool(opt->second, false) ? metaIndex::TRI_YES : metaIndex::TRI_NO;
+ return metaIndex::TRI_DONTCARE;
+ }
+
+ time_t GetTimeOption(std::map<std::string, std::string>const &Options, char const * const name) const
+ {
+ std::map<std::string, std::string>::const_iterator const opt = Options.find(name);
+ if (opt == Options.end())
+ return 0;
+ return strtoull(opt->second.c_str(), NULL, 10);
+ }
+
+ protected:
+
+ bool CreateItemInternal(std::vector<metaIndex *> &List, std::string const &URI,
+ std::string const &Dist, std::string const &Section,
+ bool const &IsSrc, std::map<std::string, std::string> const &Options) const
+ {
+ debReleaseIndex *Deb = NULL;
+ for (std::vector<metaIndex *>::const_iterator I = List.begin();
I != List.end(); ++I)
{
// We only worry about debian entries here
if (strcmp((*I)->GetType(), "deb") != 0)
continue;
- debReleaseIndex *Deb = (debReleaseIndex *) (*I);
- if (trusted != Options.end())
- Deb->SetTrusted(StringToBool(trusted->second, false));
-
/* 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)
+ if ((*I)->GetURI() == URI && (*I)->GetDist() == Dist)
{
- if (IsSrc == true)
- Deb->PushSectionEntry("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
- else
- {
- if (Dist[Dist.size() - 1] == '/')
- Deb->PushSectionEntry("any", new debReleaseIndex::debSectionEntry(Section, IsSrc));
- else
- Deb->PushSectionEntry(Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
- }
- return true;
+ Deb = dynamic_cast<debReleaseIndex*>(*I);
+ if (Deb != NULL)
+ break;
}
}
// No currently created Release file indexes this entry, so we create a new one.
- debReleaseIndex *Deb;
- if (trusted != Options.end())
- Deb = new debReleaseIndex(URI, Dist, StringToBool(trusted->second, false));
- else
+ if (Deb == NULL)
+ {
Deb = new debReleaseIndex(URI, Dist);
+ List.push_back(Deb);
+ }
- if (IsSrc == true)
- Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ Deb->AddComponent(
+ IsSrc,
+ Section,
+ parsePlusMinusOptions("target", Options, _config->FindVector(std::string("Acquire::IndexTargets::") + Name, "", true)),
+ parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()),
+ parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true))
+ );
+
+ if (Deb->SetTrusted(GetTriStateOption(Options, "trusted")) == false ||
+ Deb->SetCheckValidUntil(GetTriStateOption(Options, "check-valid-until")) == false ||
+ Deb->SetValidUntilMax(GetTimeOption(Options, "valid-until-max")) == false ||
+ Deb->SetValidUntilMin(GetTimeOption(Options, "valid-until-min")) == false)
+ return false;
+
+ std::map<std::string, std::string>::const_iterator const signedby = Options.find("signed-by");
+ if (signedby == Options.end())
+ {
+ if (Deb->SetSignedBy("") == false)
+ return false;
+ }
else
{
- if (Dist[Dist.size() - 1] == '/')
- Deb->PushSectionEntry ("any", new debReleaseIndex::debSectionEntry(Section, IsSrc));
- else
- Deb->PushSectionEntry (Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ if (Deb->SetSignedBy(signedby->second) == false)
+ return false;
}
- List.push_back(Deb);
+
return true;
}
-};
-debDebFileMetaIndex::debDebFileMetaIndex(std::string const &DebFile)
- : metaIndex(DebFile, "local-uri", "deb-dist"), DebFile(DebFile)
-{
- DebIndex = new debDebPkgFileIndex(DebFile);
- Indexes = new vector<pkgIndexFile *>();
- Indexes->push_back(DebIndex);
-}
-
-
-class APT_HIDDEN debSLTypeDeb : public debSLTypeDebian
+ debSLTypeDebian(char const * const Name, char const * const Label) : Type(Name, Label)
+ {
+ }
+};
+ /*}}}*/
+class APT_HIDDEN debSLTypeDeb : public debSLTypeDebian /*{{{*/
{
public:
- bool CreateItem(vector<metaIndex *> &List, string const &URI,
- string const &Dist, string const &Section,
- std::map<string, string> const &Options) const
+ bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI,
+ std::string const &Dist, std::string const &Section,
+ std::map<std::string, std::string> const &Options) const APT_OVERRIDE
{
return CreateItemInternal(List, URI, Dist, Section, false, Options);
}
- debSLTypeDeb()
+ debSLTypeDeb() : debSLTypeDebian("deb", "Debian binary tree")
{
- Name = "deb";
- Label = "Standard Debian binary tree";
- }
+ }
};
-
-class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian
+ /*}}}*/
+class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian /*{{{*/
{
public:
- bool CreateItem(vector<metaIndex *> &List, string const &URI,
- string const &Dist, string const &Section,
- std::map<string, string> const &Options) const
+ bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI,
+ std::string const &Dist, std::string const &Section,
+ std::map<std::string, std::string> const &Options) const APT_OVERRIDE
{
return CreateItemInternal(List, URI, Dist, Section, true, Options);
}
-
- debSLTypeDebSrc()
- {
- Name = "deb-src";
- Label = "Standard Debian source tree";
- }
-};
-class APT_HIDDEN debSLTypeDebFile : public pkgSourceList::Type
-{
- public:
-
- bool CreateItem(vector<metaIndex *> &List, string const &URI,
- string const &/*Dist*/, string const &/*Section*/,
- std::map<string, string> const &/*Options*/) const
+ debSLTypeDebSrc() : debSLTypeDebian("deb-src", "Debian source tree")
{
- metaIndex *mi = new debDebFileMetaIndex(URI);
- List.push_back(mi);
- return true;
}
-
- debSLTypeDebFile()
- {
- Name = "deb-file";
- Label = "Debian Deb File";
- }
};
+ /*}}}*/
APT_HIDDEN debSLTypeDeb _apt_DebType;
APT_HIDDEN debSLTypeDebSrc _apt_DebSrcType;
-APT_HIDDEN debSLTypeDebFile _apt_DebFileType;
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index 94d005760..e93959a21 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -1,4 +1,3 @@
-// ijones, walters
#ifndef PKGLIB_DEBMETAINDEX_H
#define PKGLIB_DEBMETAINDEX_H
@@ -18,83 +17,52 @@
class pkgAcquire;
class pkgIndexFile;
-class debDebPkgFileIndex;
class IndexTarget;
+class pkgCacheGenerator;
+class OpProgress;
+class debReleaseIndexPrivate;
-class APT_HIDDEN debReleaseIndex : public metaIndex {
- public:
-
- class debSectionEntry
- {
- public:
- debSectionEntry (std::string const &Section, bool const &IsSrc);
- std::string const Section;
- bool const IsSrc;
- };
-
- private:
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
- std::map<std::string, std::vector<debSectionEntry const*> > ArchEntries;
- enum APT_HIDDEN { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
+class APT_HIDDEN debReleaseIndex : public metaIndex
+{
+ debReleaseIndexPrivate * const d;
+ APT_HIDDEN bool parseSumData(const char *&Start, const char *End, std::string &Name,
+ std::string &Hash, unsigned long long &Size);
public:
+ APT_HIDDEN std::string MetaIndexInfo(const char *Type) const;
+ APT_HIDDEN std::string MetaIndexFile(const char *Types) const;
+ APT_HIDDEN std::string MetaIndexURI(const char *Type) const;
+
debReleaseIndex(std::string const &URI, std::string const &Dist);
debReleaseIndex(std::string const &URI, std::string const &Dist, bool const Trusted);
virtual ~debReleaseIndex();
- virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
- virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
- std::vector <IndexTarget *>* ComputeIndexTargets() const;
- std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const;
+ virtual std::string ArchiveURI(std::string const &File) const APT_OVERRIDE {return URI + File;};
+ virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) APT_OVERRIDE;
+ virtual std::vector<IndexTarget> GetIndexTargets() const APT_OVERRIDE;
- std::string MetaIndexInfo(const char *Type) const;
- std::string MetaIndexFile(const char *Types) const;
- std::string MetaIndexURI(const char *Type) const;
+ virtual std::string Describe() const APT_OVERRIDE;
+ virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const APT_OVERRIDE;
+ virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE;
-#if APT_PKG_ABI >= 413
- virtual
-#endif
- std::string LocalFileName() const;
-
- std::string IndexURI(const char *Type, std::string const &Section, std::string const &Arch="native") const;
- std::string IndexURISuffix(const char *Type, std::string const &Section, std::string const &Arch="native") const;
- std::string SourceIndexURI(const char *Type, const std::string &Section) const;
- std::string SourceIndexURISuffix(const char *Type, const std::string &Section) const;
- std::string TranslationIndexURI(const char *Type, const std::string &Section) const;
- std::string TranslationIndexURISuffix(const char *Type, const std::string &Section) const;
- virtual std::vector <pkgIndexFile *> *GetIndexFiles();
-
- void SetTrusted(bool const Trusted);
- virtual bool IsTrusted() const;
-
- void PushSectionEntry(std::vector<std::string> const &Archs, const debSectionEntry *Entry);
- void PushSectionEntry(std::string const &Arch, const debSectionEntry *Entry);
- void PushSectionEntry(const debSectionEntry *Entry);
-};
+ virtual bool Load(std::string const &Filename, std::string * const ErrorText) APT_OVERRIDE;
+ virtual metaIndex * UnloadedClone() const APT_OVERRIDE;
-class APT_HIDDEN debDebFileMetaIndex : public metaIndex
-{
- private:
- std::string DebFile;
- debDebPkgFileIndex *DebIndex;
- public:
- virtual std::string ArchiveURI(std::string const& /*File*/) const {
- return DebFile;
- }
- virtual bool GetIndexes(pkgAcquire* /*Owner*/, const bool& /*GetAll=false*/) const {
- return true;
- }
- virtual std::vector<pkgIndexFile *> *GetIndexFiles() {
- return Indexes;
- }
- virtual bool IsTrusted() const {
- return true;
- }
- debDebFileMetaIndex(std::string const &DebFile);
- virtual ~debDebFileMetaIndex() {};
+ virtual std::vector <pkgIndexFile *> *GetIndexFiles() APT_OVERRIDE;
+
+ bool SetTrusted(TriState const Trusted);
+ bool SetCheckValidUntil(TriState const Trusted);
+ bool SetValidUntilMin(time_t const Valid);
+ bool SetValidUntilMax(time_t const Valid);
+ bool SetSignedBy(std::string const &SignedBy);
+
+ virtual bool IsTrusted() const APT_OVERRIDE;
+ void AddComponent(bool const isSrc, std::string const &Name,
+ std::vector<std::string> const &Targets,
+ std::vector<std::string> const &Architectures,
+ std::vector<std::string> Languages);
};
#endif
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 335bcfda0..d78a7e2e0 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -34,7 +34,7 @@ using std::string;
// RecordParser::debRecordParser - Constructor /*{{{*/
debRecordParser::debRecordParser(string FileName,pkgCache &Cache) :
- debRecordParserBase(), File(FileName, FileFd::ReadOnly, FileFd::Extension),
+ debRecordParserBase(), d(NULL), File(FileName, FileFd::ReadOnly, FileFd::Extension),
Tags(&File, std::max(Cache.Head().MaxVerFileSize, Cache.Head().MaxDescFileSize) + 200)
{
}
@@ -42,15 +42,20 @@ debRecordParser::debRecordParser(string FileName,pkgCache &Cache) :
// RecordParser::Jump - Jump to a specific record /*{{{*/
bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
{
+ if (Ver.end() == true)
+ return false;
return Tags.Jump(Section,Ver->Offset);
}
bool debRecordParser::Jump(pkgCache::DescFileIterator const &Desc)
{
+ if (Desc.end() == true)
+ return false;
return Tags.Jump(Section,Desc->Offset);
}
/*}}}*/
debRecordParser::~debRecordParser() {}
+debRecordParserBase::debRecordParserBase() : Parser(), d(NULL) {}
// RecordParserBase::FileName - Return the archive filename on the site /*{{{*/
string debRecordParserBase::FileName()
{
@@ -207,3 +212,9 @@ bool debDebFileRecordParser::LoadContent()
return _error->Error(_("Unable to parse package file %s (%d)"), debFileName.c_str(), 3);
return true;
}
+bool debDebFileRecordParser::Jump(pkgCache::VerFileIterator const &) { return LoadContent(); }
+bool debDebFileRecordParser::Jump(pkgCache::DescFileIterator const &) { return LoadContent(); }
+std::string debDebFileRecordParser::FileName() { return debFileName; }
+
+debDebFileRecordParser::debDebFileRecordParser(std::string FileName) : debRecordParserBase(), d(NULL), debFileName(FileName) {}
+debDebFileRecordParser::~debDebFileRecordParser() {}
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index 38e071940..7fc82a88d 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -27,41 +27,43 @@
class APT_HIDDEN debRecordParserBase : public pkgRecords::Parser
{
+ void * const d;
protected:
pkgTagSection Section;
public:
// These refer to the archive file for the Version
- virtual std::string FileName();
- virtual std::string SourcePkg();
- virtual std::string SourceVer();
+ virtual std::string FileName() APT_OVERRIDE;
+ virtual std::string SourcePkg() APT_OVERRIDE;
+ virtual std::string SourceVer() APT_OVERRIDE;
- virtual HashStringList Hashes() const;
+ virtual HashStringList Hashes() const APT_OVERRIDE;
// These are some general stats about the package
- virtual std::string Maintainer();
- virtual std::string ShortDesc(std::string const &lang);
- virtual std::string LongDesc(std::string const &lang);
- virtual std::string Name();
- virtual std::string Homepage();
+ virtual std::string Maintainer() APT_OVERRIDE;
+ virtual std::string ShortDesc(std::string const &lang) APT_OVERRIDE;
+ virtual std::string LongDesc(std::string const &lang) APT_OVERRIDE;
+ virtual std::string Name() APT_OVERRIDE;
+ virtual std::string Homepage() APT_OVERRIDE;
// An arbitrary custom field
- virtual std::string RecordField(const char *fieldName);
+ virtual std::string RecordField(const char *fieldName) APT_OVERRIDE;
- virtual void GetRec(const char *&Start,const char *&Stop);
+ virtual void GetRec(const char *&Start,const char *&Stop) APT_OVERRIDE;
- debRecordParserBase() : Parser() {}
+ debRecordParserBase();
virtual ~debRecordParserBase();
};
class APT_HIDDEN debRecordParser : public debRecordParserBase
{
+ void * const d;
protected:
FileFd File;
pkgTagFile Tags;
- virtual bool Jump(pkgCache::VerFileIterator const &Ver);
- virtual bool Jump(pkgCache::DescFileIterator const &Desc);
+ virtual bool Jump(pkgCache::VerFileIterator const &Ver) APT_OVERRIDE;
+ virtual bool Jump(pkgCache::DescFileIterator const &Desc) APT_OVERRIDE;
public:
debRecordParser(std::string FileName,pkgCache &Cache);
@@ -71,20 +73,21 @@ class APT_HIDDEN debRecordParser : public debRecordParserBase
// custom record parser that reads deb files directly
class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
{
+ void * const d;
std::string debFileName;
std::string controlContent;
APT_HIDDEN bool LoadContent();
protected:
// single file files, so no jumping whatsoever
- bool Jump(pkgCache::VerFileIterator const &) { return LoadContent(); }
- bool Jump(pkgCache::DescFileIterator const &) { return LoadContent(); }
+ bool Jump(pkgCache::VerFileIterator const &) APT_OVERRIDE;
+ bool Jump(pkgCache::DescFileIterator const &) APT_OVERRIDE;
public:
- virtual std::string FileName() { return debFileName; }
+ virtual std::string FileName() APT_OVERRIDE;
- debDebFileRecordParser(std::string FileName)
- : debRecordParserBase(), debFileName(FileName) {};
+ debDebFileRecordParser(std::string FileName);
+ virtual ~debDebFileRecordParser();
};
#endif
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index ca6d09896..9404b6421 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -32,6 +32,10 @@
using std::max;
using std::string;
+debSrcRecordParser::debSrcRecordParser(std::string const &File,pkgIndexFile const *Index)
+ : Parser(Index), d(NULL), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400),
+ iOffset(0), Buffer(NULL) {}
+
// SrcRecordParser::Binaries - Return the binaries field /*{{{*/
// ---------------------------------------------------------------------
/* This member parses the binaries field into a pair of class arrays and
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index cd246d624..89134af5f 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -24,7 +24,7 @@ class pkgIndexFile;
class APT_HIDDEN debSrcRecordParser : public pkgSrcRecords::Parser
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
protected:
FileFd Fd;
@@ -36,29 +36,27 @@ class APT_HIDDEN debSrcRecordParser : public pkgSrcRecords::Parser
public:
- virtual bool Restart() {return Jump(0);};
- virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
- virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
+ virtual bool Restart() APT_OVERRIDE {return Jump(0);};
+ virtual bool Step() APT_OVERRIDE {iOffset = Tags.Offset(); return Tags.Step(Sect);};
+ virtual bool Jump(unsigned long const &Off) APT_OVERRIDE {iOffset = Off; return Tags.Jump(Sect,Off);};
- virtual std::string Package() const {return Sect.FindS("Package");};
- virtual std::string Version() const {return Sect.FindS("Version");};
- virtual std::string Maintainer() const {return Sect.FindS("Maintainer");};
- virtual std::string Section() const {return Sect.FindS("Section");};
- virtual const char **Binaries();
- virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true);
- virtual unsigned long Offset() {return iOffset;};
- virtual std::string AsStr()
+ virtual std::string Package() const APT_OVERRIDE {return Sect.FindS("Package");};
+ virtual std::string Version() const APT_OVERRIDE {return Sect.FindS("Version");};
+ virtual std::string Maintainer() const APT_OVERRIDE {return Sect.FindS("Maintainer");};
+ virtual std::string Section() const APT_OVERRIDE {return Sect.FindS("Section");};
+ virtual const char **Binaries() APT_OVERRIDE;
+ virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) APT_OVERRIDE;
+ virtual unsigned long Offset() APT_OVERRIDE {return iOffset;};
+ virtual std::string AsStr() APT_OVERRIDE
{
const char *Start=0,*Stop=0;
Sect.GetSection(Start,Stop);
return std::string(Start,Stop);
};
- virtual bool Files(std::vector<pkgSrcRecords::File> &F);
+ virtual bool Files(std::vector<pkgSrcRecords::File> &F) APT_OVERRIDE;
bool Files2(std::vector<pkgSrcRecords::File2> &F);
- debSrcRecordParser(std::string const &File,pkgIndexFile const *Index)
- : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400),
- iOffset(0), Buffer(NULL) {}
+ debSrcRecordParser(std::string const &File,pkgIndexFile const *Index);
virtual ~debSrcRecordParser();
};
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 9a5da9da1..465e13b9e 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -53,11 +53,8 @@ public:
// System::debSystem - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debSystem::debSystem()
+debSystem::debSystem() : pkgSystem("Debian dpkg interface", &debVS), d(new debSystemPrivate())
{
- d = new debSystemPrivate();
- Label = "Debian dpkg interface";
- VS = &debVS;
}
/*}}}*/
// System::~debSystem - Destructor /*{{{*/
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 226cd60bf..aed77520e 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -28,20 +28,20 @@ class debStatusIndex;
class debSystem : public pkgSystem
{
// private d-pointer
- debSystemPrivate *d;
+ debSystemPrivate * const d;
APT_HIDDEN bool CheckUpdates();
public:
- virtual bool Lock();
- virtual bool UnLock(bool NoErrors = false);
- virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const;
- virtual bool Initialize(Configuration &Cnf);
- virtual bool ArchiveSupported(const char *Type);
- virtual signed Score(Configuration const &Cnf);
- virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List);
+ virtual bool Lock() APT_OVERRIDE;
+ virtual bool UnLock(bool NoErrors = false) APT_OVERRIDE;
+ virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_OVERRIDE;
+ virtual bool Initialize(Configuration &Cnf) APT_OVERRIDE;
+ virtual bool ArchiveSupported(const char *Type) APT_OVERRIDE;
+ virtual signed Score(Configuration const &Cnf) APT_OVERRIDE;
+ virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) APT_OVERRIDE;
virtual bool FindIndex(pkgCache::PkgFileIterator File,
- pkgIndexFile *&Found) const;
+ pkgIndexFile *&Found) const APT_OVERRIDE;
debSystem();
virtual ~debSystem();
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index a5eacb7f5..48462c6a2 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -16,7 +16,6 @@
#include <apt-pkg/pkgcache.h>
#include <string.h>
-#include <string>
#include <stdlib.h>
#include <ctype.h>
/*}}}*/
@@ -34,29 +33,26 @@ debVersioningSystem::debVersioningSystem()
// debVS::CmpFragment - Compare versions /*{{{*/
// ---------------------------------------------------------------------
-/* This compares a fragment of the version. This is a slightly adapted
- version of what dpkg uses. */
-#define order(x) ((x) == '~' ? -1 \
- : isdigit((x)) ? 0 \
- : !(x) ? 0 \
- : isalpha((x)) ? (x) \
- : (x) + 256)
-int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
- const char *B,const char *BEnd)
+/* This compares a fragment of the version. This is a slightly adapted
+ version of what dpkg uses in dpkg/lib/dpkg/version.c.
+ In particular, the a | b = NULL check is removed as we check this in the
+ caller, we use an explicit end for a | b strings and we check ~ explicit. */
+static int order(char c)
{
- if (A >= AEnd && B >= BEnd)
+ if (isdigit(c))
return 0;
- if (A >= AEnd)
- {
- if (*B == '~') return 1;
+ else if (isalpha(c))
+ return c;
+ else if (c == '~')
return -1;
- }
- if (B >= BEnd)
- {
- if (*A == '~') return -1;
- return 1;
- }
-
+ else if (c)
+ return c + 256;
+ else
+ return 0;
+}
+int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
+ const char *B,const char *BEnd)
+{
/* Iterate over the whole string
What this does is to split the whole string into groups of
numeric and non numeric portions. For instance:
@@ -77,19 +73,19 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd,
int rc = order(*rhs);
if (vc != rc)
return vc - rc;
- lhs++; rhs++;
+ ++lhs; ++rhs;
}
while (*lhs == '0')
- lhs++;
+ ++lhs;
while (*rhs == '0')
- rhs++;
+ ++rhs;
while (isdigit(*lhs) && isdigit(*rhs))
{
if (!first_diff)
first_diff = *lhs - *rhs;
- lhs++;
- rhs++;
+ ++lhs;
+ ++rhs;
}
if (isdigit(*lhs))
diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h
index 434ff4a2e..db70c8797 100644
--- a/apt-pkg/deb/debversion.h
+++ b/apt-pkg/deb/debversion.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debversion.h,v 1.3 2001/05/03 05:25:04 jgg Exp $
/* ######################################################################
Debian Version - Versioning system for Debian
@@ -25,14 +24,14 @@ class debVersioningSystem : public pkgVersioningSystem
// Compare versions..
virtual int DoCmpVersion(const char *A,const char *Aend,
- const char *B,const char *Bend) APT_PURE;
- virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) APT_PURE;
+ const char *B,const char *Bend) APT_OVERRIDE APT_PURE;
+ virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) APT_OVERRIDE APT_PURE;
virtual APT_PURE int DoCmpReleaseVer(const char *A,const char *Aend,
- const char *B,const char *Bend)
+ const char *B,const char *Bend) APT_OVERRIDE
{
return DoCmpVersion(A,Aend,B,Bend);
}
- virtual std::string UpstreamVersion(const char *A);
+ virtual std::string UpstreamVersion(const char *A) APT_OVERRIDE;
debVersioningSystem();
};
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index a7a66c75d..6ae85d2ea 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -18,7 +18,6 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/install-progress.h>
#include <apt-pkg/packagemanager.h>
-#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/macros.h>
@@ -27,7 +26,6 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
-#include <pty.h>
#include <pwd.h>
#include <signal.h>
#include <stddef.h>
@@ -205,8 +203,10 @@ pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
for (pkgCache::VerFileIterator Vf = Ver.FileList(); Vf.end() == false; ++Vf)
for (pkgCache::PkgFileIterator F = Vf.File(); F.end() == false; ++F)
- if (F->Archive != 0 && strcmp(F.Archive(), "now") == 0)
+ {
+ if (F.Archive() != 0 && strcmp(F.Archive(), "now") == 0)
return Ver;
+ }
return Ver;
}
/*}}}*/
@@ -214,10 +214,9 @@ pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
// DPkgPM::pkgDPkgPM - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache)
- : pkgPackageManager(Cache), pkgFailures(0), PackagesDone(0), PackagesTotal(0)
+pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache)
+ : pkgPackageManager(Cache),d(new pkgDPkgPMPrivate()), pkgFailures(0), PackagesDone(0), PackagesTotal(0)
{
- d = new pkgDPkgPMPrivate();
}
/*}}}*/
// DPkgPM::pkgDPkgPM - Destructor /*{{{*/
@@ -1483,6 +1482,10 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
a != Args.end(); ++a)
clog << *a << ' ';
clog << endl;
+ for (std::vector<char *>::const_iterator p = Packages.begin();
+ p != Packages.end(); ++p)
+ free(*p);
+ Packages.clear();
continue;
}
Args.push_back(NULL);
@@ -1540,9 +1543,6 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
_exit(100);
}
- /* No Job Control Stop Env is a magic dpkg var that prevents it
- from using sigstop */
- putenv((char *)"DPKG_NO_TSTP=yes");
execvp(Args[0], (char**) &Args[0]);
cerr << "Could not exec dpkg!" << endl;
_exit(100);
@@ -1841,16 +1841,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
time_t now = time(NULL);
fprintf(report, "Date: %s" , ctime(&now));
fprintf(report, "Package: %s %s\n", pkgname.c_str(), pkgver.c_str());
-#if APT_PKG_ABI >= 413
fprintf(report, "SourcePackage: %s\n", Ver.SourcePkgName());
-#else
- pkgRecords Recs(Cache);
- pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
- std::string srcpkgname = Parse.SourcePkg();
- if(srcpkgname.empty())
- srcpkgname = pkgname;
- fprintf(report, "SourcePackage: %s\n", srcpkgname.c_str());
-#endif
fprintf(report, "ErrorMessage:\n %s\n", errormsg);
// ensure that the log is flushed
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 2a6e7e004..82c1bef5d 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -37,7 +37,7 @@ class pkgDPkgPMPrivate;
class pkgDPkgPM : public pkgPackageManager
{
private:
- pkgDPkgPMPrivate *d;
+ pkgDPkgPMPrivate * const d;
/** \brief record the disappear action and handle accordingly
@@ -120,14 +120,14 @@ class pkgDPkgPM : public pkgPackageManager
void ProcessDpkgStatusLine(char *line);
// The Actuall installation implementation
- virtual bool Install(PkgIterator Pkg,std::string File);
- virtual bool Configure(PkgIterator Pkg);
- virtual bool Remove(PkgIterator Pkg,bool Purge = false);
+ virtual bool Install(PkgIterator Pkg,std::string File) APT_OVERRIDE;
+ virtual bool Configure(PkgIterator Pkg) APT_OVERRIDE;
+ virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE;
- virtual bool Go(APT::Progress::PackageManager *progress);
- virtual bool Go(int StatusFd=-1);
+ virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE;
+ virtual bool Go(int StatusFd=-1) APT_OVERRIDE;
- virtual void Reset();
+ virtual void Reset() APT_OVERRIDE;
public: