summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc220
-rw-r--r--apt-pkg/deb/debindexfile.h95
-rw-r--r--apt-pkg/deb/deblistparser.cc165
-rw-r--r--apt-pkg/deb/deblistparser.h46
-rw-r--r--apt-pkg/deb/debmetaindex.cc86
-rw-r--r--apt-pkg/deb/debmetaindex.h36
-rw-r--r--apt-pkg/deb/debrecords.cc103
-rw-r--r--apt-pkg/deb/debrecords.h34
-rw-r--r--apt-pkg/deb/debsrcrecords.cc45
-rw-r--r--apt-pkg/deb/debsrcrecords.h9
-rw-r--r--apt-pkg/deb/debsystem.cc2
-rw-r--r--apt-pkg/deb/debsystem.h2
-rw-r--r--apt-pkg/deb/dpkgpm.cc42
-rw-r--r--apt-pkg/deb/dpkgpm.h15
14 files changed, 623 insertions, 277 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 5b4289e92..cecfe41a9 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -30,6 +30,7 @@
#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>
@@ -130,7 +131,7 @@ string debSourcesIndex::Info(const char *Type) const
// SourcesIndex::Index* - Return the URI to the index files /*{{{*/
// ---------------------------------------------------------------------
/* */
-inline string debSourcesIndex::IndexFile(const char *Type) const
+string debSourcesIndex::IndexFile(const char *Type) const
{
string s = URItoFileName(IndexURI(Type));
@@ -264,7 +265,7 @@ string debPackagesIndex::Info(const char *Type) const
// PackagesIndex::Index* - Return the URI to the index files /*{{{*/
// ---------------------------------------------------------------------
/* */
-inline string debPackagesIndex::IndexFile(const char *Type) const
+string debPackagesIndex::IndexFile(const char *Type) const
{
string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
@@ -420,7 +421,7 @@ debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section
// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
// ---------------------------------------------------------------------
/* */
-inline string debTranslationsIndex::IndexFile(const char *Type) const
+string debTranslationsIndex::IndexFile(const char *Type) const
{
string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
@@ -451,19 +452,6 @@ string debTranslationsIndex::IndexURI(const char *Type) const
return Res;
}
/*}}}*/
-// TranslationsIndex::GetIndexes - Fetch the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
-{
- string const TranslationFile = string("Translation-").append(Language);
- new pkgAcqIndexTrans(Owner, IndexURI(Language),
- Info(TranslationFile.c_str()),
- TranslationFile);
-
- return true;
-}
- /*}}}*/
// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
// ---------------------------------------------------------------------
/* This should help the user find the index in the sources.list and
@@ -634,7 +622,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
CFile->Size = Pkg.FileSize();
CFile->mtime = Pkg.ModificationTime();
- map_ptrloc const storage = Gen.WriteUniqString("now");
+ map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::MIXED, "now");
CFile->Archive = storage;
if (Gen.MergeList(Parser) == false)
@@ -683,14 +671,144 @@ APT_CONST bool debStatusIndex::Exists() const
}
/*}}}*/
+// 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
+{
+ return FileExists(DebFile);
+}
+bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
+{
+ if(Prog)
+ Prog->SubProgress(0, "Reading deb file");
+
+ // get the control data out of the deb file vid dpkg -I
+ // ... can I haz libdpkg?
+ Configuration::Item const *Opts = _config->Tree("DPkg::Options");
+ std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg");
+ std::vector<const char *> Args;
+ Args.push_back(dpkg.c_str());
+ if (Opts != 0)
+ {
+ Opts = Opts->Child;
+ for (; Opts != 0; Opts = Opts->Next)
+ {
+ if (Opts->Value.empty() == true)
+ continue;
+ Args.push_back(Opts->Value.c_str());
+ }
+ }
+ Args.push_back("-I");
+ Args.push_back(DebFile.c_str());
+ Args.push_back("control");
+ Args.push_back(NULL);
+ FileFd PipeFd;
+ pid_t Child;
+ if(Popen((const char**)&Args[0], PipeFd, Child, FileFd::ReadOnly) == false)
+ return _error->Error("Popen failed");
+ // FIXME: static buffer
+ char buf[8*1024];
+ unsigned long long n = 0;
+ if(PipeFd.Read(buf, sizeof(buf)-1, &n) == false)
+ return _error->Errno("read", "Failed to read dpkg pipe");
+ ExecWait(Child, "Popen");
+
+ // now write the control data to a tempfile
+ SPtr<FileFd> DebControl = GetTempFile("deb-file-" + flNotDir(DebFile));
+ if(DebControl == NULL)
+ return false;
+ DebControl->Write(buf, n);
+ // append size of the file
+ FileFd Fd(DebFile, FileFd::ReadOnly);
+ string Size;
+ strprintf(Size, "Size: %llu\n", Fd.Size());
+ DebControl->Write(Size.c_str(), Size.size());
+ // and 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());
+
+ return true;
+}
+pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const
+{
+ pkgCache::PkgFileIterator File = Cache.FileBegin();
+ for (; File.end() == false; ++File)
+ {
+ if (File.FileName() == NULL || DebFile != File.FileName())
+ continue;
+
+ 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);
+}
+
+unsigned long debDscFileIndex::Size() const
+{
+ 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))
+ return NULL;
+
+ return new debDscRecordParser(DscFile,this);
+}
+ /*}}}*/
// Index File types for Debian /*{{{*/
-class debIFTypeSrc : public pkgIndexFile::Type
+class APT_HIDDEN debIFTypeSrc : public pkgIndexFile::Type
{
public:
debIFTypeSrc() {Label = "Debian Source Index";};
};
-class debIFTypePkg : public pkgIndexFile::Type
+class APT_HIDDEN debIFTypePkg : public pkgIndexFile::Type
{
public:
@@ -700,12 +818,12 @@ class debIFTypePkg : public pkgIndexFile::Type
};
debIFTypePkg() {Label = "Debian Package Index";};
};
-class debIFTypeTrans : public debIFTypePkg
+class APT_HIDDEN debIFTypeTrans : public debIFTypePkg
{
public:
debIFTypeTrans() {Label = "Debian Translation Index";};
};
-class debIFTypeStatus : public pkgIndexFile::Type
+class APT_HIDDEN debIFTypeStatus : public pkgIndexFile::Type
{
public:
@@ -715,10 +833,42 @@ class debIFTypeStatus : public pkgIndexFile::Type
};
debIFTypeStatus() {Label = "Debian dpkg status file";};
};
-static debIFTypeSrc _apt_Src;
-static debIFTypePkg _apt_Pkg;
-static debIFTypeTrans _apt_Trans;
-static debIFTypeStatus _apt_Status;
+class APT_HIDDEN debIFTypeDebPkgFile : public pkgIndexFile::Type
+{
+ public:
+ virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
+ {
+ return new debDebFileRecordParser(File.FileName(),*File.Cache());
+ };
+ debIFTypeDebPkgFile() {Label = "deb Package file";};
+};
+class APT_HIDDEN debIFTypeDscFile : public pkgIndexFile::Type
+{
+ public:
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string DscFile) const
+ {
+ return new debDscRecordParser(DscFile, NULL);
+ };
+ debIFTypeDscFile() {Label = "dsc File Source Index";};
+};
+class APT_HIDDEN debIFTypeDebianSourceDir : public pkgIndexFile::Type
+{
+ public:
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string SourceDir) const
+ {
+ return new debDscRecordParser(SourceDir + string("/debian/control"), NULL);
+ };
+ debIFTypeDebianSourceDir() {Label = "debian/control File Source Index";};
+};
+
+APT_HIDDEN debIFTypeSrc _apt_Src;
+APT_HIDDEN debIFTypePkg _apt_Pkg;
+APT_HIDDEN debIFTypeTrans _apt_Trans;
+APT_HIDDEN debIFTypeStatus _apt_Status;
+APT_HIDDEN debIFTypeDebPkgFile _apt_DebPkgFile;
+// file based pseudo indexes
+APT_HIDDEN debIFTypeDscFile _apt_DscFile;
+APT_HIDDEN debIFTypeDebianSourceDir _apt_DebianSourceDir;
const pkgIndexFile::Type *debSourcesIndex::GetType() const
{
@@ -736,5 +886,23 @@ const pkgIndexFile::Type *debStatusIndex::GetType() const
{
return &_apt_Status;
}
-
+const pkgIndexFile::Type *debDebPkgFileIndex::GetType() const
+{
+ return &_apt_DebPkgFile;
+}
+const pkgIndexFile::Type *debDscFileIndex::GetType() const
+{
+ return &_apt_DscFile;
+}
+const pkgIndexFile::Type *debDebianSourceDirIndex::GetType() const
+{
+ return &_apt_DebianSourceDir;
+}
/*}}}*/
+
+debStatusIndex::~debStatusIndex() {}
+debPackagesIndex::~debPackagesIndex() {}
+debTranslationsIndex::~debTranslationsIndex() {}
+debSourcesIndex::~debSourcesIndex() {}
+
+debDebPkgFileIndex::~debDebPkgFileIndex() {}
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 017c69a0a..312e915f1 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -28,7 +28,7 @@ class pkgAcquire;
class pkgCacheGenerator;
-class debStatusIndex : public pkgIndexFile
+class APT_HIDDEN debStatusIndex : public pkgIndexFile
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
@@ -52,10 +52,10 @@ class debStatusIndex : public pkgIndexFile
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
debStatusIndex(std::string File);
- virtual ~debStatusIndex() {};
+ virtual ~debStatusIndex();
};
-class debPackagesIndex : public pkgIndexFile
+class APT_HIDDEN debPackagesIndex : public pkgIndexFile
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
@@ -65,10 +65,10 @@ class debPackagesIndex : public pkgIndexFile
std::string Section;
std::string Architecture;
- std::string Info(const char *Type) const;
- std::string IndexFile(const char *Type) const;
- std::string IndexURI(const char *Type) const;
-
+ 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;
+
public:
virtual const Type *GetType() const APT_CONST;
@@ -89,10 +89,10 @@ class debPackagesIndex : public pkgIndexFile
debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
bool const &Trusted, std::string const &Arch = "native");
- virtual ~debPackagesIndex() {};
+ virtual ~debPackagesIndex();
};
-class debTranslationsIndex : public pkgIndexFile
+class APT_HIDDEN debTranslationsIndex : public pkgIndexFile
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
@@ -102,11 +102,11 @@ class debTranslationsIndex : public pkgIndexFile
std::string Section;
const char * const Language;
- std::string Info(const char *Type) const;
- std::string IndexFile(const char *Type) const;
- std::string IndexURI(const char *Type) const;
+ 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;
- inline std::string TranslationFile() const {return std::string("Translation-").append(Language);};
+ APT_HIDDEN std::string TranslationFile() const {return std::string("Translation-").append(Language);};
public:
@@ -114,7 +114,6 @@ class debTranslationsIndex : public pkgIndexFile
// Interface for acquire
virtual std::string Describe(bool Short) const;
- virtual bool GetIndexes(pkgAcquire *Owner) const;
// Interface for the Cache Generator
virtual bool Exists() const;
@@ -124,10 +123,10 @@ class debTranslationsIndex : public pkgIndexFile
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
debTranslationsIndex(std::string URI,std::string Dist,std::string Section, char const * const Language);
- virtual ~debTranslationsIndex() {};
+ virtual ~debTranslationsIndex();
};
-class debSourcesIndex : public pkgIndexFile
+class APT_HIDDEN debSourcesIndex : public pkgIndexFile
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
@@ -136,10 +135,10 @@ class debSourcesIndex : public pkgIndexFile
std::string Dist;
std::string Section;
- std::string Info(const char *Type) const;
- std::string IndexFile(const char *Type) const;
- std::string IndexURI(const char *Type) const;
-
+ 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;
+
public:
virtual const Type *GetType() const APT_CONST;
@@ -161,7 +160,61 @@ class debSourcesIndex : public pkgIndexFile
virtual unsigned long Size() const;
debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
- virtual ~debSourcesIndex() {};
+ virtual ~debSourcesIndex();
+};
+
+class APT_HIDDEN debDebPkgFileIndex : public pkgIndexFile
+{
+ private:
+ void *d;
+ std::string DebFile;
+ std::string DebFileFullPath;
+
+ public:
+ virtual const Type *GetType() const APT_CONST;
+
+ virtual std::string Describe(bool /*Short*/) const {
+ return 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;
+
+ // Interface for acquire
+ virtual std::string ArchiveURI(std::string /*File*/) const;
+
+ debDebPkgFileIndex(std::string DebFile);
+ virtual ~debDebPkgFileIndex();
+};
+
+class APT_HIDDEN debDscFileIndex : public pkgIndexFile
+{
+ private:
+ std::string DscFile;
+ 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() {};
+};
+
+class APT_HIDDEN debDebianSourceDirIndex : public debDscFileIndex
+{
+ public:
+ virtual const Type *GetType() const APT_CONST;
};
#endif
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4eef66c2b..462818a03 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -58,18 +58,6 @@ debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File),
MultiArchEnabled = Architectures.size() > 1;
}
/*}}}*/
-// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned long debListParser::UniqFindTagWrite(const char *Tag)
-{
- const char *Start;
- const char *Stop;
- if (Section.Find(Tag,Start,Stop) == false)
- return 0;
- return WriteUniqString(Start,Stop - Start);
-}
- /*}}}*/
// ListParser::Package - Return the package name /*{{{*/
// ---------------------------------------------------------------------
/* This is to return the name of the package this section describes */
@@ -144,9 +132,69 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
/* */
bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
{
+ const char *Start;
+ const char *Stop;
+
// Parse the section
- unsigned long const idxSection = UniqFindTagWrite("Section");
- Ver->Section = idxSection;
+ if (Section.Find("Section",Start,Stop) == true)
+ {
+ 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;
+ Ver->SourceVerStr = Ver->VerStr;
+ if (Section.Find("Source",Start,Stop) == true)
+ {
+ const char * const Space = (const char * const) memchr(Start, ' ', Stop - Start);
+ pkgCache::VerIterator V;
+
+ if (Space != NULL)
+ {
+ Stop = Space;
+ const char * const Open = (const char * const) memchr(Space, '(', Stop - Space);
+ if (likely(Open != NULL))
+ {
+ const char * const Close = (const char * const) memchr(Open, ')', Stop - Open);
+ if (likely(Close != NULL))
+ {
+ std::string const version(Open + 1, (Close - Open) - 1);
+ if (version != Ver.VerStr())
+ {
+ map_stringitem_t const idx = StoreString(pkgCacheGenerator::VERSIONNUMBER, version);
+ Ver->SourceVerStr = idx;
+ }
+ }
+ }
+ }
+
+ std::string const pkgname(Start, Stop - Start);
+ if (pkgname != G.Name())
+ {
+ for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P))
+ {
+ for (V = P.VersionList(); V.end() == false; ++V)
+ {
+ if (pkgname == V.SourcePkgName())
+ {
+ Ver->SourcePkgName = V->SourcePkgName;
+ break;
+ }
+ }
+ if (V.end() == false)
+ break;
+ }
+ if (V.end() == true)
+ {
+ map_stringitem_t const idx = StoreString(pkgCacheGenerator::PKGNAME, pkgname);
+ Ver->SourcePkgName = idx;
+ }
+ }
+ }
+#endif
+
Ver->MultiArch = ParseMultiArch(true);
// Archive Size
Ver->Size = Section.FindULL("Size");
@@ -155,10 +203,8 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
Ver->InstalledSize *= 1024;
// Priority
- const char *Start;
- const char *Stop;
if (Section.Find("Priority",Start,Stop) == true)
- {
+ {
if (GrabWord(string(Start,Stop-Start),PrioList,Ver->Priority) == false)
Ver->Priority = pkgCache::State::Extra;
}
@@ -195,35 +241,31 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
/* This is to return the string describing the package in debian
form. If this returns the blank string then the entry is assumed to
only describe package properties */
-string debListParser::Description()
+string debListParser::Description(std::string const &lang)
{
- string const lang = DescriptionLanguage();
if (lang.empty())
return Section.FindS("Description");
else
return Section.FindS(string("Description-").append(lang).c_str());
}
- /*}}}*/
-// ListParser::DescriptionLanguage - Return the description lang string /*{{{*/
-// ---------------------------------------------------------------------
-/* This is to return the string describing the language of
- description. If this returns the blank string then the entry is
- assumed to describe original description. */
-string debListParser::DescriptionLanguage()
+ /*}}}*/
+// ListParser::AvailableDescriptionLanguages /*{{{*/
+std::vector<std::string> debListParser::AvailableDescriptionLanguages()
{
- if (Section.FindS("Description").empty() == false)
- return "";
-
- std::vector<string> const lang = APT::Configuration::getLanguages(true);
- for (std::vector<string>::const_iterator l = lang.begin();
- l != lang.end(); ++l)
- if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
- return *l;
-
- return "";
+ std::vector<std::string> const understood = APT::Configuration::getLanguages();
+ std::vector<std::string> avail;
+ if (Section.Exists("Description") == true)
+ avail.push_back("");
+ for (std::vector<std::string>::const_iterator lang = understood.begin(); lang != understood.end(); ++lang)
+ {
+ std::string const tagname = "Description-" + *lang;
+ if (Section.Exists(tagname.c_str()) == true)
+ avail.push_back(*lang);
+ }
+ return avail;
}
- /*}}}*/
-// ListParser::Description - Return the description_md5 MD5SumValue /*{{{*/
+ /*}}}*/
+// ListParser::Description_md5 - Return the description_md5 MD5SumValue /*{{{*/
// ---------------------------------------------------------------------
/* This is to return the md5 string to allow the check if it is the right
description. If no Description-md5 is found in the section it will be
@@ -234,7 +276,7 @@ MD5SumValue debListParser::Description_md5()
string const value = Section.FindS("Description-md5");
if (value.empty() == true)
{
- std::string const desc = Description() + "\n";
+ std::string const desc = Description("") + "\n";
if (desc == "\n")
return MD5SumValue();
@@ -260,12 +302,6 @@ MD5SumValue debListParser::Description_md5()
bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver)
{
- if (Pkg->Section == 0)
- {
- unsigned long const idxSection = UniqFindTagWrite("Section");
- Pkg->Section = idxSection;
- }
-
string const static myArch = _config->Find("APT::Architecture");
// Possible values are: "all", "native", "installed" and "none"
// The "installed" mode is handled by ParseStatus(), See #544481 and friends.
@@ -917,7 +953,7 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
{
// apt-secure does no longer download individual (per-section) Release
// file. to provide Component pinning we use the section name now
- map_ptrloc const storage = WriteUniqString(component);
+ map_stringitem_t const storage = StoreString(pkgCacheGenerator::MIXED, component);
FileI->Component = storage;
pkgTagFile TagFile(&File, File.Size());
@@ -926,19 +962,19 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
return false;
std::string data;
- #define APT_INRELEASE(TAG, STORE) \
+ #define APT_INRELEASE(TYPE, TAG, STORE) \
data = Section.FindS(TAG); \
if (data.empty() == false) \
{ \
- map_ptrloc const storage = WriteUniqString(data); \
+ map_stringitem_t const storage = StoreString(pkgCacheGenerator::TYPE, data); \
STORE = storage; \
}
- APT_INRELEASE("Suite", FileI->Archive)
- APT_INRELEASE("Component", FileI->Component)
- APT_INRELEASE("Version", FileI->Version)
- APT_INRELEASE("Origin", FileI->Origin)
- APT_INRELEASE("Codename", FileI->Codename)
- APT_INRELEASE("Label", FileI->Label)
+ 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);
@@ -958,7 +994,7 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+#if APT_PKG_ABI >= 413
bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
pkgCache::VerIterator const &Ver)
{
@@ -979,3 +1015,22 @@ bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
}
/*}}}*/
#endif
+
+
+debDebFileParser::debDebFileParser(FileFd *File, std::string const &DebFile)
+ : debListParser(File, ""), DebFile(DebFile)
+{
+}
+
+bool debDebFileParser::UsePackage(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver)
+{
+ 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)
+ return false;
+ return res;
+}
+
+debListParser::~debListParser() {}
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 3b6963211..6279d8399 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -26,7 +26,7 @@
class FileFd;
-class debListParser : public pkgCacheGenerator::ListParser
+class APT_HIDDEN debListParser : public pkgCacheGenerator::ListParser
{
public:
@@ -44,22 +44,22 @@ class debListParser : public pkgCacheGenerator::ListParser
protected:
pkgTagFile Tags;
pkgTagSection Section;
- unsigned long iOffset;
+ map_filesize_t iOffset;
std::string Arch;
std::vector<std::string> Architectures;
bool MultiArchEnabled;
- unsigned long UniqFindTagWrite(const char *Tag);
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);
+
public:
- static unsigned char GetPrio(std::string Str);
+ APT_PUBLIC static unsigned char GetPrio(std::string Str);
// These all operate against the current section
virtual std::string Package();
@@ -67,46 +67,54 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual bool ArchitectureAll();
virtual std::string Version();
virtual bool NewVersion(pkgCache::VerIterator &Ver);
- virtual std::string Description();
- virtual std::string DescriptionLanguage();
+ 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_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+#if APT_PKG_ABI >= 413
virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
#endif
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver);
- virtual unsigned long Offset() {return iOffset;};
- virtual unsigned long Size() {return Section.size();};
+ virtual map_filesize_t Offset() {return iOffset;};
+ virtual map_filesize_t Size() {return Section.size();};
virtual bool Step();
bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
std::string section);
- static const char *ParseDepends(const char *Start,const char *Stop,
+ APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op);
- static const char *ParseDepends(const char *Start,const char *Stop,
+ APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op,
bool const &ParseArchFlags);
- static const char *ParseDepends(const char *Start,const char *Stop,
+ APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op,
bool const &ParseArchFlags, bool const &StripMultiArch);
- static const char *ParseDepends(const char *Start,const char *Stop,
+ APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
std::string &Package,std::string &Ver,unsigned int &Op,
bool const &ParseArchFlags, bool const &StripMultiArch,
bool const &ParseRestrictionsList);
- static const char *ConvertRelation(const char *I,unsigned int &Op);
+ APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
debListParser(FileFd *File, std::string const &Arch = "");
- virtual ~debListParser() {};
+ virtual ~debListParser();
+};
- private:
- APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
+class APT_HIDDEN debDebFileParser : public debListParser
+{
+ private:
+ std::string DebFile;
+
+ public:
+ debDebFileParser(FileFd *File, std::string const &DebFile);
+ virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver);
};
-class debTranslationsParser : public debListParser
+class APT_HIDDEN debTranslationsParser : public debListParser
{
public:
// a translation can never be a real package
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 6fd12add8..81e067424 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -78,7 +78,6 @@ string debReleaseIndex::MetaIndexURI(const char *Type) const
return Res;
}
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
std::string debReleaseIndex::LocalFileName() const
{
// see if we have a InRelease file
@@ -92,7 +91,6 @@ std::string debReleaseIndex::LocalFileName() const
return "";
}
-#endif
string debReleaseIndex::IndexURISuffix(const char *Type, string const &Section, string const &Arch) const
{
@@ -186,8 +184,8 @@ debReleaseIndex::~debReleaseIndex() {
delete *S;
}
-vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
- vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
+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()) {
@@ -253,38 +251,44 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
{
bool const tryInRelease = _config->FindB("Acquire::TryInRelease", true);
+ indexRecords * const iR = new indexRecords(Dist);
+ if (Trusted == ALWAYS_TRUSTED)
+ iR->SetTrusted(true);
+ else if (Trusted == NEVER_TRUSTED)
+ iR->SetTrusted(false);
+
// special case for --print-uris
if (GetAll) {
- vector <struct IndexTarget *> *targets = ComputeIndexTargets();
- for (vector <struct IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) {
+ 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, HashString());
+ (*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, MetaIndexURI("Release"),
- MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"),
- ComputeIndexTargets(),
- new indexRecords (Dist));
+ new pkgAcqMetaIndex(Owner, NULL,
+ MetaIndexURI("Release"),
+ MetaIndexInfo("Release"), "Release",
+ MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
+ ComputeIndexTargets(),
+ iR);
}
-
if (tryInRelease == true)
- new pkgAcqMetaClearSig(Owner, MetaIndexURI("InRelease"),
- MetaIndexInfo("InRelease"), "InRelease",
+ new pkgAcqMetaClearSig(Owner,
+ MetaIndexURI("InRelease"), MetaIndexInfo("InRelease"), "InRelease",
MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
ComputeIndexTargets(),
- new indexRecords (Dist));
+ iR);
else
- new pkgAcqMetaSig(Owner, MetaIndexURI("Release.gpg"),
- MetaIndexInfo("Release.gpg"), "Release.gpg",
- MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
- ComputeIndexTargets(),
- new indexRecords (Dist));
+ new pkgAcqMetaIndex(Owner, NULL,
+ MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
+ MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
+ ComputeIndexTargets(),
+ iR);
return true;
}
@@ -388,7 +392,7 @@ debReleaseIndex::debSectionEntry::debSectionEntry (string const &Section,
bool const &IsSrc): Section(Section), IsSrc(IsSrc)
{}
-class debSLTypeDebian : public pkgSourceList::Type
+class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type
{
protected:
@@ -471,7 +475,16 @@ class debSLTypeDebian : public pkgSourceList::Type
}
};
-class debSLTypeDeb : public debSLTypeDebian
+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
{
public:
@@ -489,7 +502,7 @@ class debSLTypeDeb : public debSLTypeDebian
}
};
-class debSLTypeDebSrc : public debSLTypeDebian
+class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian
{
public:
@@ -507,5 +520,26 @@ class debSLTypeDebSrc : public debSLTypeDebian
}
};
-debSLTypeDeb _apt_DebType;
-debSLTypeDebSrc _apt_DebSrcType;
+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
+ {
+ 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 2286fa8b2..94d005760 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -18,8 +18,10 @@
class pkgAcquire;
class pkgIndexFile;
+class debDebPkgFileIndex;
+class IndexTarget;
-class debReleaseIndex : public metaIndex {
+class APT_HIDDEN debReleaseIndex : public metaIndex {
public:
class debSectionEntry
@@ -34,7 +36,7 @@ class debReleaseIndex : public metaIndex {
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
std::map<std::string, std::vector<debSectionEntry const*> > ArchEntries;
- enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
+ enum APT_HIDDEN { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
public:
@@ -44,16 +46,17 @@ class debReleaseIndex : public metaIndex {
virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
- std::vector <struct IndexTarget *>* ComputeIndexTargets() const;
+ std::vector <IndexTarget *>* ComputeIndexTargets() const;
std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const;
std::string MetaIndexInfo(const char *Type) const;
std::string MetaIndexFile(const char *Types) const;
std::string MetaIndexURI(const char *Type) const;
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
- virtual std::string LocalFileName() const;
+#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;
@@ -71,4 +74,27 @@ class debReleaseIndex : public metaIndex {
void PushSectionEntry(const debSectionEntry *Entry);
};
+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() {};
+
+};
+
#endif
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 6063db5a8..b41aa5584 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -73,36 +73,17 @@ string debRecordParser::Homepage()
return Section.FindS("Homepage");
}
/*}}}*/
-// RecordParser::MD5Hash - Return the archive hash /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debRecordParser::MD5Hash()
+// RecordParser::Hashes - return the available archive hashes /*{{{*/
+HashStringList debRecordParser::Hashes() const
{
- return Section.FindS("MD5Sum");
-}
- /*}}}*/
-// RecordParser::SHA1Hash - Return the archive hash /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debRecordParser::SHA1Hash()
-{
- return Section.FindS("SHA1");
-}
- /*}}}*/
-// RecordParser::SHA256Hash - Return the archive hash /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debRecordParser::SHA256Hash()
-{
- return Section.FindS("SHA256");
-}
- /*}}}*/
-// RecordParser::SHA512Hash - Return the archive hash /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debRecordParser::SHA512Hash()
-{
- return Section.FindS("SHA512");
+ HashStringList hashes;
+ for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
+ {
+ std::string const hash = Section.FindS(*type);
+ if (hash.empty() == false)
+ hashes.push_back(HashString(*type, hash));
+ }
+ return hashes;
}
/*}}}*/
// RecordParser::Maintainer - Return the maintainer email /*{{{*/
@@ -125,10 +106,12 @@ string debRecordParser::RecordField(const char *fieldName)
// RecordParser::ShortDesc - Return a 1 line description /*{{{*/
// ---------------------------------------------------------------------
/* */
-string debRecordParser::ShortDesc()
+string debRecordParser::ShortDesc(std::string const &lang)
{
- string Res = LongDesc();
- string::size_type Pos = Res.find('\n');
+ string const Res = LongDesc(lang);
+ if (Res.empty() == true)
+ return "";
+ string::size_type const Pos = Res.find('\n');
if (Pos == string::npos)
return Res;
return string(Res,0,Pos);
@@ -137,26 +120,44 @@ string debRecordParser::ShortDesc()
// RecordParser::LongDesc - Return a longer description /*{{{*/
// ---------------------------------------------------------------------
/* */
-string debRecordParser::LongDesc()
-{
- string orig, dest;
+string debRecordParser::LongDesc(std::string const &lang)
+{
+ string orig;
+ if (lang.empty() == true)
+ {
+ std::vector<string> const lang = APT::Configuration::getLanguages();
+ for (std::vector<string>::const_iterator l = lang.begin();
+ l != lang.end(); ++l)
+ {
+ std::string const tagname = "Description-" + *l;
+ orig = Section.FindS(tagname.c_str());
+ if (orig.empty() == false)
+ break;
+ else if (*l == "en")
+ {
+ orig = Section.FindS("Description");
+ if (orig.empty() == false)
+ break;
+ }
+ }
+ if (orig.empty() == true)
+ orig = Section.FindS("Description");
+ }
+ else
+ {
+ std::string const tagname = "Description-" + lang;
+ orig = Section.FindS(tagname.c_str());
+ if (orig.empty() == true && lang == "en")
+ orig = Section.FindS("Description");
+ }
- if (!Section.FindS("Description").empty())
- orig = Section.FindS("Description").c_str();
- else
- {
- std::vector<string> const lang = APT::Configuration::getLanguages();
- for (std::vector<string>::const_iterator l = lang.begin();
- orig.empty() && l != lang.end(); ++l)
- orig = Section.FindS(string("Description-").append(*l).c_str());
- }
+ char const * const codeset = nl_langinfo(CODESET);
+ if (strcmp(codeset,"UTF-8") != 0) {
+ string dest;
+ UTF8ToCodeset(codeset, orig, &dest);
+ return dest;
+ }
- char const * const codeset = nl_langinfo(CODESET);
- if (strcmp(codeset,"UTF-8") != 0) {
- UTF8ToCodeset(codeset, orig, &dest);
- orig = dest;
- }
-
return orig;
}
/*}}}*/
@@ -206,3 +207,5 @@ void debRecordParser::GetRec(const char *&Start,const char *&Stop)
Section.GetSection(Start,Stop);
}
/*}}}*/
+
+debRecordParser::~debRecordParser() {}
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index bdac6c90b..7091c38e6 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -25,35 +25,32 @@
#include <apt-pkg/indexfile.h>
#endif
-class debRecordParser : public pkgRecords::Parser
+class APT_HIDDEN debRecordParser : public pkgRecords::Parser
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
-
+
+ protected:
FileFd File;
pkgTagFile Tags;
pkgTagSection Section;
- protected:
-
virtual bool Jump(pkgCache::VerFileIterator const &Ver);
virtual bool Jump(pkgCache::DescFileIterator const &Desc);
- public:
+ public:
// These refer to the archive file for the Version
virtual std::string FileName();
- virtual std::string MD5Hash();
- virtual std::string SHA1Hash();
- virtual std::string SHA256Hash();
- virtual std::string SHA512Hash();
virtual std::string SourcePkg();
virtual std::string SourceVer();
-
+
+ virtual HashStringList Hashes() const;
+
// These are some general stats about the package
virtual std::string Maintainer();
- virtual std::string ShortDesc();
- virtual std::string LongDesc();
+ virtual std::string ShortDesc(std::string const &lang);
+ virtual std::string LongDesc(std::string const &lang);
virtual std::string Name();
virtual std::string Homepage();
@@ -63,7 +60,18 @@ class debRecordParser : public pkgRecords::Parser
virtual void GetRec(const char *&Start,const char *&Stop);
debRecordParser(std::string FileName,pkgCache &Cache);
- virtual ~debRecordParser() {};
+ virtual ~debRecordParser();
+};
+
+// custom record parser that reads deb files directly
+class APT_HIDDEN debDebFileRecordParser : public debRecordParser
+{
+ public:
+ virtual std::string FileName() {
+ return File.Name();
+ }
+ debDebFileRecordParser(std::string FileName,pkgCache &Cache)
+ : debRecordParser(FileName, Cache) {};
};
#endif
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 49a348dd4..ca6d09896 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -18,6 +18,8 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/gpgv.h>
#include <ctype.h>
#include <stdlib.h>
@@ -55,12 +57,13 @@ const char **debSrcRecordParser::Binaries()
char* binStartNext = strchrnul(bin, ',');
char* binEnd = binStartNext - 1;
for (; isspace(*binEnd) != 0; --binEnd)
- binEnd = '\0';
+ binEnd = 0;
StaticBinList.push_back(bin);
if (*binStartNext != ',')
break;
*binStartNext = '\0';
- for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin);
+ for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin)
+ ;
} while (*bin != '\0');
StaticBinList.push_back(NULL);
@@ -190,16 +193,8 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List)
// we have it already, store the new hash and be done
if (file != List.end())
{
-#if __GNUC__ >= 4
- // set for compatibility only, so warn users not us
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
if (checksumField == "Files")
- file->MD5Hash = hash;
-#if __GNUC__ >= 4
- #pragma GCC diagnostic pop
-#endif
+ APT_IGNORE_DEPRECATED(file->MD5Hash = hash;)
// an error here indicates that we have two different hashes for the same file
if (file->Hashes.push_back(hashString) == false)
return _error->Error("Error parsing checksum in %s of source package %s", checksumField.c_str(), Package().c_str());
@@ -212,17 +207,11 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List)
F.FileSize = strtoull(size.c_str(), NULL, 10);
F.Hashes.push_back(hashString);
-#if __GNUC__ >= 4
- // set for compatibility only, so warn users not us
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+ APT_IGNORE_DEPRECATED_PUSH
F.Size = F.FileSize;
if (checksumField == "Files")
F.MD5Hash = hash;
-#if __GNUC__ >= 4
- #pragma GCC diagnostic pop
-#endif
+ APT_IGNORE_DEPRECATED_POP
// Try to guess what sort of file it is we are getting.
string::size_type Pos = F.Path.length()-1;
@@ -264,3 +253,21 @@ debSrcRecordParser::~debSrcRecordParser()
free(Buffer);
}
/*}}}*/
+
+
+debDscRecordParser::debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index)
+ : debSrcRecordParser(DscFile, Index)
+{
+ // support clear signed files
+ if (OpenMaybeClearSignedFile(DscFile, Fd) == false)
+ {
+ _error->Error("Failed to open %s", DscFile.c_str());
+ return;
+ }
+
+ // re-init to ensure the updated Fd is used
+ Tags.Init(&Fd);
+ // read the first (and only) record
+ Step();
+
+}
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index 2a3fc86c9..cd246d624 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -21,11 +21,12 @@
class pkgIndexFile;
-class debSrcRecordParser : public pkgSrcRecords::Parser
+class APT_HIDDEN debSrcRecordParser : public pkgSrcRecords::Parser
{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
+ protected:
FileFd Fd;
pkgTagFile Tags;
pkgTagSection Sect;
@@ -61,4 +62,10 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
virtual ~debSrcRecordParser();
};
+class APT_HIDDEN debDscRecordParser : public debSrcRecordParser
+{
+ public:
+ debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index);
+};
+
#endif
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 142f3a6e6..9a5da9da1 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -38,7 +38,7 @@ using std::string;
debSystem debSys;
-class debSystemPrivate {
+class APT_HIDDEN debSystemPrivate {
public:
debSystemPrivate() : LockFD(-1), LockCount(0), StatusFile(0)
{
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index a945f68fb..226cd60bf 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -29,7 +29,7 @@ class debSystem : public pkgSystem
{
// private d-pointer
debSystemPrivate *d;
- bool CheckUpdates();
+ APT_HIDDEN bool CheckUpdates();
public:
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index e23ca466d..09bd9149f 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -203,18 +203,10 @@ pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
{
pkgCache::VerIterator Ver;
for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
- {
- pkgCache::VerFileIterator Vf = Ver.FileList();
- pkgCache::PkgFileIterator F = Vf.File();
- for (F = Vf.File(); F.end() == false; ++F)
- {
- if (F && F.Archive())
- {
- if (strcmp(F.Archive(), "now"))
- return 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)
+ return Ver;
return Ver;
}
/*}}}*/
@@ -534,7 +526,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
void pkgDPkgPM::DoStdin(int master)
{
unsigned char input_buf[256] = {0,};
- ssize_t len = read(0, input_buf, sizeof(input_buf));
+ ssize_t len = read(STDIN_FILENO, input_buf, sizeof(input_buf));
if (len)
FileFd::Write(master, input_buf, len);
else
@@ -1057,7 +1049,6 @@ void pkgDPkgPM::BuildPackagesProgressMap()
++PackagesTotal;
}
/*}}}*/
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
bool pkgDPkgPM::Go(int StatusFd)
{
APT::Progress::PackageManager *progress = NULL;
@@ -1066,9 +1057,8 @@ bool pkgDPkgPM::Go(int StatusFd)
else
progress = new APT::Progress::PackageManagerProgressFd(StatusFd);
- return GoNoABIBreak(progress);
+ return Go(progress);
}
-#endif
void pkgDPkgPM::StartPtyMagic()
{
@@ -1223,11 +1213,7 @@ void pkgDPkgPM::StopPtyMagic()
* through to human readable (and i10n-able)
* names and calculates a percentage for each step.
*/
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
-#else
-bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
-#endif
{
pkgPackageManager::SigINTStop = false;
d->progress = progress;
@@ -1716,7 +1702,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
if (apportPkg.end() == true || apportPkg->CurrentVer == 0)
return;
- string pkgname, reportfile, srcpkgname, pkgver, arch;
+ string pkgname, reportfile, pkgver, arch;
string::size_type pos;
FILE *report;
@@ -1805,11 +1791,6 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
if (Ver.end() == true)
return;
pkgver = Ver.VerStr() == NULL ? "unknown" : Ver.VerStr();
- pkgRecords Recs(Cache);
- pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
- srcpkgname = Parse.SourcePkg();
- if(srcpkgname.empty())
- srcpkgname = pkgname;
// if the file exists already, we check:
// - if it was reported already (touched by apport).
@@ -1860,7 +1841,16 @@ 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 2c1805015..2a6e7e004 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -52,7 +52,7 @@ class pkgDPkgPM : public pkgPackageManager
needs to declare a Replaces on the disappeared package.
\param pkgname Name of the package that disappeared
*/
- void handleDisappearAction(std::string const &pkgname);
+ APT_HIDDEN void handleDisappearAction(std::string const &pkgname);
protected:
int pkgFailures;
@@ -118,27 +118,14 @@ class pkgDPkgPM : public pkgPackageManager
void DoTerminalPty(int master);
void DoDpkgStatusFd(int statusfd);
void ProcessDpkgStatusLine(char *line);
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
- void DoDpkgStatusFd(int statusfd, int /*unused*/) {
- DoDpkgStatusFd(statusfd);
- }
- void ProcessDpkgStatusLine(int /*unused*/, char *line) {
- ProcessDpkgStatusLine(line);
- }
-#endif
-
// 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);
-#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
virtual bool Go(APT::Progress::PackageManager *progress);
-#else
virtual bool Go(int StatusFd=-1);
- bool GoNoABIBreak(APT::Progress::PackageManager *progress);
-#endif
virtual void Reset();