summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-04-01 13:57:22 +0200
committerMichael Vogt <mvo@debian.org>2014-04-01 13:57:22 +0200
commit8a1c9010137a8c49d9808f2db34b9ee277138986 (patch)
tree5ec5c0103cb896407d8c9542fac0ec8ab3313602 /apt-pkg/deb
parentfa55ccaa85ca8f85251300f5c5f574edc0c3ca71 (diff)
parent417e83d0d79637266e04c98189c62ce85bcdf737 (diff)
Merge branch 'debian/sid' into ubuntu/master
Conflicts: apt-pkg/deb/dpkgpm.cc debian/apt.auto-removal.sh debian/changelog vendor/debian/sources.list.in
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc16
-rw-r--r--apt-pkg/deb/debindexfile.h20
-rw-r--r--apt-pkg/deb/deblistparser.cc176
-rw-r--r--apt-pkg/deb/deblistparser.h31
-rw-r--r--apt-pkg/deb/debmetaindex.cc11
-rw-r--r--apt-pkg/deb/debmetaindex.h8
-rw-r--r--apt-pkg/deb/debrecords.cc8
-rw-r--r--apt-pkg/deb/debrecords.h3
-rw-r--r--apt-pkg/deb/debsrcrecords.cc15
-rw-r--r--apt-pkg/deb/debsrcrecords.h7
-rw-r--r--apt-pkg/deb/debsystem.cc11
-rw-r--r--apt-pkg/deb/debsystem.h10
-rw-r--r--apt-pkg/deb/debversion.cc2
-rw-r--r--apt-pkg/deb/debversion.h20
-rw-r--r--apt-pkg/deb/dpkgpm.cc106
-rw-r--r--apt-pkg/deb/dpkgpm.h17
16 files changed, 345 insertions, 116 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 909dfcf47..eee758b7a 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -15,7 +15,6 @@
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/debrecords.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
@@ -23,7 +22,18 @@
#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 <stdio.h>
+#include <iostream>
+#include <string>
#include <sys/stat.h>
/*}}}*/
@@ -650,7 +660,7 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
// StatusIndex::Exists - Check if the index is available /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debStatusIndex::Exists() const
+APT_CONST bool debStatusIndex::Exists() const
{
// Abort if the file does not exist.
return true;
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 9e64d4476..017c69a0a 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -16,9 +16,17 @@
#ifndef PKGLIB_DEBINDEXFILE_H
#define PKGLIB_DEBINDEXFILE_H
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/srcrecords.h>
+#include <string>
+
+class OpProgress;
+class pkgAcquire;
+class pkgCacheGenerator;
-#include <apt-pkg/indexfile.h>
class debStatusIndex : public pkgIndexFile
{
@@ -30,10 +38,10 @@ class debStatusIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Interface for acquire
- virtual std::string Describe(bool Short) const {return File;};
+ virtual std::string Describe(bool /*Short*/) const {return File;};
// Interface for the Cache Generator
virtual bool Exists() const;
@@ -63,7 +71,7 @@ class debPackagesIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Stuff for accessing files on remote items
virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
@@ -102,7 +110,7 @@ class debTranslationsIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Interface for acquire
virtual std::string Describe(bool Short) const;
@@ -134,7 +142,7 @@ class debSourcesIndex : public pkgIndexFile
public:
- virtual const Type *GetType() const;
+ virtual const Type *GetType() const APT_CONST;
// Stuff for accessing files on remote items
virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index acdcc4554..a1bcfb710 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -21,8 +21,17 @@
#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>
#include <apt-pkg/macros.h>
+#include <stddef.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
#include <ctype.h>
/*}}}*/
@@ -34,7 +43,7 @@ static debListParser::WordList PrioList[] = {
{"standard",pkgCache::State::Standard},
{"optional",pkgCache::State::Optional},
{"extra",pkgCache::State::Extra},
- {}};
+ {NULL, 0}};
// ListParser::debListParser - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -95,44 +104,49 @@ string debListParser::Version()
return Section.FindS("Version");
}
/*}}}*/
-// ListParser::NewVersion - Fill in the version structure /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
{
- // Parse the section
- Ver->Section = UniqFindTagWrite("Section");
-
- // Parse multi-arch
+ unsigned char MA;
string const MultiArch = Section.FindS("Multi-Arch");
if (MultiArch.empty() == true)
- Ver->MultiArch = pkgCache::Version::None;
+ MA = pkgCache::Version::None;
else if (MultiArch == "same") {
- // Parse multi-arch
if (ArchitectureAll() == true)
{
- /* Arch all packages can't be Multi-Arch: same */
- _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
- Section.FindS("Package").c_str());
- Ver->MultiArch = pkgCache::Version::None;
+ if (showErrors == true)
+ _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
+ Section.FindS("Package").c_str());
+ MA = pkgCache::Version::None;
}
else
- Ver->MultiArch = pkgCache::Version::Same;
+ MA = pkgCache::Version::Same;
}
else if (MultiArch == "foreign")
- Ver->MultiArch = pkgCache::Version::Foreign;
+ MA = pkgCache::Version::Foreign;
else if (MultiArch == "allowed")
- Ver->MultiArch = pkgCache::Version::Allowed;
+ MA = pkgCache::Version::Allowed;
else
{
- _error->Warning("Unknown Multi-Arch type '%s' for package '%s'",
- MultiArch.c_str(), Section.FindS("Package").c_str());
- Ver->MultiArch = pkgCache::Version::None;
+ 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;
}
if (ArchitectureAll() == true)
- Ver->MultiArch |= pkgCache::Version::All;
+ MA |= pkgCache::Version::All;
+ return MA;
+}
+ /*}}}*/
+// ListParser::NewVersion - Fill in the version structure /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
+{
+ // Parse the section
+ Ver->Section = UniqFindTagWrite("Section");
+ Ver->MultiArch = ParseMultiArch(true);
// Archive Size
Ver->Size = Section.FindULL("Size");
// Unpacked Size (in K)
@@ -354,7 +368,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"hold",pkgCache::State::Hold},
{"deinstall",pkgCache::State::DeInstall},
{"purge",pkgCache::State::Purge},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false)
return _error->Error("Malformed 1st word in the Status line");
@@ -370,7 +384,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"reinstreq",pkgCache::State::ReInstReq},
{"hold",pkgCache::State::HoldInst},
{"hold-reinstreq",pkgCache::State::HoldReInstReq},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false)
return _error->Error("Malformed 2nd word in the Status line");
@@ -392,7 +406,7 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
{"triggers-pending",pkgCache::State::TriggersPending},
{"post-inst-failed",pkgCache::State::HalfConfigured},
{"removal-failed",pkgCache::State::HalfInstalled},
- {}};
+ {NULL, 0}};
if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
return _error->Error("Malformed 3rd word in the Status line");
@@ -475,17 +489,30 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
/* This parses the dependency elements out of a standard string in place,
bit by bit. */
const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, StripMultiArch, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
string &Package,string &Ver,
unsigned int &Op, bool const &ParseArchFlags,
- bool const &StripMultiArch)
+ bool const &StripMultiArch,
+ bool const &ParseRestrictionsList)
{
// Strip off leading space
- for (;Start != Stop && isspace(*Start) != 0; Start++);
+ for (;Start != Stop && isspace(*Start) != 0; ++Start);
// Parse off the package name
const char *I = Start;
for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
- *I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
+ *I != ',' && *I != '|' && *I != '[' && *I != ']' &&
+ *I != '<' && *I != '>'; ++I);
// Malformed, no '('
if (I != Stop && *I == ')')
@@ -602,6 +629,76 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
for (;I != Stop && isspace(*I) != 0; I++);
}
+ if (ParseRestrictionsList == true)
+ {
+ // Parse a restrictions list
+ if (I != Stop && *I == '<')
+ {
+ ++I;
+ // malformed
+ if (unlikely(I == Stop))
+ return 0;
+
+ std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
+
+ const char *End = I;
+ bool Found = false;
+ bool NegRestriction = false;
+ while (I != Stop)
+ {
+ // look for whitespace or ending '>'
+ for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+
+ if (unlikely(End == Stop))
+ return 0;
+
+ if (*I == '!')
+ {
+ NegRestriction = true;
+ ++I;
+ }
+
+ std::string restriction(I, End);
+
+ std::string prefix = "profile.";
+ // only support for "profile" prefix, ignore others
+ if (restriction.size() > prefix.size() &&
+ restriction.substr(0, prefix.size()) == prefix)
+ {
+ // get the name of the profile
+ restriction = restriction.substr(prefix.size());
+
+ if (restriction.empty() == false && profiles.empty() == false &&
+ std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
+ {
+ Found = true;
+ if (I[-1] != '!')
+ NegRestriction = false;
+ // we found a match, so fast-forward to the end of the wildcards
+ for (; End != Stop && *End != '>'; ++End);
+ }
+ }
+
+ if (*End++ == '>') {
+ I = End;
+ break;
+ }
+
+ I = End;
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
+ if (NegRestriction == true)
+ Found = !Found;
+
+ if (Found == false)
+ Package = ""; /* not for this restriction */
+ }
+
+ // Skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
if (I != Stop && *I == '|')
Op |= pkgCache::Dep::Or;
@@ -635,7 +732,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
string Version;
unsigned int Op;
- Start = ParseDepends(Start, Stop, Package, Version, Op, false, false);
+ Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);
size_t const found = Package.rfind(':');
@@ -841,3 +938,24 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
+ pkgCache::VerIterator const &Ver)
+{
+ if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false)
+ return false;
+ // status file has no (Download)Size, but all others are fair game
+ // status file is parsed last, so the first version we encounter is
+ // probably also the version we have downloaded
+ unsigned long long const Size = Section.FindULL("Size");
+ if (Size != 0 && Size != Ver->Size)
+ return false;
+ // available everywhere, but easier to check here than to include in VersionHash
+ unsigned char MultiArch = ParseMultiArch(false);
+ if (MultiArch != Ver->MultiArch)
+ return false;
+ // for all practical proposes (we can check): same version
+ return true;
+}
+ /*}}}*/
+#endif
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 386d291a2..baace79fe 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -13,11 +13,19 @@
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/tagfile.h>
+#include <apt-pkg/md5.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
+
+#include <string>
+#include <vector>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
#endif
+class FileFd;
+
class debListParser : public pkgCacheGenerator::ListParser
{
public:
@@ -63,6 +71,9 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual std::string DescriptionLanguage();
virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+ virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver);
+#endif
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver);
virtual unsigned long Offset() {return iOffset;};
@@ -72,15 +83,27 @@ class debListParser : public pkgCacheGenerator::ListParser
bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
std::string section);
-
+
+ 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,
- std::string &Package,std::string &Ver,unsigned int &Op,
- bool const &ParseArchFlags = false,
- bool const &StripMultiArch = true);
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags);
+ 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,
+ 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);
debListParser(FileFd *File, std::string const &Arch = "");
virtual ~debListParser() {};
+
+ private:
+ APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 504877558..6fd12add8 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -9,8 +9,15 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/indexrecords.h>
#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/error.h>
-
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/metaindex.h>
+
+#include <string.h>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
#include <set>
#include <algorithm>
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index cef8d68f7..2286fa8b2 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -3,7 +3,7 @@
#define PKGLIB_DEBMETAINDEX_H
#include <apt-pkg/metaindex.h>
-#include <apt-pkg/init.h>
+#include <apt-pkg/macros.h>
#include <map>
#include <string>
@@ -12,6 +12,12 @@
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/sourcelist.h>
#endif
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/init.h>
+#endif
+
+class pkgAcquire;
+class pkgIndexFile;
class debReleaseIndex : public metaIndex {
public:
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 184c07c33..6063db5a8 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -12,10 +12,16 @@
#include <apt-pkg/debrecords.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/tagfile.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
#include <langinfo.h>
/*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index b5e3bbdba..bdac6c90b 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -17,6 +17,9 @@
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgcache.h>
+
+#include <string>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index ce55ccd1f..b09588dd3 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -15,12 +15,19 @@
#include <apt-pkg/debsrcrecords.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/tagfile.h>
-using std::max;
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <string>
+#include <vector>
/*}}}*/
+using std::max;
using std::string;
// SrcRecordParser::Binaries - Return the binaries field /*{{{*/
@@ -57,7 +64,7 @@ const char **debSrcRecordParser::Binaries()
} while (*bin != '\0');
StaticBinList.push_back(NULL);
- return (const char **) &StaticBinList[0];
+ return &StaticBinList[0];
}
/*}}}*/
// SrcRecordParser::BuildDepends - Return the Build-Depends information /*{{{*/
@@ -90,7 +97,7 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
while (1)
{
Start = debListParser::ParseDepends(Start, Stop,
- rec.Package,rec.Version,rec.Op,true, StripMultiArch);
+ rec.Package,rec.Version,rec.Op,true,StripMultiArch,true);
if (Start == 0)
return _error->Error("Problem parsing dependency: %s", fields[I]);
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index a8fb465bb..b65d1480b 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -11,11 +11,16 @@
#ifndef PKGLIB_DEBSRCRECORDS_H
#define PKGLIB_DEBSRCRECORDS_H
-
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/fileutl.h>
+#include <stddef.h>
+#include <string>
+#include <vector>
+
+class pkgIndexFile;
+
class debSrcRecordParser : public pkgSrcRecords::Parser
{
/** \brief dpointer placeholder (for later in case we need it) */
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index b95ff15df..142f3a6e6 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -19,7 +19,14 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <sys/types.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <vector>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
@@ -195,7 +202,7 @@ bool debSystem::Initialize(Configuration &Cnf)
// ---------------------------------------------------------------------
/* The standard name for a deb is 'deb'.. There are no separate versions
of .deb to worry about.. */
-bool debSystem::ArchiveSupported(const char *Type)
+APT_PURE bool debSystem::ArchiveSupported(const char *Type)
{
if (strcmp(Type,"deb") == 0)
return true;
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 855123516..a945f68fb 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -12,11 +12,19 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <vector>
+class Configuration;
+class pkgIndexFile;
+class pkgPackageManager;
class debSystemPrivate;
-class debStatusIndex;
class pkgDepCache;
+#ifndef APT_10_CLEANER_HEADERS
+class debStatusIndex;
+#endif
+
class debSystem : public pkgSystem
{
// private d-pointer
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index 74e2552ff..a5eacb7f5 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -15,6 +15,8 @@
#include <apt-pkg/debversion.h>
#include <apt-pkg/pkgcache.h>
+#include <string.h>
+#include <string>
#include <stdlib.h>
#include <ctype.h>
/*}}}*/
diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h
index f1d6f3cc5..434ff4a2e 100644
--- a/apt-pkg/deb/debversion.h
+++ b/apt-pkg/deb/debversion.h
@@ -12,26 +12,26 @@
#ifndef PKGLIB_DEBVERSION_H
#define PKGLIB_DEBVERSION_H
+#include <apt-pkg/version.h>
+#include <string>
-#include <apt-pkg/version.h>
-
class debVersioningSystem : public pkgVersioningSystem
-{
+{
public:
-
+
static int CmpFragment(const char *A, const char *AEnd, const char *B,
- const char *BEnd);
-
+ const char *BEnd) APT_PURE;
+
// Compare versions..
virtual int DoCmpVersion(const char *A,const char *Aend,
- const char *B,const char *Bend);
- virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
- virtual int DoCmpReleaseVer(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;
+ virtual APT_PURE int DoCmpReleaseVer(const char *A,const char *Aend,
const char *B,const char *Bend)
{
return DoCmpVersion(A,Aend,B,Bend);
- }
+ }
virtual std::string UpstreamVersion(const char *A);
debVersioningSystem();
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 25a1e6055..c52b83c6e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -10,40 +10,45 @@
// Includes /*{{{*/
#include <config.h>
-#include <apt-pkg/dpkgpm.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/dpkgpm.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/packagemanager.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>
+#include <apt-pkg/pkgcache.h>
-#include <unistd.h>
-#include <stdlib.h>
+#include <errno.h>
#include <fcntl.h>
+#include <grp.h>
+#include <pty.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/time.h>
#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <algorithm>
-#include <sstream>
-#include <map>
-#include <pwd.h>
-#include <grp.h>
-#include <iomanip>
-
#include <termios.h>
+#include <time.h>
#include <unistd.h>
-#include <sys/ioctl.h>
-#include <pty.h>
-#include <stdio.h>
+#include <algorithm>
+#include <cstring>
+#include <iostream>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -394,10 +399,14 @@ bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version)
that are due to be installed. */
bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
{
+ bool result = true;
+
Configuration::Item const *Opts = _config->Tree(Cnf);
if (Opts == 0 || Opts->Child == 0)
return true;
Opts = Opts->Child;
+
+ sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN);
unsigned int Count = 1;
for (; Opts != 0; Opts = Opts->Next, Count++)
@@ -405,6 +414,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
if (Opts->Value.empty() == true)
continue;
+ if(_config->FindB("Debug::RunScripts", false) == true)
+ std::clog << "Running external script with list of all .deb file: '"
+ << Opts->Value << "'" << std::endl;
+
// Determine the protocol version
string OptSec = Opts->Value;
string::size_type Pos;
@@ -419,8 +432,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
std::set<int> KeepFDs;
MergeKeepFdsFromConfiguration(KeepFDs);
int Pipes[2];
- if (pipe(Pipes) != 0)
- return _error->Errno("pipe","Failed to create IPC pipe to subprocess");
+ if (pipe(Pipes) != 0) {
+ result = _error->Errno("pipe","Failed to create IPC pipe to subprocess");
+ break;
+ }
if (InfoFD != (unsigned)Pipes[0])
SetCloseExec(Pipes[0],true);
else
@@ -454,8 +469,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
}
close(Pipes[0]);
FILE *F = fdopen(Pipes[1],"w");
- if (F == 0)
- return _error->Errno("fdopen","Faild to open new FD");
+ if (F == 0) {
+ result = _error->Errno("fdopen","Faild to open new FD");
+ break;
+ }
// Feed it the filenames.
if (Version <= 1)
@@ -483,11 +500,14 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
fclose(F);
// Clean up the sub process
- if (ExecWait(Process,Opts->Value.c_str()) == false)
- return _error->Error("Failure running script %s",Opts->Value.c_str());
+ if (ExecWait(Process,Opts->Value.c_str()) == false) {
+ result = _error->Error("Failure running script %s",Opts->Value.c_str());
+ break;
+ }
}
+ signal(SIGPIPE, old_sigpipe);
- return true;
+ return result;
}
/*}}}*/
// DPkgPM::DoStdin - Read stdin and pass to slave pty /*{{{*/
@@ -1525,28 +1545,18 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
// here but keep the loop going and just report it as a error
// for later
bool const stopOnError = _config->FindB("Dpkg::StopOnError",true);
-
- if(stopOnError)
- RunScripts("DPkg::Post-Invoke");
- if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
+ if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
strprintf(d->dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
else if (WIFEXITED(Status) != 0)
strprintf(d->dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
- else
+ else
strprintf(d->dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
+ _error->Error("%s", d->dpkg_error.c_str());
- if(d->dpkg_error.size() > 0)
- _error->Error("%s", d->dpkg_error.c_str());
-
- if(stopOnError)
- {
- CloseLog();
- StopPtyMagic();
- d->progress->Stop();
- return false;
- }
- }
+ if(stopOnError)
+ break;
+ }
}
// dpkg is done at this point
d->progress->Stop();
@@ -1577,10 +1587,10 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
}
Cache.writeStateFile(NULL);
- return true;
+ return d->dpkg_error.empty();
}
-void SigINT(int sig) {
+void SigINT(int /*sig*/) {
pkgPackageManager::SigINTStop = true;
}
/*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 02e12a6d9..859c74b46 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -11,11 +11,20 @@
#define PKGLIB_DPKGPM_H
#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
+
#include <vector>
#include <map>
#include <stdio.h>
-#include <apt-pkg/macros.h>
+#include <string>
+
+#ifndef APT_10_CLEANER_HEADERS
#include <apt-pkg/init.h>
+#endif
+
+class pkgDepCache;
+namespace APT { namespace Progress { class PackageManager; } }
#ifndef APT_8_CLEANER_HEADERS
using std::vector;
@@ -82,7 +91,7 @@ class pkgDPkgPM : public pkgPackageManager
// Helpers
bool RunScriptsWithPkgs(const char *Cnf);
- __deprecated bool SendV2Pkgs(FILE *F);
+ APT_DEPRECATED bool SendV2Pkgs(FILE *F);
bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
void WriteHistoryTag(std::string const &tag, std::string value);
std::string ExpandShortPackageName(pkgDepCache &Cache,
@@ -109,10 +118,10 @@ class pkgDPkgPM : public pkgPackageManager
void DoDpkgStatusFd(int statusfd);
void ProcessDpkgStatusLine(char *line);
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
- void DoDpkgStatusFd(int statusfd, int unused) {
+ void DoDpkgStatusFd(int statusfd, int /*unused*/) {
DoDpkgStatusFd(statusfd);
}
- void ProcessDpkgStatusLine(int unused, char *line) {
+ void ProcessDpkgStatusLine(int /*unused*/, char *line) {
ProcessDpkgStatusLine(line);
}
#endif