diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-04-01 12:28:56 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-04-01 12:28:56 +0200 |
commit | be20eef52da4b7f361333ea70a8d705a98ae779e (patch) | |
tree | 4177a110ce6b1335fc4b85d5e53b298a65661f39 /apt-pkg/deb | |
parent | a555cf8be53d8b5557f004ecbde8482a169b79f3 (diff) | |
parent | 21b3eac8f9ab8e12b43fa8998a5aa5465f29adc5 (diff) |
Merge remote-tracking branch 'upstream/debian/sid' into feature/apt-manpage
Conflicts:
cmdline/apt.cc
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 16 | ||||
-rw-r--r-- | apt-pkg/deb/debindexfile.h | 20 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 178 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 31 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.cc | 11 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.h | 8 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.cc | 8 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.h | 3 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.cc | 15 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.h | 13 | ||||
-rw-r--r-- | apt-pkg/deb/debsystem.cc | 13 | ||||
-rw-r--r-- | apt-pkg/deb/debsystem.h | 10 | ||||
-rw-r--r-- | apt-pkg/deb/debversion.cc | 6 | ||||
-rw-r--r-- | apt-pkg/deb/debversion.h | 20 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 115 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.h | 17 |
16 files changed, 352 insertions, 132 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 68d544e1f..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(':'); @@ -758,7 +855,7 @@ bool debListParser::GrabWord(string Word,WordList *List,unsigned char &Out) /*}}}*/ // ListParser::Step - Move to the next section in the file /*{{{*/ // --------------------------------------------------------------------- -/* This has to be carefull to only process the correct architecture */ +/* This has to be careful to only process the correct architecture */ bool debListParser::Step() { iOffset = Tags.Offset(); @@ -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 5d2a67f4f..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) */ @@ -30,7 +35,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser public: - virtual bool Restart() {return Tags.Jump(Sect,0);}; + 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);}; @@ -50,8 +55,8 @@ class debSrcRecordParser : public pkgSrcRecords::Parser virtual bool Files(std::vector<pkgSrcRecords::File> &F); debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) - : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), - Buffer(NULL) {} + : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), + iOffset(0), Buffer(NULL) {} virtual ~debSrcRecordParser(); }; diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 7ed6936c3..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> @@ -193,9 +200,9 @@ bool debSystem::Initialize(Configuration &Cnf) /*}}}*/ // System::ArchiveSupported - Is a file format supported /*{{{*/ // --------------------------------------------------------------------- -/* The standard name for a deb is 'deb'.. There are no seperate versions +/* 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 140561262..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> /*}}}*/ @@ -116,7 +118,7 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, return 1; } - // Shouldnt happen + // Shouldn't happen return 1; } /*}}}*/ @@ -221,7 +223,7 @@ bool debVersioningSystem::CheckDep(const char *PkgVer, if (PkgVer == DepVer) return Op == pkgCache::Dep::Equals || Op == pkgCache::Dep::LessEq || Op == pkgCache::Dep::GreaterEq; - // Perform the actual comparision. + // Perform the actual comparison. int const Res = CmpVersion(PkgVer, DepVer); switch (Op) { 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 14ce133cf..5a5fff13b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -10,41 +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 <string.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> /*}}}*/ @@ -568,7 +572,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line) std::string prefix = APT::String::Strip(list[0]); std::string pkgname; std::string action; - ostringstream status; // "processing" has the form "processing: action: pkg or trigger" // with action = ["install", "configure", "remove", "purge", "disappear", @@ -1028,6 +1031,12 @@ bool pkgDPkgPM::Go(int StatusFd) void pkgDPkgPM::StartPtyMagic() { + if (_config->FindB("Dpkg::Use-Pty", true) == false) + { + d->master = d->slave = -1; + return; + } + // setup the pty and stuff struct winsize win; @@ -1036,10 +1045,9 @@ void pkgDPkgPM::StartPtyMagic() _error->PushToStack(); if (tcgetattr(STDOUT_FILENO, &d->tt) == 0) { - ioctl(1, TIOCGWINSZ, (char *)&win); - if (_config->FindB("Dpkg::Use-Pty", true) == false) + if (ioctl(1, TIOCGWINSZ, (char *)&win) < 0) { - d->master = d->slave = -1; + _error->Errno("ioctl", _("ioctl(TIOCGWINSZ) failed")); } else if (openpty(&d->master, &d->slave, NULL, &d->tt, &win) < 0) { _error->Errno("openpty", _("Can not write log (%s)"), _("Is /dev/pts mounted?")); @@ -1393,12 +1401,17 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) if(d->slave >= 0 && d->master >= 0) { setsid(); - ioctl(d->slave, TIOCSCTTY, 0); - close(d->master); - dup2(d->slave, 0); - dup2(d->slave, 1); - dup2(d->slave, 2); - close(d->slave); + int res = ioctl(d->slave, TIOCSCTTY, 0); + if (res < 0) { + std::cerr << "ioctl(TIOCSCTTY) failed for fd: " + << d->slave << std::endl; + } else { + close(d->master); + dup2(d->slave, 0); + dup2(d->slave, 1); + dup2(d->slave, 2); + close(d->slave); + } } close(fd[0]); // close the read end of the pipe @@ -1517,28 +1530,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(); @@ -1569,10 +1572,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; } /*}}}*/ @@ -1652,7 +1655,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) io_errors.push_back(string("failed in write on buffer copy for %s")); io_errors.push_back(string("short read on buffer copy for %s")); - for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); I++) + for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I) { vector<string> list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%'); if (list.size() > 1) { @@ -1767,13 +1770,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) string histfile_name = _config->FindFile("Dir::Log::History"); if (!histfile_name.empty()) { - FILE *log = NULL; - char buf[1024]; - fprintf(report, "DpkgHistoryLog:\n"); - log = fopen(histfile_name.c_str(),"r"); + FILE* log = fopen(histfile_name.c_str(),"r"); if(log != NULL) { + char buf[1024]; while( fgets(buf, sizeof(buf), log) != NULL) fprintf(report, " %s", buf); fclose(log); 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 |