From 565ded7b65240b25ad8551789ac388c8ce72b1f4 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Date: Tue, 25 Feb 2014 00:12:20 +0100 Subject: implement BuildProfileSpec support as dpkg has in 1.17.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build-dependencies are now able to include a specification limiting usage similar to already supported [arch …]. More details: https://wiki.debian.org/BuildProfileSpec Closes: 661537 --- apt-pkg/deb/deblistparser.cc | 91 ++++++++++++++++++++++++++++++++++++++++++-- apt-pkg/deb/deblistparser.h | 17 +++++++-- apt-pkg/deb/debsrcrecords.cc | 2 +- 3 files changed, 101 insertions(+), 9 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index acdcc4554..a4795f15d 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -474,18 +474,31 @@ 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 +615,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 const profiles = _config->FindVector("APT::Build-Profiles"); + + 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 +718,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(':'); diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 386d291a2..0531b20f3 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -72,11 +72,20 @@ 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 = ""); diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index ce55ccd1f..90182b4a4 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -90,7 +90,7 @@ bool debSrcRecordParser::BuildDepends(std::vectorError("Problem parsing dependency: %s", fields[I]); -- cgit v1.2.3 From ce7f128c020e1347f91c6074238fc5da58c5df71 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 14:26:18 +0100 Subject: support DEB_BUILD_PROFILES and -P for build profiles Inspired by the rest of the patch in 661537, but abstract the parsing of various ways of setting the build profiles more so it can potentially be reused and all apt parts have the same behaviour. Especially config options, cmdline options and environment will not be combined as proposed as this isn't APTs usual behaviour and dpkg doesn't do it either, so one overrides the other as it normally does. --- apt-pkg/deb/deblistparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index a4795f15d..89f3514c9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -625,7 +625,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, if (unlikely(I == Stop)) return 0; - std::vector const profiles = _config->FindVector("APT::Build-Profiles"); + std::vector const profiles = APT::Configuration::getBuildProfiles(); const char *End = I; bool Found = false; -- cgit v1.2.3 From 67c3067f1a615fd6ff0b332c2a526d052442913d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 22:22:41 +0100 Subject: fix -Wmissing-field-initializers warnings Reported-By: gcc Git-Dch: Ignore --- apt-pkg/deb/deblistparser.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 89f3514c9..3374865ac 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -34,7 +34,7 @@ static debListParser::WordList PrioList[] = { {"standard",pkgCache::State::Standard}, {"optional",pkgCache::State::Optional}, {"extra",pkgCache::State::Extra}, - {}}; + {NULL, 0}}; // ListParser::debListParser - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -354,7 +354,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 +370,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 +392,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"); -- cgit v1.2.3 From e788a834ce421042e727b72e43177edaa47e53a7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 02:18:11 +0100 Subject: warning: useless cast to type A [-Wuseless-cast] Git-Dch: Ignore Reported-By: gcc -Wuseless-cast --- apt-pkg/deb/debsrcrecords.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 90182b4a4..daa54d036 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -57,7 +57,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 /*{{{*/ -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- apt-pkg/deb/debindexfile.h | 2 +- apt-pkg/deb/dpkgpm.cc | 2 +- apt-pkg/deb/dpkgpm.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index 9e64d4476..e079d40c2 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -33,7 +33,7 @@ class debStatusIndex : public pkgIndexFile virtual const Type *GetType() 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; diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 91893c4e1..adf59516e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1581,7 +1581,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) return true; } -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..c144f78e1 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -109,10 +109,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 -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-pkg/deb/debindexfile.cc | 14 ++++++++++-- apt-pkg/deb/debindexfile.h | 10 ++++++++- apt-pkg/deb/deblistparser.cc | 9 ++++++++ apt-pkg/deb/deblistparser.h | 7 ++++++ apt-pkg/deb/debmetaindex.cc | 11 ++++++++-- apt-pkg/deb/debmetaindex.h | 8 ++++++- apt-pkg/deb/debrecords.cc | 8 ++++++- apt-pkg/deb/debrecords.h | 3 +++ apt-pkg/deb/debsrcrecords.cc | 11 ++++++++-- apt-pkg/deb/debsrcrecords.h | 7 +++++- apt-pkg/deb/debsystem.cc | 9 +++++++- apt-pkg/deb/debsystem.h | 10 ++++++++- apt-pkg/deb/debversion.cc | 2 ++ apt-pkg/deb/debversion.h | 6 ++--- apt-pkg/deb/dpkgpm.cc | 52 ++++++++++++++++++++++++-------------------- apt-pkg/deb/dpkgpm.h | 13 +++++++++-- 16 files changed, 139 insertions(+), 41 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 909dfcf47..1b35d0d52 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -23,7 +22,18 @@ #include #include #include - +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index e079d40c2..3bcb3b64f 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 +#include +#include +#include +#include + +class OpProgress; +class pkgAcquire; +class pkgCacheGenerator; -#include class debStatusIndex : public pkgIndexFile { diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 3374865ac..7777d654e 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -21,8 +21,17 @@ #include #include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 0531b20f3..c0973260f 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -13,11 +13,18 @@ #include #include +#include +#include + +#include +#include #ifndef APT_8_CLEANER_HEADERS #include #endif +class FileFd; + class debListParser : public pkgCacheGenerator::ListParser { public: 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 #include #include -#include - +#include +#include +#include + +#include +#include +#include +#include +#include #include #include 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 -#include +#include #include #include @@ -12,6 +12,12 @@ #ifndef APT_8_CLEANER_HEADERS #include #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#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 #include -#include #include #include +#include +#include +#include +#include +#include +#include +#include #include /*}}}*/ 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 #include #include +#include + +#include #ifndef APT_8_CLEANER_HEADERS #include diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index daa54d036..b09588dd3 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -15,12 +15,19 @@ #include #include #include -#include #include +#include +#include -using std::max; +#include +#include +#include +#include +#include +#include /*}}}*/ +using std::max; using std::string; // SrcRecordParser::Binaries - Return the binaries field /*{{{*/ 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 #include #include +#include +#include +#include + +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..db557e537 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -19,7 +19,14 @@ #include #include #include -#include +#include +#include + +#include +#include +#include +#include +#include #include #include #include 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 #include +#include +#include +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 #include +#include +#include #include #include /*}}}*/ diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h index f1d6f3cc5..981ea9ad2 100644 --- a/apt-pkg/deb/debversion.h +++ b/apt-pkg/deb/debversion.h @@ -12,12 +12,12 @@ #ifndef PKGLIB_DEBVERSION_H #define PKGLIB_DEBVERSION_H +#include +#include -#include - class debVersioningSystem : public pkgVersioningSystem -{ +{ public: static int CmpFragment(const char *A, const char *AEnd, const char *B, diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index adf59516e..9fee7c923 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -10,41 +10,45 @@ // Includes /*{{{*/ #include -#include -#include +#include #include #include -#include -#include +#include +#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index c144f78e1..859c74b46 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -11,11 +11,20 @@ #define PKGLIB_DPKGPM_H #include +#include +#include + #include #include #include -#include +#include + +#ifndef APT_10_CLEANER_HEADERS #include +#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, -- cgit v1.2.3 From a02db58fd50ef7fc2f0284852c6b3f98e458a232 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 00:33:10 +0100 Subject: follow method attribute suggestions by gcc Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn} --- apt-pkg/deb/debindexfile.cc | 2 +- apt-pkg/deb/debindexfile.h | 8 ++++---- apt-pkg/deb/debsystem.cc | 2 +- apt-pkg/deb/debversion.h | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 1b35d0d52..eee758b7a 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -660,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 3bcb3b64f..017c69a0a 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -38,7 +38,7 @@ 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;}; @@ -71,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; @@ -110,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; @@ -142,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/debsystem.cc b/apt-pkg/deb/debsystem.cc index db557e537..142f3a6e6 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -202,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/debversion.h b/apt-pkg/deb/debversion.h index 981ea9ad2..434ff4a2e 100644 --- a/apt-pkg/deb/debversion.h +++ b/apt-pkg/deb/debversion.h @@ -19,19 +19,19 @@ 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(); -- cgit v1.2.3 From e33dbfe5cea09b2124be8db5a6ae0eb82ad7e9c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 16:53:44 +0100 Subject: factor out parsing of MultiArch flag Git-Dch: Ignore --- apt-pkg/deb/deblistparser.cc | 47 ++++++++++++++++++++++++-------------------- apt-pkg/deb/deblistparser.h | 3 +++ 2 files changed, 29 insertions(+), 21 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 7777d654e..18b8b931d 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -104,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) diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index c0973260f..03733ae8c 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -97,6 +97,9 @@ class debListParser : public pkgCacheGenerator::ListParser debListParser(FileFd *File, std::string const &Arch = ""); virtual ~debListParser() {}; + + private: + unsigned char ParseMultiArch(bool const showErrors); }; #endif -- cgit v1.2.3 From 68134bda8868a8614edf137aad7e9be61cd2a6ee Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 17:55:08 +0100 Subject: abstract version hash comparison a bit In #737085 we see that apt can be confused if informations about versions only differ slightly. This commit adds a way of at least adding a few more data points with the next abi break to help a bit with it. Git-Dch: Ignore --- apt-pkg/deb/deblistparser.cc | 21 +++++++++++++++++++++ apt-pkg/deb/deblistparser.h | 3 +++ 2 files changed, 24 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 18b8b931d..a1bcfb710 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -938,3 +938,24 @@ unsigned char debListParser::GetPrio(string Str) return Out; } /*}}}*/ +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/ + pkgCache::VerIterator const &Ver) +{ + if (pkgCacheGenerator::ListParser::SameVersion(Hash, Ver) == false) + return false; + // status file has no (Download)Size, but all others are fair game + // status file is parsed last, so the first version we encounter is + // probably also the version we have downloaded + unsigned long long const Size = Section.FindULL("Size"); + if (Size != 0 && Size != Ver->Size) + return false; + // available everywhere, but easier to check here than to include in VersionHash + unsigned char MultiArch = ParseMultiArch(false); + if (MultiArch != Ver->MultiArch) + return false; + // for all practical proposes (we can check): same version + return true; +} + /*}}}*/ +#endif diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 03733ae8c..286244cc9 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -70,6 +70,9 @@ class debListParser : public pkgCacheGenerator::ListParser virtual std::string DescriptionLanguage(); virtual MD5SumValue Description_md5(); virtual unsigned short VersionHash(); +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) + virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver); +#endif virtual bool UsePackage(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver); virtual unsigned long Offset() {return iOffset;}; -- cgit v1.2.3 From ce62f1def6565375ce9c56eb1237ccdc0ca138ba Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 16:26:01 +0100 Subject: mark optional (private) symbols as hidden This methods should not be used by anyone expect the library itself as they are helpers for the specific class and therefore perfect candidates for hidding. Git-Dch: Ignore --- apt-pkg/deb/deblistparser.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 286244cc9..baace79fe 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -102,7 +103,7 @@ class debListParser : public pkgCacheGenerator::ListParser virtual ~debListParser() {}; private: - unsigned char ParseMultiArch(bool const showErrors); + APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors); }; #endif -- cgit v1.2.3 From d151adbf2cc4d23c240c6c4fcfbfda439a98c36f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 22 Mar 2014 21:35:57 +0100 Subject: ensure proper teardown in dpkg error cases We have to properly close our pseudo terminals even in error cases before we call post-invoke scripts. This is done now by breaking from the dpkg calling loop instead of copying the handling, which did it in the wrong order before. This also ensures that our state file is written in error cases to record autobit and co as this was forgotten before. Closes: 738969 --- apt-pkg/deb/dpkgpm.cc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 9fee7c923..5a5fff13b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1530,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(); @@ -1582,7 +1572,7 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) } Cache.writeStateFile(NULL); - return true; + return d->dpkg_error.empty(); } void SigINT(int /*sig*/) { -- cgit v1.2.3 From e5b7e019232f89a97e8ba3cbffa295595daa0351 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 1 Apr 2014 11:30:00 +0200 Subject: Add new Debug::RunScripts option This debug option will display all scripts that are run by apts RunScripts and RunScriptsWithPkgs helpers. --- apt-pkg/deb/dpkgpm.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5a5fff13b..e68c2ca34 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -410,6 +410,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; -- cgit v1.2.3 From 26b3ade25dc90ab9288fcdd19af747eb62743013 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 1 Apr 2014 12:17:17 +0200 Subject: do not crash on SIGPIPE in pkgDPkgPM::RunScriptsWithPkgs() If a external command closes the PIPE unexpectedly, do not crash in pkgDPkgPM::RunScriptsWithPkgs but ignore the SIGPIPE. --- apt-pkg/deb/dpkgpm.cc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e68c2ca34..c3e7e1d1d 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -399,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++) @@ -428,8 +432,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) std::set 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 @@ -463,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) @@ -492,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 /*{{{*/ -- cgit v1.2.3 From 6c50447eb443768764f83b3ba86ef32780ba6dde Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Apr 2014 14:41:35 +0200 Subject: reduce delta from ubuntu --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c3e7e1d1d..c52b83c6e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1617,7 +1617,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) string::size_type pos; FILE *report; - if (_config->FindB("Dpkg::ApportFailureReport", false) == false) + if (_config->FindB("Dpkg::ApportFailureReport", true) == false) { std::clog << "configured to not write apport reports" << std::endl; return; -- cgit v1.2.3 From a11f6c973bc0dc226d8953e3edb6333d526c3143 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 30 Apr 2014 17:04:29 +0200 Subject: Only do openpty() if both stdin/stdout are terminals Closes: 746434 --- apt-pkg/deb/dpkgpm.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c52b83c6e..e410594df 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1053,14 +1053,15 @@ void pkgDPkgPM::StartPtyMagic() } // setup the pty and stuff - struct winsize win; + struct winsize win; - // if tcgetattr does not return zero there was a error - // and we do not do any pty magic + // if tcgetattr for both stdin/stdout returns 0 (no error) + // we do the pty magic _error->PushToStack(); - if (tcgetattr(STDOUT_FILENO, &d->tt) == 0) + if (tcgetattr(STDIN_FILENO, &d->tt) == 0 && + tcgetattr(STDOUT_FILENO, &d->tt) == 0) { - if (ioctl(1, TIOCGWINSZ, (char *)&win) < 0) + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) < 0) { _error->Errno("ioctl", _("ioctl(TIOCGWINSZ) failed")); } else if (openpty(&d->master, &d->slave, NULL, &d->tt, &win) < 0) -- cgit v1.2.3