From ed9665aedf77b3b8345bd4ed33de7885738e29f0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Feb 2014 16:46:05 +0100 Subject: initial version of apt-helper --- apt-pkg/acquire-item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 36bb48382..de03011bf 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -2201,7 +2201,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, if (stat(DestFile.c_str(),&Buf) == 0) { // Hmm, the partial file is too big, erase it - if ((unsigned long long)Buf.st_size > Size) + if ((Size > 0) && (unsigned long long)Buf.st_size > Size) unlink(DestFile.c_str()); else PartialSize = Buf.st_size; -- cgit v1.2.3 From e43a426e5d402d36eb180935fbbf1430a4a86e3f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Feb 2014 16:46:05 +0100 Subject: initial version of apt-helper --- apt-pkg/acquire-item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 36bb48382..de03011bf 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -2201,7 +2201,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, if (stat(DestFile.c_str(),&Buf) == 0) { // Hmm, the partial file is too big, erase it - if ((unsigned long long)Buf.st_size > Size) + if ((Size > 0) && (unsigned long long)Buf.st_size > Size) unlink(DestFile.c_str()); else PartialSize = Buf.st_size; -- cgit v1.2.3 From c1409d1be88557529c62883be3174793481233de Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Mar 2014 20:33:05 +0100 Subject: add hashsum support in apt-file download and add more tests --- apt-pkg/contrib/fileutl.cc | 11 +++++++++++ apt-pkg/contrib/fileutl.h | 1 + 2 files changed, 12 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 52411a762..79bcf112c 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1841,3 +1841,14 @@ std::string GetTempDir() return string(tmpdir); } + +bool Rename(std::string From, std::string To) +{ + if (rename(From.c_str(),To.c_str()) != 0) + { + _error->Error(_("rename failed, %s (%s -> %s)."),strerror(errno), + From.c_str(),To.c_str()); + return false; + } + return true; +} diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index e752e9621..f0569b6fd 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -164,6 +164,7 @@ bool RealFileExists(std::string File); bool DirectoryExists(std::string const &Path) __attrib_const; bool CreateDirectory(std::string const &Parent, std::string const &Path); time_t GetModificationTime(std::string const &Path); +bool Rename(std::string From, std::string To); std::string GetTempDir(); -- cgit v1.2.3 From 8daf68e366fa9fa2794ae667f51562663856237c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 15 Feb 2014 13:38:39 +0100 Subject: propagate a negative score point along breaks/conflicts versioned -dev packages like db and boost have the problem of no dependencies which would give them a competitive advantage against an older incarnation of the -dev package, so they tend to be kept back until the old version is removed from the archive, which, if the user has older releases in its sources can take a long time (or never happens). The newer version has a conflicts/breaks against the older one, but the older one hasn't against the newer, so by giving via the conflicts the older one a reduced score the newer one can win if there is no other reason to keep it. If both have a conflict against each other the scoring will cancel itself out, so no harm done. This gives "action" a slightly bigger edge in breaks/conflicts cases than before, but holding back isn't a really good solution anyway. --- apt-pkg/algorithms.cc | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 0363ab3e2..db1ebd7e3 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -394,8 +394,18 @@ void pkgProblemResolver::MakeScores() }; int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100); int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1); - int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1); - int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1); + int DepMap[] = { + 0, + _config->FindI("pkgProblemResolver::Scores::Depends",1), + _config->FindI("pkgProblemResolver::Scores::PreDepends",1), + _config->FindI("pkgProblemResolver::Scores::Suggests",0), + _config->FindI("pkgProblemResolver::Scores::Recommends",1), + _config->FindI("pkgProblemResolver::Scores::Conflicts",-1), + _config->FindI("pkgProblemResolver::Scores::Replaces",0), + _config->FindI("pkgProblemResolver::Scores::Obsoletes",0), + _config->FindI("pkgProblemResolver::Scores::Breaks",-1), + _config->FindI("pkgProblemResolver::Scores::Enhances",0) + }; int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000); int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000); @@ -408,8 +418,15 @@ void pkgProblemResolver::MakeScores() << " Extra => " << PrioMap[pkgCache::State::Extra] << endl << " Essentials => " << PrioEssentials << endl << " InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl - << " Depends => " << PrioDepends << endl - << " Recommends => " << PrioRecommends << endl + << " Pre-Depends => " << DepMap[pkgCache::Dep::PreDepends] << endl + << " Depends => " << DepMap[pkgCache::Dep::Depends] << endl + << " Recommends => " << DepMap[pkgCache::Dep::Recommends] << endl + << " Suggests => " << DepMap[pkgCache::Dep::Suggests] << endl + << " Conflicts => " << DepMap[pkgCache::Dep::Conflicts] << endl + << " Breaks => " << DepMap[pkgCache::Dep::DpkgBreaks] << endl + << " Replaces => " << DepMap[pkgCache::Dep::Replaces] << endl + << " Obsoletes => " << DepMap[pkgCache::Dep::Obsoletes] << endl + << " Enhances => " << DepMap[pkgCache::Dep::Enhances] << endl << " AddProtected => " << AddProtected << endl << " AddEssential => " << AddEssential << endl; @@ -446,17 +463,11 @@ void pkgProblemResolver::MakeScores() { if (Cache[I].InstallVer == 0) continue; - + for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) - { - if (D->Type == pkgCache::Dep::Depends || - D->Type == pkgCache::Dep::PreDepends) - Scores[D.TargetPkg()->ID] += PrioDepends; - else if (D->Type == pkgCache::Dep::Recommends) - Scores[D.TargetPkg()->ID] += PrioRecommends; - } - } - + Scores[D.TargetPkg()->ID] += DepMap[D->Type]; + } + // Copy the scores to advoid additive looping SPtrArray OldScores = new int[Size]; memcpy(OldScores,Scores,sizeof(*Scores)*Size); -- cgit v1.2.3 From cb4b85b0bdba6a0c43ca62259dcd35fccd38a45a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 15 Feb 2014 14:47:24 +0100 Subject: do not do the same looping twice Git-Dch: Ignore --- apt-pkg/algorithms.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index db1ebd7e3..4d86e5ff8 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -456,14 +456,8 @@ void pkgProblemResolver::MakeScores() */ if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable()) Score += PrioInstalledAndNotObsolete; - } - - // Now that we have the base scores we go and propagate dependencies - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) - { - if (Cache[I].InstallVer == 0) - continue; + // propagate score points along dependencies for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) Scores[D.TargetPkg()->ID] += DepMap[D->Type]; } -- cgit v1.2.3 From 2252183c69fb5e3e020b45c37d9728b3437d797d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 23 Feb 2014 22:22:15 +0100 Subject: show debug output only if told so in packagemanager Git-Dch: Ignore --- apt-pkg/packagemanager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 5f9a31264..0be76b311 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -741,7 +741,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c // See if the current version is conflicting if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) { - clog << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl; + if (Debug) + clog << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl; /* If a loop is not present or has not yet been detected, attempt to unpack packages to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */ if (List->IsFlag(ConflictPkg,pkgOrderList::Loop) == false) -- cgit v1.2.3 From 9ec748ff103840c4c65471ca00d3b72984131ce4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 23 Feb 2014 22:24:27 +0100 Subject: check version before adding scores in resolver Prevents that "old" dependencies have an influence in the scoring. With positive dependencies this is usually not a problem, but negative dependencies can linger around for a long time. --- apt-pkg/algorithms.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 4d86e5ff8..8320e7ef0 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -459,7 +459,18 @@ void pkgProblemResolver::MakeScores() // propagate score points along dependencies for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) - Scores[D.TargetPkg()->ID] += DepMap[D->Type]; + { + if (DepMap[D->Type] == 0) + continue; + pkgCache::PkgIterator const T = D.TargetPkg(); + if (D->Version != 0) + { + pkgCache::VerIterator const IV = Cache[T].InstVerIter(Cache); + if (IV.end() == true || D.IsSatisfied(IV) != D.IsNegative()) + continue; + } + Scores[T->ID] += DepMap[D->Type]; + } } // Copy the scores to advoid additive looping -- cgit v1.2.3 From a5414e56403537678d5be87acf59c37a05f55719 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 24 Feb 2014 23:10:25 +0100 Subject: add default and override handling for Cnf::FindVector Automatically handle the override of list options via its parent value which can even be a comma-separated list of values. It also adds an easy way of providing a default for the list. --- apt-pkg/aptconfiguration.cc | 72 ++++++---------------------------------- apt-pkg/contrib/configuration.cc | 14 ++++++-- apt-pkg/contrib/configuration.h | 16 ++++++++- apt-pkg/contrib/strutl.cc | 4 ++- 4 files changed, 41 insertions(+), 65 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 0b0b546c5..f5c758e14 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -49,11 +49,6 @@ const Configuration::getCompressionTypes(bool const &Cached) { setDefaultConfigurationForCompressors(); std::vector const compressors = getCompressors(); - // accept non-list order as override setting for config settings on commandline - std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order",""); - if (overrideOrder.empty() == false) - types.push_back(overrideOrder); - // load the order setting into our vector std::vector const order = _config->FindVector("Acquire::CompressionTypes::Order"); for (std::vector::const_iterator o = order.begin(); @@ -227,61 +222,11 @@ std::vector const Configuration::getLanguages(bool const &All, } } } else { + // cornercase: LANG=C, so we use only "en" Translation environment.push_back("en"); } - // Support settings like Acquire::Languages=none on the command line to - // override the configuration settings vector of languages. - string const forceLang = _config->Find("Acquire::Languages",""); - if (forceLang.empty() == false) { - if (forceLang == "none") { - codes.clear(); - allCodes.clear(); - allCodes.push_back("none"); - } else { - if (forceLang == "environment") - codes = environment; - else - codes.push_back(forceLang); - allCodes = codes; - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); - } - if (All == true) - return allCodes; - else - return codes; - } - - // cornercase: LANG=C, so we use only "en" Translation - if (envShort == "C") { - allCodes = codes = environment; - allCodes.insert(allCodes.end(), builtin.begin(), builtin.end()); - if (All == true) - return allCodes; - else - return codes; - } - - std::vector const lang = _config->FindVector("Acquire::Languages"); - // the default setting -> "environment, en" - if (lang.empty() == true) { - codes = environment; - if (envShort != "en") - codes.push_back("en"); - allCodes = codes; - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); - if (All == true) - return allCodes; - else - return codes; - } - + std::vector const lang = _config->FindVector("Acquire::Languages", "environment,en"); // the configs define the order, so add the environment // then needed and ensure the codes are not listed twice. bool noneSeen = false; @@ -308,10 +253,15 @@ std::vector const Configuration::getLanguages(bool const &All, allCodes.push_back(*l); } - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); + if (allCodes.empty() == false) { + for (std::vector::const_iterator b = builtin.begin(); + b != builtin.end(); ++b) + if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) + allCodes.push_back(*b); + } else { + // "none" was forced + allCodes.push_back("none"); + } if (All == true) return allCodes; diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 4ef4663c0..8eddd56d4 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -246,12 +247,18 @@ string Configuration::FindDir(const char *Name,const char *Default) const // Configuration::FindVector - Find a vector of values /*{{{*/ // --------------------------------------------------------------------- /* Returns a vector of config values under the given item */ -vector Configuration::FindVector(const char *Name) const +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) +vector Configuration::FindVector(const char *Name) const { return FindVector(Name, ""); } +#endif +vector Configuration::FindVector(const char *Name, std::string const &Default) const { vector Vec; const Item *Top = Lookup(Name); if (Top == NULL) - return Vec; + return VectorizeString(Default, ','); + + if (Top->Value.empty() == false) + return VectorizeString(Top->Value, ','); Item *I = Top->Child; while(I != NULL) @@ -259,6 +266,9 @@ vector Configuration::FindVector(const char *Name) const Vec.push_back(I->Value); I = I->Next; } + if (Vec.empty() == true) + return VectorizeString(Default, ','); + return Vec; } /*}}}*/ diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 8e09ea0a6..c256139f4 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -74,8 +74,22 @@ class Configuration std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());}; std::string FindFile(const char *Name,const char *Default = 0) const; std::string FindDir(const char *Name,const char *Default = 0) const; + /** return a list of child options + * + * Options like Acquire::Languages are handled as lists which + * can be overridden and have a default. For the later two a comma + * separated list of values is supported. + * + * \param Name of the parent node + * \param Default list of values separated by commas */ + std::vector FindVector(const char *Name, std::string const &Default) const; + std::vector FindVector(std::string const &Name, std::string const &Default) const { return FindVector(Name.c_str(), Default); }; +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) + std::vector FindVector(const char *Name) const { return FindVector(Name, ""); }; +#else std::vector FindVector(const char *Name) const; - std::vector FindVector(std::string const &Name) const { return FindVector(Name.c_str()); }; +#endif + std::vector FindVector(std::string const &Name) const { return FindVector(Name.c_str(), ""); }; int FindI(const char *Name,int const &Default = 0) const; int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);}; bool FindB(const char *Name,bool const &Default = false) const; diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index d4f53ea3a..f8bb3890d 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1130,9 +1130,11 @@ bool TokSplitString(char Tok,char *Input,char **List, also, but the advantage is that we have an iteratable vector */ vector VectorizeString(string const &haystack, char const &split) { + vector exploded; + if (haystack.empty() == true) + return exploded; string::const_iterator start = haystack.begin(); string::const_iterator end = start; - vector exploded; do { for (; end != haystack.end() && *end != split; ++end); exploded.push_back(string(start, end)); -- cgit v1.2.3 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') 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/aptconfiguration.cc | 26 +++++++++++++++++++++++++- apt-pkg/aptconfiguration.h | 5 +++++ apt-pkg/deb/deblistparser.cc | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index f5c758e14..3948854c6 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -426,7 +426,7 @@ void Configuration::setDefaultConfigurationForCompressors() { } } /*}}}*/ -// getCompressors - Return Vector of usbale compressors /*{{{*/ +// getCompressors - Return Vector of usealbe compressors /*{{{*/ // --------------------------------------------------------------------- /* return a vector of compressors used by apt-ftparchive in the multicompress functionality or to detect data.tar files */ @@ -508,4 +508,28 @@ Configuration::Compressor::Compressor(char const *name, char const *extension, UncompressArgs.push_back(uncompressArg); } /*}}}*/ +// getBuildProfiles - return a vector of enabled build profiles /*{{{*/ +std::vector const Configuration::getBuildProfiles() { + // order is: override value (~= commandline), environment variable, list (~= config file) + std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES"); + if (profiles_env.empty() == false) { + profiles_env = SubstVar(profiles_env, " ", ","); + std::string const bp = _config->Find("APT::Build-Profiles"); + _config->Clear("APT::Build-Profiles"); + if (bp.empty() == false) + _config->Set("APT::Build-Profiles", bp); + } + return _config->FindVector("APT::Build-Profiles", profiles_env); +} +std::string const Configuration::getBuildProfilesString() { + std::vector profiles = getBuildProfiles(); + if (profiles.empty() == true) + return ""; + std::vector::const_iterator p = profiles.begin(); + std::string list = *p; + for (; p != profiles.end(); ++p) + list.append(",").append(*p); + return list; +} + /*}}}*/ } diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index bf7deae85..026493c6d 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -117,6 +117,11 @@ public: /*{{{*/ /** \brief Return a vector of extensions supported for data.tar's */ std::vector static const getCompressorExtensions(); + + /** \return Return a vector of enabled build profile specifications */ + std::vector static const getBuildProfiles(); + /** \return Return a comma-separated list of enabled build profile specifications */ + std::string static const getBuildProfilesString(); /*}}}*/ private: /*{{{*/ void static setDefaultConfigurationForCompressors(); 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 255c9e4b74fe677d723c51d3450869ad45ca5463 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 22:10:40 +0100 Subject: make doxygen more quiet, fix issues and disable latex Git-Dch: Ignore --- apt-pkg/acquire-item.h | 15 ++++++++------- apt-pkg/acquire-worker.h | 4 ++-- apt-pkg/acquire.h | 4 ++-- apt-pkg/cachefilter.h | 2 +- apt-pkg/cacheset.h | 7 +++++-- apt-pkg/contrib/error.h | 4 ++-- apt-pkg/depcache.h | 6 +++--- apt-pkg/pkgcache.h | 8 ++++---- 8 files changed, 27 insertions(+), 23 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 5a1c7979c..0524743c6 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -64,7 +64,7 @@ class pkgAcquire::Item : public WeakPointable /** \brief Insert this item into its owner's queue. * - * \param ItemDesc Metadata about this item (its URI and + * \param Item Metadata about this item (its URI and * description). */ inline void QueueURI(ItemDesc &Item) @@ -79,7 +79,7 @@ class pkgAcquire::Item : public WeakPointable * * \param From The file to be renamed. * - * \param To The new name of #From. If #To exists it will be + * \param To The new name of \a From. If \a To exists it will be * overwritten. */ void Rename(std::string From,std::string To); @@ -115,7 +115,7 @@ class pkgAcquire::Item : public WeakPointable } Status; /** \brief Contains a textual description of the error encountered - * if #Status is #StatError or #StatAuthError. + * if #ItemState is #StatError or #StatAuthError. */ std::string ErrorText; @@ -293,7 +293,6 @@ class pkgAcquire::Item : public WeakPointable /** \brief Rename failed file and set error * * \param state respresenting the error we encountered - * \param errorMsg a message describing the error */ bool RenameOnError(RenameOnErrorState const state); }; @@ -636,7 +635,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item /** \brief Create an index diff item. * * After filling in its basic fields, this invokes Finish(true) if - * #diffs is empty, or QueueNextDiff() otherwise. + * \a diffs is empty, or QueueNextDiff() otherwise. * * \param Owner The pkgAcquire object that owns this item. * @@ -651,6 +650,8 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * reconstructed package index file; the index file will be tested * against this value when it is entirely reconstructed. * + * \param ServerSha1 is the sha1sum of the current file on the server + * * \param diffs The remaining diffs from the index of diffs. They * should be ordered so that each diff appears before any diff * that depends on it. @@ -1162,8 +1163,8 @@ class pkgAcqFile : public pkgAcquire::Item * \param IsIndexFile The file is considered a IndexFile and cache-control * headers like "cache-control: max-age=0" are send * - * If DestFilename is empty, download to DestDir/ if - * DestDir is non-empty, $CWD/ otherwise. If + * If DestFilename is empty, download to DestDir/\ if + * DestDir is non-empty, $CWD/\ otherwise. If * DestFilename is NOT empty, DestDir is ignored and DestFilename * is the absolute name to which the file should be downloaded. */ diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 848a6bad7..a558f69a7 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -136,8 +136,8 @@ class pkgAcquire::Worker : public WeakPointable /** \brief Retrieve any available messages from the subprocess. * - * The messages are retrieved as in ::ReadMessages(), and - * MessageFailure() is invoked if an error occurs; in particular, + * The messages are retrieved as in \link strutl.h ReadMessages()\endlink, and + * #MethodFailure() is invoked if an error occurs; in particular, * if the pipe to the subprocess dies unexpectedly while a message * is being read. * diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 3d5d7a4b7..2c0b37635 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -282,13 +282,13 @@ class pkgAcquire */ void Shutdown(); - /** \brief Get the first #Worker object. + /** \brief Get the first Worker object. * * \return the first active worker in this download process. */ inline Worker *WorkersBegin() {return Workers;}; - /** \brief Advance to the next #Worker object. + /** \brief Advance to the next Worker object. * * \return the worker immediately following I, or \b NULL if none * exists. diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h index 34b7d0b46..81ae1383c 100644 --- a/apt-pkg/cachefilter.h +++ b/apt-pkg/cachefilter.h @@ -47,7 +47,7 @@ public: /** \class PackageArchitectureMatchesSpecification \brief matching against architecture specification strings - The strings are of the format - where either component, + The strings are of the format \-\ where either component, or the whole string, can be the wildcard "any" as defined in debian-policy §11.1 "Architecture specification strings". diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index b69d74b8e..ce502d8ca 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -479,14 +479,16 @@ protected: /*{{{*/ /** \brief returns the candidate version of the package \param Cache to be used to query for information - \param Pkg we want the candidate version from this package */ + \param Pkg we want the candidate version from this package + \param helper used in this container instance */ static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper); /** \brief returns the installed version of the package \param Cache to be used to query for information - \param Pkg we want the installed version from this package */ + \param Pkg we want the installed version from this package + \param helper used in this container instance */ static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper); /*}}}*/ @@ -558,6 +560,7 @@ public: /*{{{*/ non specifically requested and executes regex's if needed on names. \param Cache the packages and versions are in \param cmdline Command line the versions should be extracted from + \param fallback version specification \param helper responsible for error and message handling */ static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, Version const &fallback, CacheSetHelper &helper) { diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index bcee70b1a..c06e45ee4 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -232,11 +232,11 @@ public: /*{{{*/ * if you want to check if also no notices happened set the parameter * flag to \b false. * - * \param WithoutNotice does notices count, default is \b true, so no + * \param threshold minimim level considered * * \return \b true if an the list is empty, \b false otherwise */ - bool empty(MsgType const &trashhold = WARNING) const; + bool empty(MsgType const &threshold = WARNING) const; /** \brief returns and removes the first (or last) message in the list * diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index f6848f383..a02a86b87 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -381,8 +381,8 @@ class pkgDepCache : protected pkgCache::Namespace /** \brief Update the Marked and Garbage fields of all packages. * * This routine is implicitly invoked after all state manipulators - * and when an ActionGroup is destroyed. It invokes #MarkRequired - * and #Sweep to do its dirty work. + * and when an ActionGroup is destroyed. It invokes the private + * MarkRequired() and Sweep() to do its dirty work. * * \param rootFunc A predicate that returns \b true for packages * that should be added to the root set. @@ -465,7 +465,7 @@ class pkgDepCache : protected pkgCache::Namespace * * The parameters are the same as in the calling MarkDelete: * \param Pkg the package that MarkDelete wants to remove. - * \param Purge should we purge instead of "only" remove? + * \param MarkPurge should we purge instead of "only" remove? * \param Depth recursive deep of this Marker call * \param FromUser was the remove requested by the user? */ diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index c31c5f30b..669904c84 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -451,7 +451,7 @@ struct pkgCache::PackageFile /** \brief Modification time for the file */ time_t mtime; - /* @TODO document PackageFile::Flags */ + /** @TODO document PackageFile::Flags */ unsigned long Flags; // Linked list @@ -474,7 +474,7 @@ struct pkgCache::VerFile map_ptrloc NextFile; // PkgVerFile /** \brief position in the package file */ map_ptrloc Offset; // File offset - /* @TODO document pkgCache::VerFile::Size */ + /** @TODO document pkgCache::VerFile::Size */ unsigned long Size; }; /*}}}*/ @@ -488,7 +488,7 @@ struct pkgCache::DescFile map_ptrloc NextFile; // PkgVerFile /** \brief position in the file */ map_ptrloc Offset; // File offset - /* @TODO document pkgCache::DescFile::Size */ + /** @TODO document pkgCache::DescFile::Size */ unsigned long Size; }; /*}}}*/ @@ -571,7 +571,7 @@ struct pkgCache::Description and to check that the Translation is up-to-date. */ map_ptrloc md5sum; // StringItem - /* @TODO document pkgCache::Description::FileList */ + /** @TODO document pkgCache::Description::FileList */ map_ptrloc FileList; // DescFile /** \brief next translation for this description */ map_ptrloc NextDesc; // Description -- 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 ++++---- apt-pkg/indexcopy.cc | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'apt-pkg') 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"); diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 7694cb1dd..9ea244139 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -436,8 +436,8 @@ bool PackageCopy::GetFile(string &File,unsigned long long &Size) /* */ bool PackageCopy::RewriteEntry(FILE *Target,string File) { - TFRewriteData Changes[] = {{"Filename",File.c_str()}, - {}}; + TFRewriteData Changes[] = {{ "Filename", File.c_str(), NULL }, + { NULL, NULL, NULL }}; if (TFRewrite(Target,*Section,TFRewritePackageOrder,Changes) == false) return false; @@ -482,8 +482,8 @@ bool SourceCopy::GetFile(string &File,unsigned long long &Size) bool SourceCopy::RewriteEntry(FILE *Target,string File) { string Dir(File,0,File.rfind('/')); - TFRewriteData Changes[] = {{"Directory",Dir.c_str()}, - {}}; + TFRewriteData Changes[] = {{ "Directory", Dir.c_str(), NULL }, + { NULL, NULL, NULL }}; if (TFRewrite(Target,*Section,TFRewriteSourceOrder,Changes) == false) return false; -- cgit v1.2.3 From d3e8fbb395f57954acd7a2095f02ce530a05ec6a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:20:53 +0100 Subject: =?UTF-8?q?warning:=20extra=20=E2=80=98;=E2=80=99=20[-Wpedantic]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git-Dch: Ignore Reported-By: gcc -Wpedantic --- apt-pkg/acquire.cc | 2 +- apt-pkg/cacheiterators.h | 226 +++++++++++++++++++-------------------- apt-pkg/cacheset.h | 176 +++++++++++++++--------------- apt-pkg/cdrom.cc | 6 +- apt-pkg/contrib/configuration.cc | 3 +- apt-pkg/contrib/error.cc | 2 +- apt-pkg/contrib/gpgv.h | 2 +- apt-pkg/contrib/progress.cc | 12 +-- apt-pkg/contrib/strutl.cc | 2 +- apt-pkg/contrib/strutl.h | 38 +++---- apt-pkg/depcache.cc | 4 +- apt-pkg/indexcopy.cc | 4 +- apt-pkg/install-progress.cc | 4 +- apt-pkg/install-progress.h | 32 +++--- apt-pkg/pkgcache.cc | 20 ++-- apt-pkg/pkgcache.h | 42 ++++---- apt-pkg/upgrade.h | 2 +- 17 files changed, 288 insertions(+), 289 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 120e809e1..e8fa68338 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -468,7 +468,7 @@ void pkgAcquire::Bump() pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I) { return I->NextAcquire; -}; +} /*}}}*/ // Acquire::Clean - Cleans a directory /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index ea6a4afba..ca8bc5ca0 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -55,26 +55,26 @@ template class pkgCache::Iterator : public: // Iteration virtual void operator ++(int) = 0; - virtual void operator ++() = 0; // Should be {operator ++(0);}; - inline bool end() const {return Owner == 0 || S == OwnerPointer();}; + virtual void operator ++() = 0; // Should be {operator ++(0);} + inline bool end() const {return Owner == 0 || S == OwnerPointer();} // Comparison - inline bool operator ==(const Itr &B) const {return S == B.S;}; - inline bool operator !=(const Itr &B) const {return S != B.S;}; + inline bool operator ==(const Itr &B) const {return S == B.S;} + inline bool operator !=(const Itr &B) const {return S != B.S;} // Accessors - inline Str *operator ->() {return S;}; - inline Str const *operator ->() const {return S;}; - inline operator Str *() {return S == OwnerPointer() ? 0 : S;}; - inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;}; - inline Str &operator *() {return *S;}; - inline Str const &operator *() const {return *S;}; - inline pkgCache *Cache() const {return Owner;}; + inline Str *operator ->() {return S;} + inline Str const *operator ->() const {return S;} + inline operator Str *() {return S == OwnerPointer() ? 0 : S;} + inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;} + inline Str &operator *() {return *S;} + inline Str const &operator *() const {return *S;} + inline pkgCache *Cache() const {return Owner;} // Mixed stuff - inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;}; - inline bool IsGood() const { return S && Owner && ! end();}; - inline unsigned long Index() const {return S - OwnerPointer();}; + inline void operator =(const Itr &B) {S = B.S; Owner = B.Owner;} + inline bool IsGood() const { return S && Owner && ! end();} + inline unsigned long Index() const {return S - OwnerPointer();} void ReMap(void const * const oldMap, void const * const newMap) { if (Owner == 0 || S == 0) @@ -83,8 +83,8 @@ template class pkgCache::Iterator : } // Constructors - look out for the variable assigning - inline Iterator() : S(0), Owner(0) {}; - inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}; + inline Iterator() : S(0), Owner(0) {} + inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {} }; /*}}}*/ // Group Iterator /*{{{*/ @@ -98,19 +98,19 @@ class pkgCache::GrpIterator: public Iterator { protected: inline Group* OwnerPointer() const { return (Owner != 0) ? Owner->GrpP : 0; - }; + } public: // This constructor is the 'begin' constructor, never use it. inline GrpIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { S = OwnerPointer(); operator ++(0); - }; + } virtual void operator ++(int); - virtual void operator ++() {operator ++(0);}; + virtual void operator ++() {operator ++(0);} - inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}; + inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;} inline PkgIterator PackageList() const; PkgIterator FindPkg(std::string Arch = "any") const; /** \brief find the package with the "best" architecture @@ -127,8 +127,8 @@ class pkgCache::GrpIterator: public Iterator { inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator(Owner, Trg), HashIndex(0) { if (S == 0) S = OwnerPointer(); - }; - inline GrpIterator() : Iterator(), HashIndex(0) {}; + } + inline GrpIterator() : Iterator(), HashIndex(0) {} }; /*}}}*/ @@ -139,27 +139,27 @@ class pkgCache::PkgIterator: public Iterator { protected: inline Package* OwnerPointer() const { return (Owner != 0) ? Owner->PkgP : 0; - }; + } public: // This constructor is the 'begin' constructor, never use it. inline PkgIterator(pkgCache &Owner) : Iterator(Owner), HashIndex(-1) { S = OwnerPointer(); operator ++(0); - }; + } virtual void operator ++(int); - virtual void operator ++() {operator ++(0);}; + virtual void operator ++() {operator ++(0);} enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure}; // Accessors - inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}; - inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}; + inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;} + inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;} inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge || - (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}; - inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}; - inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}; + (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);} + inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;} + inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);} inline VerIterator VersionList() const; inline VerIterator CurrentVer() const; @@ -177,8 +177,8 @@ class pkgCache::PkgIterator: public Iterator { inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator(Owner, Trg), HashIndex(0) { if (S == 0) S = OwnerPointer(); - }; - inline PkgIterator() : Iterator(), HashIndex(0) {}; + } + inline PkgIterator() : Iterator(), HashIndex(0) {} }; /*}}}*/ // Version Iterator /*{{{*/ @@ -186,12 +186,12 @@ class pkgCache::VerIterator : public Iterator { protected: inline Version* OwnerPointer() const { return (Owner != 0) ? Owner->VerP : 0; - }; + } public: // Iteration - void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;}; - inline void operator ++() {operator ++(0);}; + void operator ++(int) {if (S != Owner->VerP) S = Owner->VerP + S->NextVer;} + inline void operator ++() {operator ++(0);} // Comparison int CompareVer(const VerIterator &B) const; @@ -201,17 +201,17 @@ class pkgCache::VerIterator : public Iterator { referring to the same "real" version */ inline bool SimilarVer(const VerIterator &B) const { return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0); - }; + } // Accessors - inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}; - inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}; + inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;} + inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;} inline const char *Arch() const { if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All) return "all"; return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch; - }; - inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}; + } + inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);} inline DescIterator DescriptionList() const; DescIterator TranslatedDescription() const; @@ -219,7 +219,7 @@ class pkgCache::VerIterator : public Iterator { inline PrvIterator ProvidesList() const; inline VerFileIterator FileList() const; bool Downloadable() const; - inline const char *PriorityType() const {return Owner->Priority(S->Priority);}; + inline const char *PriorityType() const {return Owner->Priority(S->Priority);} const char *MultiArchType() const; std::string RelStr() const; @@ -229,8 +229,8 @@ class pkgCache::VerIterator : public Iterator { inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator(Owner, Trg) { if (S == 0) S = OwnerPointer(); - }; - inline VerIterator() : Iterator() {}; + } + inline VerIterator() : Iterator() {} }; /*}}}*/ // Description Iterator /*{{{*/ @@ -238,26 +238,26 @@ class pkgCache::DescIterator : public Iterator { protected: inline Description* OwnerPointer() const { return (Owner != 0) ? Owner->DescP : 0; - }; + } public: // Iteration - void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;}; - inline void operator ++() {operator ++(0);}; + void operator ++(int) {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc;} + inline void operator ++() {operator ++(0);} // Comparison int CompareDesc(const DescIterator &B) const; // Accessors - inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}; - inline const char *md5() const {return Owner->StrP + S->md5sum;}; + inline const char *LanguageCode() const {return Owner->StrP + S->language_code;} + inline const char *md5() const {return Owner->StrP + S->md5sum;} inline DescFileIterator FileList() const; - inline DescIterator() : Iterator() {}; + inline DescIterator() : Iterator() {} inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator(Owner, Trg) { if (S == 0) S = Owner.DescP; - }; + } }; /*}}}*/ // Dependency iterator /*{{{*/ @@ -267,21 +267,21 @@ class pkgCache::DepIterator : public Iterator { protected: inline Dependency* OwnerPointer() const { return (Owner != 0) ? Owner->DepP : 0; - }; + } public: // Iteration void operator ++(int) {if (S != Owner->DepP) S = Owner->DepP + - (Type == DepVer ? S->NextDepends : S->NextRevDepends);}; - inline void operator ++() {operator ++(0);}; + (Type == DepVer ? S->NextDepends : S->NextRevDepends);} + inline void operator ++() {operator ++(0);} // Accessors - inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;}; - inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);}; - inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}; - inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}; - inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);}; - inline bool Reverse() const {return Type == DepRev;}; + inline const char *TargetVer() const {return S->Version == 0?0:Owner->StrP + S->Version;} + inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->Package);} + inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;} + inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);} + inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);} + inline bool Reverse() const {return Type == DepRev;} bool IsCritical() const; bool IsNegative() const; bool IsIgnorable(PrvIterator const &Prv) const; @@ -292,8 +292,8 @@ class pkgCache::DepIterator : public Iterator { void GlobOr(DepIterator &Start,DepIterator &End); Version **AllTargets() const; bool SmartTargetPkg(PkgIterator &Result) const; - inline const char *CompType() const {return Owner->CompType(S->CompareOp);}; - inline const char *DepType() const {return Owner->DepType(S->Type);}; + inline const char *CompType() const {return Owner->CompType(S->CompareOp);} + inline const char *DepType() const {return Owner->DepType(S->Type);} //Nice printable representation friend std::ostream& operator <<(std::ostream& out, DepIterator D); @@ -302,13 +302,13 @@ class pkgCache::DepIterator : public Iterator { Iterator(Owner, Trg), Type(DepVer) { if (S == 0) S = Owner.DepP; - }; + } inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) : Iterator(Owner, Trg), Type(DepRev) { if (S == 0) S = Owner.DepP; - }; - inline DepIterator() : Iterator(), Type(DepVer) {}; + } + inline DepIterator() : Iterator(), Type(DepVer) {} }; /*}}}*/ // Provides iterator /*{{{*/ @@ -318,34 +318,34 @@ class pkgCache::PrvIterator : public Iterator { protected: inline Provides* OwnerPointer() const { return (Owner != 0) ? Owner->ProvideP : 0; - }; + } public: // Iteration void operator ++(int) {if (S != Owner->ProvideP) S = Owner->ProvideP + - (Type == PrvVer?S->NextPkgProv:S->NextProvides);}; - inline void operator ++() {operator ++(0);}; + (Type == PrvVer?S->NextPkgProv:S->NextProvides);} + inline void operator ++() {operator ++(0);} // Accessors - inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;}; - inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}; - inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}; - inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}; - inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);}; + inline const char *Name() const {return Owner->StrP + Owner->PkgP[S->ParentPkg].Name;} + inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;} + inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);} + inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);} + inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);} bool IsMultiArchImplicit() const; - inline PrvIterator() : Iterator(), Type(PrvVer) {}; + inline PrvIterator() : Iterator(), Type(PrvVer) {} inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) : Iterator(Owner, Trg), Type(PrvVer) { if (S == 0) S = Owner.ProvideP; - }; + } inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) : Iterator(Owner, Trg), Type(PrvPkg) { if (S == 0) S = Owner.ProvideP; - }; + } }; /*}}}*/ // Package file /*{{{*/ @@ -353,32 +353,32 @@ class pkgCache::PkgFileIterator : public Iterator protected: inline PackageFile* OwnerPointer() const { return (Owner != 0) ? Owner->PkgFileP : 0; - }; + } public: // Iteration - void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;}; - inline void operator ++() {operator ++(0);}; + void operator ++(int) {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile;} + inline void operator ++() {operator ++(0);} // Accessors - inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}; - inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}; - inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}; - inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}; - inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}; - inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}; - inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}; - inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}; - inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}; - inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}; + inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;} + inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;} + inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;} + inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;} + inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;} + inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;} + inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;} + inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;} + inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;} + inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;} bool IsOk(); std::string RelStr(); // Constructors - inline PkgFileIterator() : Iterator() {}; - inline PkgFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.PkgFileP) {}; - inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator(Owner, Trg) {}; + inline PkgFileIterator() : Iterator() {} + inline PkgFileIterator(pkgCache &Owner) : Iterator(Owner, Owner.PkgFileP) {} + inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator(Owner, Trg) {} }; /*}}}*/ // Version File /*{{{*/ @@ -386,18 +386,18 @@ class pkgCache::VerFileIterator : public pkgCache::IteratorVerFileP : 0; - }; + } public: // Iteration - void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;}; - inline void operator ++() {operator ++(0);}; + void operator ++(int) {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile;} + inline void operator ++() {operator ++(0);} // Accessors - inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}; + inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);} - inline VerFileIterator() : Iterator() {}; - inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator(Owner, Trg) {}; + inline VerFileIterator() : Iterator() {} + inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator(Owner, Trg) {} }; /*}}}*/ // Description File /*{{{*/ @@ -405,40 +405,40 @@ class pkgCache::DescFileIterator : public Iterator { protected: inline DescFile* OwnerPointer() const { return (Owner != 0) ? Owner->DescFileP : 0; - }; + } public: // Iteration - void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;}; - inline void operator ++() {operator ++(0);}; + void operator ++(int) {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile;} + inline void operator ++() {operator ++(0);} // Accessors - inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);}; + inline PkgFileIterator File() const {return PkgFileIterator(*Owner,S->File + Owner->PkgFileP);} - inline DescFileIterator() : Iterator() {}; - inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator(Owner, Trg) {}; + inline DescFileIterator() : Iterator() {} + inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator(Owner, Trg) {} }; /*}}}*/ // Inlined Begin functions can't be in the class because of order problems /*{{{*/ inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const - {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}; + {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);} inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const - {return VerIterator(*Owner,Owner->VerP + S->VersionList);}; + {return VerIterator(*Owner,Owner->VerP + S->VersionList);} inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const - {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}; + {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);} inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const - {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}; + {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);} inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const - {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}; + {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);} inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const - {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}; + {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);} inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const - {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}; + {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);} inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const - {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}; + {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);} inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const - {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}; + {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);} inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const - {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}; + {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);} /*}}}*/ #endif diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index ce502d8ca..ef28bbc34 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -43,8 +43,8 @@ class CacheSetHelper { /*{{{*/ public: /*{{{*/ CacheSetHelper(bool const ShowError = true, GlobalError::MsgType ErrorType = GlobalError::ERROR) : - ShowError(ShowError), ErrorType(ErrorType) {}; - virtual ~CacheSetHelper() {}; + ShowError(ShowError), ErrorType(ErrorType) {} + virtual ~CacheSetHelper() {} virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern); virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern); @@ -76,9 +76,9 @@ public: /*{{{*/ virtual pkgCache::VerIterator canNotFindInstalledVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg); - bool showErrors() const { return ShowError; }; - bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); }; - GlobalError::MsgType errorType() const { return ErrorType; }; + bool showErrors() const { return ShowError; } + bool showErrors(bool const newValue) { if (ShowError == newValue) return ShowError; else return ((ShowError = newValue) == false); } + GlobalError::MsgType errorType() const { return ErrorType; } GlobalError::MsgType errorType(GlobalError::MsgType const &newValue) { if (ErrorType == newValue) return ErrorType; @@ -87,7 +87,7 @@ public: /*{{{*/ ErrorType = newValue; return oldValue; } - }; + } /*}}}*/ protected: @@ -124,12 +124,12 @@ public: inline pkgCache::PkgIterator::OkState State() const { return getPkg().State(); } inline const char *CandVersion() const { return getPkg().CandVersion(); } inline const char *CurVersion() const { return getPkg().CurVersion(); } - inline pkgCache *Cache() const { return getPkg().Cache(); }; - inline unsigned long Index() const {return getPkg().Index();}; + inline pkgCache *Cache() const { return getPkg().Cache(); } + inline unsigned long Index() const {return getPkg().Index();} // we have only valid iterators here - inline bool end() const { return false; }; + inline bool end() const { return false; } - inline pkgCache::Package const * operator->() const {return &*getPkg();}; + inline pkgCache::Package const * operator->() const {return &*getPkg();} }; /*}}}*/ @@ -154,7 +154,7 @@ public: unsigned short ID; const char * const Alias; Position Pos; - Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {}; + Modifier (unsigned short const &id, const char * const alias, Position const &pos) : ID(id), Alias(alias), Pos(pos) {} }; static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci, @@ -177,12 +177,12 @@ public: /*{{{*/ public: const_iterator(typename Container::const_iterator i) : _iter(i) {} pkgCache::PkgIterator getPkg(void) const { return *_iter; } - inline pkgCache::PkgIterator operator*(void) const { return *_iter; }; + inline pkgCache::PkgIterator operator*(void) const { return *_iter; } operator typename Container::const_iterator(void) const { return _iter; } inline const_iterator& operator++() { ++_iter; return *this; } inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; } - inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }; - inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }; + inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; } + inline bool operator==(const_iterator const &i) const { return _iter == i._iter; } friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); } }; class iterator : public PackageContainerInterface::const_iterator, @@ -191,43 +191,43 @@ public: /*{{{*/ public: iterator(typename Container::iterator i) : _iter(i) {} pkgCache::PkgIterator getPkg(void) const { return *_iter; } - inline pkgCache::PkgIterator operator*(void) const { return *_iter; }; + inline pkgCache::PkgIterator operator*(void) const { return *_iter; } operator typename Container::iterator(void) const { return _iter; } operator typename PackageContainer::const_iterator() { return typename PackageContainer::const_iterator(_iter); } inline iterator& operator++() { ++_iter; return *this; } inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; } - inline bool operator!=(iterator const &i) const { return _iter != i._iter; }; - inline bool operator==(iterator const &i) const { return _iter == i._iter; }; - inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }; - inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }; + inline bool operator!=(iterator const &i) const { return _iter != i._iter; } + inline bool operator==(iterator const &i) const { return _iter == i._iter; } + inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; } + inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; } friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); } }; /*}}}*/ - bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; }; - template void insert(PackageContainer const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); }; - void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }; + bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; } + template void insert(PackageContainer const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); } + void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); } - bool empty() const { return _cont.empty(); }; - void clear() { return _cont.clear(); }; + bool empty() const { return _cont.empty(); } + void clear() { return _cont.clear(); } //FIXME: on ABI break, replace the first with the second without bool - void erase(iterator position) { _cont.erase((typename Container::iterator)position); }; - iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }; - size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); }; - void erase(iterator first, iterator last) { _cont.erase(first, last); }; - size_t size() const { return _cont.size(); }; + void erase(iterator position) { _cont.erase((typename Container::iterator)position); } + iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); } + size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); } + void erase(iterator first, iterator last) { _cont.erase(first, last); } + size_t size() const { return _cont.size(); } - const_iterator begin() const { return const_iterator(_cont.begin()); }; - const_iterator end() const { return const_iterator(_cont.end()); }; - iterator begin() { return iterator(_cont.begin()); }; - iterator end() { return iterator(_cont.end()); }; - const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); }; + const_iterator begin() const { return const_iterator(_cont.begin()); } + const_iterator end() const { return const_iterator(_cont.end()); } + iterator begin() { return iterator(_cont.begin()); } + iterator end() { return iterator(_cont.end()); } + const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); } - void setConstructor(Constructor const &by) { ConstructedBy = by; }; - Constructor getConstructor() const { return ConstructedBy; }; + void setConstructor(Constructor const &by) { ConstructedBy = by; } + Constructor getConstructor() const { return ConstructedBy; } - PackageContainer() : ConstructedBy(UNKNOWN) {}; - PackageContainer(Constructor const &by) : ConstructedBy(by) {}; + PackageContainer() : ConstructedBy(UNKNOWN) {} + PackageContainer(Constructor const &by) : ConstructedBy(by) {} /** \brief returns all packages in the cache who belong to the given task @@ -365,7 +365,7 @@ private: /*{{{*/ template<> template void PackageContainer >::insert(PackageContainer const &pkgcont) { for (typename PackageContainer::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p) _cont.push_back(*p); -}; +} // these two are 'inline' as otherwise the linker has problems with seeing these untemplated // specializations again and again - but we need to see them, so that library users can use them template<> inline bool PackageContainer >::insert(pkgCache::PkgIterator const &P) { @@ -373,11 +373,11 @@ template<> inline bool PackageContainer >::inse return false; _cont.push_back(P); return true; -}; +} template<> inline void PackageContainer >::insert(const_iterator begin, const_iterator end) { for (const_iterator p = begin; p != end; ++p) _cont.push_back(*p); -}; +} typedef PackageContainer > PackageSet; typedef PackageContainer > PackageList; @@ -392,27 +392,27 @@ public: virtual pkgCache::VerIterator getVer() const = 0; operator pkgCache::VerIterator(void) { return getVer(); } - inline pkgCache *Cache() const { return getVer().Cache(); }; - inline unsigned long Index() const {return getVer().Index();}; - inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); }; - inline const char *VerStr() const { return getVer().VerStr(); }; - inline const char *Section() const { return getVer().Section(); }; - inline const char *Arch() const { return getVer().Arch(); }; - inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); }; - inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); }; - inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); }; - inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); }; - inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); }; - inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); }; - inline bool Downloadable() const { return getVer().Downloadable(); }; - inline const char *PriorityType() const { return getVer().PriorityType(); }; - inline std::string RelStr() const { return getVer().RelStr(); }; - inline bool Automatic() const { return getVer().Automatic(); }; - inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); }; + inline pkgCache *Cache() const { return getVer().Cache(); } + inline unsigned long Index() const {return getVer().Index();} + inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); } + inline const char *VerStr() const { return getVer().VerStr(); } + inline const char *Section() const { return getVer().Section(); } + inline const char *Arch() const { return getVer().Arch(); } + inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); } + inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); } + inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); } + inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); } + inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); } + inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); } + inline bool Downloadable() const { return getVer().Downloadable(); } + inline const char *PriorityType() const { return getVer().PriorityType(); } + inline std::string RelStr() const { return getVer().RelStr(); } + inline bool Automatic() const { return getVer().Automatic(); } + inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); } // we have only valid iterators here - inline bool end() const { return false; }; + inline bool end() const { return false; } - inline pkgCache::Version const * operator->() const { return &*getVer(); }; + inline pkgCache::Version const * operator->() const { return &*getVer(); } }; /*}}}*/ @@ -446,7 +446,7 @@ public: Version SelectVersion; Modifier (unsigned short const &id, const char * const alias, Position const &pos, Version const &select) : ID(id), Alias(alias), Pos(pos), - SelectVersion(select) {}; + SelectVersion(select) {} }; static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache, @@ -509,12 +509,12 @@ public: /*{{{*/ public: const_iterator(typename Container::const_iterator i) : _iter(i) {} pkgCache::VerIterator getVer(void) const { return *_iter; } - inline pkgCache::VerIterator operator*(void) const { return *_iter; }; + inline pkgCache::VerIterator operator*(void) const { return *_iter; } operator typename Container::const_iterator(void) const { return _iter; } inline const_iterator& operator++() { ++_iter; return *this; } inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; } - inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }; - inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }; + inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; } + inline bool operator==(const_iterator const &i) const { return _iter == i._iter; } friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); } }; class iterator : public VersionContainerInterface::const_iterator, @@ -523,36 +523,36 @@ public: /*{{{*/ public: iterator(typename Container::iterator i) : _iter(i) {} pkgCache::VerIterator getVer(void) const { return *_iter; } - inline pkgCache::VerIterator operator*(void) const { return *_iter; }; + inline pkgCache::VerIterator operator*(void) const { return *_iter; } operator typename Container::iterator(void) const { return _iter; } operator typename VersionContainer::const_iterator() { return typename VersionContainer::const_iterator(_iter); } inline iterator& operator++() { ++_iter; return *this; } inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; } - inline bool operator!=(iterator const &i) const { return _iter != i._iter; }; - inline bool operator==(iterator const &i) const { return _iter == i._iter; }; - inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }; - inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }; + inline bool operator!=(iterator const &i) const { return _iter != i._iter; } + inline bool operator==(iterator const &i) const { return _iter == i._iter; } + inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; } + inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; } friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); } }; /*}}}*/ - bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; }; - template void insert(VersionContainer const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); }; - void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }; - bool empty() const { return _cont.empty(); }; - void clear() { return _cont.clear(); }; + bool insert(pkgCache::VerIterator const &V) { if (V.end() == true) return false; _cont.insert(V); return true; } + template void insert(VersionContainer const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); } + void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); } + bool empty() const { return _cont.empty(); } + void clear() { return _cont.clear(); } //FIXME: on ABI break, replace the first with the second without bool - void erase(iterator position) { _cont.erase((typename Container::iterator)position); }; - iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }; - size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); }; - void erase(iterator first, iterator last) { _cont.erase(first, last); }; - size_t size() const { return _cont.size(); }; - - const_iterator begin() const { return const_iterator(_cont.begin()); }; - const_iterator end() const { return const_iterator(_cont.end()); }; - iterator begin() { return iterator(_cont.begin()); }; - iterator end() { return iterator(_cont.end()); }; - const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); }; + void erase(iterator position) { _cont.erase((typename Container::iterator)position); } + iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); } + size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); } + void erase(iterator first, iterator last) { _cont.erase(first, last); } + size_t size() const { return _cont.size(); } + + const_iterator begin() const { return const_iterator(_cont.begin()); } + const_iterator end() const { return const_iterator(_cont.end()); } + iterator begin() { return iterator(_cont.begin()); } + iterator end() { return iterator(_cont.end()); } + const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); } /** \brief returns all versions specified on the commandline @@ -659,7 +659,7 @@ public: /*{{{*/ template<> template void VersionContainer >::insert(VersionContainer const &vercont) { for (typename VersionContainer::const_iterator v = vercont.begin(); v != vercont.end(); ++v) _cont.push_back(*v); -}; +} // these two are 'inline' as otherwise the linker has problems with seeing these untemplated // specializations again and again - but we need to see them, so that library users can use them template<> inline bool VersionContainer >::insert(pkgCache::VerIterator const &V) { @@ -667,11 +667,11 @@ template<> inline bool VersionContainer >::inse return false; _cont.push_back(V); return true; -}; +} template<> inline void VersionContainer >::insert(const_iterator begin, const_iterator end) { for (const_iterator v = begin; v != end; ++v) _cont.push_back(*v); -}; +} typedef VersionContainer > VersionSet; typedef VersionContainer > VersionList; } diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 3ae1e8b1d..838c8887a 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -933,10 +933,10 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ // convenience interface, this will just call ScanForRemovable vector pkgUdevCdromDevices::Scan() -{ +{ bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true); - return ScanForRemovable(CdromOnly); -}; + return ScanForRemovable(CdromOnly); +} /*}}}*/ /*{{{*/ vector diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 8eddd56d4..003fd01d8 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -43,8 +43,7 @@ Configuration::Configuration() : ToFree(true) } Configuration::Configuration(const Item *Root) : Root((Item *)Root), ToFree(false) { -}; - +} /*}}}*/ // Configuration::~Configuration - Destructor /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index d457781c3..2d25f5ed9 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -223,7 +223,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold, void GlobalError::Discard() { Messages.clear(); PendingFlag = false; -}; +} /*}}}*/ // GlobalError::empty - does our error list include anything? /*{{{*/ bool GlobalError::empty(MsgType const &trashhold) const { diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h index 1d79a52ac..d9712d6a8 100644 --- a/apt-pkg/contrib/gpgv.h +++ b/apt-pkg/contrib/gpgv.h @@ -45,7 +45,7 @@ inline void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd = -1) { int fd[2]; ExecGPGV(File, FileSig, statusfd, fd); -}; +} #undef APT_noreturn diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 916e1d730..9d74ed495 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -125,14 +125,14 @@ bool OpProgress::CheckChange(float Interval) // OpTextProgress::OpTextProgress - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -OpTextProgress::OpTextProgress(Configuration &Config) : - NoUpdate(false), NoDisplay(false), LastLen(0) +OpTextProgress::OpTextProgress(Configuration &Config) : + NoUpdate(false), NoDisplay(false), LastLen(0) { if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true) NoUpdate = true; if (Config.FindI("quiet",0) >= 2) NoDisplay = true; -}; +} /*}}}*/ // OpTextProgress::Done - Clean up the display /*{{{*/ // --------------------------------------------------------------------- @@ -150,12 +150,12 @@ void OpTextProgress::Done() cout << endl; OldOp = string(); } - + if (NoUpdate == true && NoDisplay == false && OldOp.empty() == false) { OldOp = string(); - cout << endl; - } + cout << endl; + } } /*}}}*/ // OpTextProgress::Update - Simple text spinner /*{{{*/ diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index f8bb3890d..0d85b4fd3 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -153,7 +153,7 @@ char *_strrstrip(char *String) End++; *End = 0; return String; -}; +} /*}}}*/ // strtabexpand - Converts tabs into 8 spaces /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 8d746f10e..3a6d38b75 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -37,8 +37,8 @@ namespace APT { namespace String { std::string Strip(const std::string &s); bool Endswith(const std::string &s, const std::string &ending); - }; -}; + } +} bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest); @@ -104,17 +104,17 @@ int tolower_ascii(int const c) __attrib_const __hot; std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ -inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \ -inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ -inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ -inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; +inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \ +inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ +inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \ +inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);} #define APT_MKSTRCMP2(name,func) \ -inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ -inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ -inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}; +inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ +inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \ +inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);} int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); @@ -132,18 +132,18 @@ int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, std::string::const_iterator B,std::string::const_iterator BEnd); -inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}; -inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}; +inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));} +inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));} #endif -APT_MKSTRCMP2(stringcmp,stringcmp); -APT_MKSTRCMP2(stringcasecmp,stringcasecmp); +APT_MKSTRCMP2(stringcmp,stringcmp) +APT_MKSTRCMP2(stringcasecmp,stringcasecmp) // Return the length of a NULL-terminated string array size_t strv_length(const char **str_array); -inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}; +inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);} class URI { @@ -159,13 +159,13 @@ class URI unsigned int Port; operator std::string(); - inline void operator =(const std::string &From) {CopyFrom(From);}; + inline void operator =(const std::string &From) {CopyFrom(From);} inline bool empty() {return Access.empty();}; static std::string SiteOnly(const std::string &URI); static std::string NoUserPassword(const std::string &URI); - URI(std::string Path) {CopyFrom(Path);}; - URI() : Port(0) {}; + URI(std::string Path) {CopyFrom(Path);} + URI() : Port(0) {} }; struct SubstVar diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index a12e6963d..90d0c9314 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1686,9 +1686,9 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) /*}}}*/ // Policy::GetPriority - Get the priority of the package pin /*{{{*/ signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &Pkg) -{ return 0; }; +{ return 0; } signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &File) -{ return 0; }; +{ return 0; } /*}}}*/ pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc() /*{{{*/ { diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 9ea244139..89c9d531f 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -646,12 +646,12 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd, int fd[2]) { ExecGPGV(File, FileOut, statusfd, fd); return false; -}; +} bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd) { ExecGPGV(File, FileOut, statusfd); return false; -}; +} /*}}}*/ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ vector &List, pkgCdromStatus *log) diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index a3a4cc0e1..aec744360 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -371,5 +371,5 @@ bool PackageManagerText::StatusChanged(std::string PackageName, -}; // namespace progress -}; // namespace apt +} // namespace progress +} // namespace apt diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h index 8a5b68a8f..8bcc32927 100644 --- a/apt-pkg/install-progress.h +++ b/apt-pkg/install-progress.h @@ -24,7 +24,7 @@ namespace Progress { int last_reported_progress; public: - PackageManager() + PackageManager() : percentage(0.0), last_reported_progress(-1) {}; virtual ~PackageManager() {}; @@ -32,8 +32,8 @@ namespace Progress { virtual void Start(int child_pty=-1) {}; virtual void Stop() {}; - /* When dpkg is invoked (may happen multiple times for each - * install/remove block + /* When dpkg is invoked (may happen multiple times for each + * install/remove block */ virtual void StartDpkg() {}; @@ -44,18 +44,18 @@ namespace Progress { return 500000; }; - virtual bool StatusChanged(std::string PackageName, + virtual bool StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, - std::string HumanReadableAction) ; - virtual void Error(std::string PackageName, + std::string HumanReadableAction); + virtual void Error(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, - std::string ErrorMessage) {}; + std::string ErrorMessage) {} virtual void ConffilePrompt(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, - std::string ConfMessage) {}; + std::string ConfMessage) {} }; class PackageManagerProgressFd : public PackageManager @@ -72,11 +72,11 @@ namespace Progress { virtual void StartDpkg(); virtual void Stop(); - virtual bool StatusChanged(std::string PackageName, + virtual bool StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); - virtual void Error(std::string PackageName, + virtual void Error(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string ErrorMessage); @@ -101,11 +101,11 @@ namespace Progress { virtual void StartDpkg(); virtual void Stop(); - virtual bool StatusChanged(std::string PackageName, + virtual bool StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); - virtual void Error(std::string PackageName, + virtual void Error(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string ErrorMessage); @@ -134,7 +134,7 @@ namespace Progress { ~PackageManagerFancy(); virtual void Start(int child_pty=-1); virtual void Stop(); - virtual bool StatusChanged(std::string PackageName, + virtual bool StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); @@ -143,14 +143,14 @@ namespace Progress { class PackageManagerText : public PackageManager { public: - virtual bool StatusChanged(std::string PackageName, + virtual bool StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); }; -}; // namespace Progress -}; // namespace APT +} // namespace Progress +} // namespace APT #endif diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 67a2a709d..7d57640c5 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -414,7 +414,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const // GrpIterator::operator ++ - Postfix incr /*{{{*/ // --------------------------------------------------------------------- /* This will advance to the next logical group in the hash table. */ -void pkgCache::GrpIterator::operator ++(int) +void pkgCache::GrpIterator::operator ++(int) { // Follow the current links if (S != Owner->GrpP) @@ -426,12 +426,12 @@ void pkgCache::GrpIterator::operator ++(int) HashIndex++; S = Owner->GrpP + Owner->HeaderP->GrpHashTable[HashIndex]; } -}; +} /*}}}*/ // PkgIterator::operator ++ - Postfix incr /*{{{*/ // --------------------------------------------------------------------- /* This will advance to the next logical package in the hash table. */ -void pkgCache::PkgIterator::operator ++(int) +void pkgCache::PkgIterator::operator ++(int) { // Follow the current links if (S != Owner->PkgP) @@ -443,7 +443,7 @@ void pkgCache::PkgIterator::operator ++(int) HashIndex++; S = Owner->PkgP + Owner->HeaderP->PkgHashTable[HashIndex]; } -}; +} /*}}}*/ // PkgIterator::State - Check the State of the package /*{{{*/ // --------------------------------------------------------------------- @@ -475,26 +475,26 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const // --------------------------------------------------------------------- /* Return string representing of the candidate version. */ const char * -pkgCache::PkgIterator::CandVersion() const +pkgCache::PkgIterator::CandVersion() const { //TargetVer is empty, so don't use it. VerIterator version = pkgPolicy(Owner).GetCandidateVer(*this); if (version.IsGood()) return version.VerStr(); return 0; -}; +} /*}}}*/ // PkgIterator::CurVersion - Returns the current version string /*{{{*/ // --------------------------------------------------------------------- /* Return string representing of the current version. */ const char * -pkgCache::PkgIterator::CurVersion() const +pkgCache::PkgIterator::CurVersion() const { VerIterator version = CurrentVer(); if (version.IsGood()) return CurrentVer().VerStr(); return 0; -}; +} /*}}}*/ // ostream operator to handle string representation of a package /*{{{*/ // --------------------------------------------------------------------- @@ -978,7 +978,7 @@ string pkgCache::PkgFileIterator::RelStr() /*}}}*/ // VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/ // --------------------------------------------------------------------- -/* return a DescIter for the current locale or the default if none is +/* return a DescIter for the current locale or the default if none is * found */ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const @@ -1012,7 +1012,7 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const if (strcmp(Desc.LanguageCode(), "") == 0) return Desc; return DescriptionList(); -}; +} /*}}}*/ // PrvIterator::IsMultiArchImplicit - added by the cache generation /*{{{*/ diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 669904c84..9a88246a1 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -176,13 +176,13 @@ class pkgCache /*{{{*/ char *StrP; virtual bool ReMap(bool const &Errorchecks = true); - inline bool Sync() {return Map.Sync();}; - inline MMap &GetMap() {return Map;}; - inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}; + inline bool Sync() {return Map.Sync();} + inline MMap &GetMap() {return Map;} + inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();} // String hashing function (512 range) - inline unsigned long Hash(const std::string &S) const {return sHash(S);}; - inline unsigned long Hash(const char *S) const {return sHash(S);}; + inline unsigned long Hash(const std::string &S) const {return sHash(S);} + inline unsigned long Hash(const char *S) const {return sHash(S);} // Useful transformation things const char *Priority(unsigned char Priority); @@ -192,7 +192,7 @@ class pkgCache /*{{{*/ PkgIterator FindPkg(const std::string &Name); PkgIterator FindPkg(const std::string &Name, const std::string &Arch); - Header &Head() {return *HeaderP;}; + Header &Head() {return *HeaderP;} inline GrpIterator GrpBegin(); inline GrpIterator GrpEnd(); inline PkgIterator PkgBegin(); @@ -200,7 +200,7 @@ class pkgCache /*{{{*/ inline PkgFileIterator FileBegin(); inline PkgFileIterator FileEnd(); - inline bool MultiArchCache() const { return MultiArchEnabled; }; + inline bool MultiArchCache() const { return MultiArchEnabled; } inline char const * const NativeArch() const; // Make me a function @@ -212,7 +212,7 @@ class pkgCache /*{{{*/ static const char *DepType(unsigned char Dep); pkgCache(MMap *Map,bool DoMap = true); - virtual ~pkgCache() {}; + virtual ~pkgCache() {} private: bool MultiArchEnabled; @@ -662,26 +662,26 @@ struct pkgCache::StringItem inline char const * const pkgCache::NativeArch() const - { return StrP + HeaderP->Architecture; }; + { return StrP + HeaderP->Architecture; } #include -inline pkgCache::GrpIterator pkgCache::GrpBegin() - {return GrpIterator(*this);}; -inline pkgCache::GrpIterator pkgCache::GrpEnd() - {return GrpIterator(*this,GrpP);}; -inline pkgCache::PkgIterator pkgCache::PkgBegin() - {return PkgIterator(*this);}; -inline pkgCache::PkgIterator pkgCache::PkgEnd() - {return PkgIterator(*this,PkgP);}; +inline pkgCache::GrpIterator pkgCache::GrpBegin() + {return GrpIterator(*this);} +inline pkgCache::GrpIterator pkgCache::GrpEnd() + {return GrpIterator(*this,GrpP);} +inline pkgCache::PkgIterator pkgCache::PkgBegin() + {return PkgIterator(*this);} +inline pkgCache::PkgIterator pkgCache::PkgEnd() + {return PkgIterator(*this,PkgP);} inline pkgCache::PkgFileIterator pkgCache::FileBegin() - {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}; + {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);} inline pkgCache::PkgFileIterator pkgCache::FileEnd() - {return PkgFileIterator(*this,PkgFileP);}; + {return PkgFileIterator(*this,PkgFileP);} // Oh I wish for Real Name Space Support class pkgCache::Namespace /*{{{*/ -{ +{ public: typedef pkgCache::GrpIterator GrpIterator; typedef pkgCache::PkgIterator PkgIterator; @@ -690,7 +690,7 @@ class pkgCache::Namespace /*{{{*/ typedef pkgCache::DepIterator DepIterator; typedef pkgCache::PrvIterator PrvIterator; typedef pkgCache::PkgFileIterator PkgFileIterator; - typedef pkgCache::VerFileIterator VerFileIterator; + typedef pkgCache::VerFileIterator VerFileIterator; typedef pkgCache::Version Version; typedef pkgCache::Description Description; typedef pkgCache::Package Package; diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h index c4973472f..436d38300 100644 --- a/apt-pkg/upgrade.h +++ b/apt-pkg/upgrade.h @@ -15,7 +15,7 @@ namespace APT { // FIXME: make this "enum class UpgradeMode {" once we enable c++11 enum UpgradeMode { FORBID_REMOVE_PACKAGES = 1, - FORBID_INSTALL_NEW_PACKAGES = 2, + FORBID_INSTALL_NEW_PACKAGES = 2 }; bool Upgrade(pkgDepCache &Cache, int UpgradeMode); } -- cgit v1.2.3 From cf4ff3b78dc347188949370db914fe6329be6c99 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:54:10 +0100 Subject: warning: cast from type A to type B casts away qualifiers [-Wcast-qual] Git-Dch: Ignore Reported-By: gcc -Wcast-qual --- apt-pkg/cacheiterators.h | 2 +- apt-pkg/contrib/fileutl.cc | 4 ++-- apt-pkg/contrib/hashes.h | 2 +- apt-pkg/contrib/hashsum_template.h | 42 +++++++++++++++++++------------------- apt-pkg/pkgcachegen.cc | 14 ++++++------- 5 files changed, 32 insertions(+), 32 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index ca8bc5ca0..64fec5daa 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -79,7 +79,7 @@ template class pkgCache::Iterator : void ReMap(void const * const oldMap, void const * const newMap) { if (Owner == 0 || S == 0) return; - S += (Str*)(newMap) - (Str*)(oldMap); + S += (Str const * const)(newMap) - (Str const * const)(oldMap); } // Constructors - look out for the variable assigning diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 52411a762..17833f090 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1400,7 +1400,7 @@ bool FileFd::Write(const void *From,unsigned long long Size) return FileFdErrno("write",_("Write error")); } - From = (char *)From + Res; + From = (char const *)From + Res; Size -= Res; if (d != NULL) d->seekpos += Res; @@ -1424,7 +1424,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size) if (Res < 0) return _error->Errno("write",_("Write error")); - From = (char *)From + Res; + From = (char const *)From + Res; Size -= Res; } while (Res > 0 && Size > 0); diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 0a8bcd259..636cad257 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -77,7 +77,7 @@ class Hashes { return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size); }; - inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; + inline bool Add(const char *Data) {return Add((unsigned char const *)Data,strlen(Data));}; inline bool AddFD(int const Fd,unsigned long long Size = 0) { return AddFD(Fd, Size, true, true, true, true); }; bool AddFD(int const Fd, unsigned long long Size, bool const addMD5, diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 9bf160b2b..97b6a4ad9 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -28,18 +28,18 @@ template class HashSumValue { unsigned char Sum[N/8]; - + public: // Accessors bool operator ==(const HashSumValue &rhs) const { return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; - }; + } bool operator !=(const HashSumValue &rhs) const { return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0; - }; + } std::string Value() const { @@ -49,7 +49,7 @@ class HashSumValue }; char Result[((N/8)*2)+1]; Result[(N/8)*2] = 0; - + // Convert each char into two letters int J = 0; int I = 0; @@ -59,31 +59,31 @@ class HashSumValue Result[I + 1] = Conv[Sum[J] & 0xF]; } return std::string(Result); - }; - + } + inline void Value(unsigned char S[N/8]) { - for (int I = 0; I != sizeof(Sum); I++) + for (int I = 0; I != sizeof(Sum); ++I) S[I] = Sum[I]; - }; + } - inline operator std::string() const + inline operator std::string() const { return Value(); - }; + } - bool Set(std::string Str) + bool Set(std::string Str) { return Hex2Num(Str,Sum,sizeof(Sum)); - }; + } - inline void Set(unsigned char S[N/8]) + inline void Set(unsigned char S[N/8]) { - for (int I = 0; I != sizeof(Sum); I++) + for (int I = 0; I != sizeof(Sum); ++I) Sum[I] = S[I]; - }; + } - HashSumValue(std::string Str) + HashSumValue(std::string Str) { memset(Sum,0,sizeof(Sum)); Set(Str); @@ -99,17 +99,17 @@ class SummationImplementation public: virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0; inline bool Add(const char *inbuf, unsigned long long const inlen) - { return Add((unsigned char *)inbuf, inlen); }; + { return Add((const unsigned char *)inbuf, inlen); } inline bool Add(const unsigned char *Data) - { return Add(Data, strlen((const char *)Data)); }; + { return Add(Data, strlen((const char *)Data)); } inline bool Add(const char *Data) - { return Add((const unsigned char *)Data, strlen((const char *)Data)); }; + { return Add((const unsigned char *)Data, strlen((const char *)Data)); } inline bool Add(const unsigned char *Beg, const unsigned char *End) - { return Add(Beg, End - Beg); }; + { return Add(Beg, End - Beg); } inline bool Add(const char *Beg, const char *End) - { return Add((const unsigned char *)Beg, End - Beg); }; + { return Add((const unsigned char *)Beg, End - Beg); } bool AddFD(int Fd, unsigned long long Size = 0); bool AddFD(FileFd &Fd, unsigned long long Size = 0); diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 7ce7aba7b..96b35f669 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -118,11 +118,11 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM Cache.ReMap(false); - CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap; + CurrentFile += (pkgCache::PackageFile const * const) newMap - (pkgCache::PackageFile const * const) oldMap; for (size_t i = 0; i < _count(UniqHash); ++i) if (UniqHash[i] != 0) - UniqHash[i] += (pkgCache::StringItem*) newMap - (pkgCache::StringItem*) oldMap; + UniqHash[i] += (pkgCache::StringItem const * const) newMap - (pkgCache::StringItem const * const) oldMap; for (std::vector::const_iterator i = Dynamic::toReMap.begin(); i != Dynamic::toReMap.end(); ++i) @@ -398,7 +398,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator Pkg.Name(), "NewVersion", 1); if (oldMap != Map.Data()) - LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + LastVer += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; *LastVer = verindex; if (unlikely(List.NewVersion(Ver) == false)) @@ -909,7 +909,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, if (unlikely(index == 0)) return false; if (OldDepLast != 0 && oldMap != Map.Data()) - OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; } } return NewDepends(Pkg, Ver, index, Op, Type, OldDepLast); @@ -948,7 +948,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) OldDepLast = &D->NextDepends; } else if (oldMap != Map.Data()) - OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + OldDepLast += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; Dep->NextDepends = *OldDepLast; *OldDepLast = Dep.Index(); @@ -1125,8 +1125,8 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S, if (unlikely(idxString == 0)) return 0; if (oldMap != Map.Data()) { - Last += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - I += (pkgCache::StringItem*) Map.Data() - (pkgCache::StringItem*) oldMap; + Last += (map_ptrloc const * const) Map.Data() - (map_ptrloc const * const) oldMap; + I += (pkgCache::StringItem const * const) Map.Data() - (pkgCache::StringItem const * const) oldMap; } *Last = Item; -- 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/acquire-item.cc | 12 ++++++------ apt-pkg/algorithms.cc | 4 ++-- apt-pkg/cdrom.cc | 8 ++++---- apt-pkg/contrib/fileutl.cc | 4 ++-- apt-pkg/contrib/hashsum_template.h | 2 +- apt-pkg/contrib/mmap.cc | 2 +- apt-pkg/contrib/netrc.cc | 2 +- apt-pkg/deb/debsrcrecords.cc | 2 +- apt-pkg/indexcopy.cc | 12 ++++++------ apt-pkg/indexrecords.cc | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index de03011bf..88b10d4b1 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -709,7 +709,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/ } // queue the right diff - Desc.URI = string(RealURI) + ".diff/" + available_patches[0].file + ".gz"; + Desc.URI = RealURI + ".diff/" + available_patches[0].file + ".gz"; Desc.Description = Description + " " + available_patches[0].file + string(".pdiff"); DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(RealURI + ".diff/" + available_patches[0].file); @@ -797,7 +797,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner, Desc.Owner = this; Desc.ShortDesc = ShortDesc; - Desc.URI = string(RealURI) + ".diff/" + patch.file + ".gz"; + Desc.URI = RealURI + ".diff/" + patch.file + ".gz"; Desc.Description = Description + " " + patch.file + string(".pdiff"); DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(RealURI + ".diff/" + patch.file); @@ -1558,7 +1558,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ { std::vector types = APT::Configuration::getCompressionTypes(); for (std::vector::const_iterator t = types.begin(); t != types.end(); ++t) - if (MetaIndexParser->Exists(string((*Target)->MetaKey).append(".").append(*t)) == true) + if (MetaIndexParser->Exists((*Target)->MetaKey + "." + *t) == true) { compressedAvailable = true; break; @@ -1596,7 +1596,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ else if (transInRelease == false || Record != NULL || compressedAvailable == true) { if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true && - MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true) + MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true) new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); else @@ -1610,7 +1610,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this instead, but passing the required info to it is to much hassle */ if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false || - MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true)) + MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true)) new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); else @@ -1635,7 +1635,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message) /*{{{*/ missingkeys += (Fingerprint); } if(!missingkeys.empty()) - _error->Warning("%s", string(msg+missingkeys).c_str()); + _error->Warning("%s", (msg + missingkeys).c_str()); string Transformed = MetaIndexParser->GetExpectedDist(); diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 8320e7ef0..2e167119d 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -885,8 +885,8 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) } if (Debug == true) - clog << " Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] << - " as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl; + clog << " Considering " << Pkg.FullName(false) << ' ' << Scores[Pkg->ID] << + " as a solution to " << I.FullName(false) << ' ' << Scores[I->ID] << endl; /* Try to fix the package under consideration rather than fiddle with the VList package */ diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 838c8887a..ea5ed7e92 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -440,7 +440,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) Out.close(); if (FileExists(DFile) == true) - rename(DFile.c_str(), string(DFile + '~').c_str()); + rename(DFile.c_str(), (DFile + '~').c_str()); if (rename(NewFile.c_str(),DFile.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", DFile.c_str(),DFile.c_str()); @@ -553,7 +553,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) Out.close(); - rename(File.c_str(),string(File + '~').c_str()); + rename(File.c_str(), (File + '~').c_str()); if (rename(NewFile.c_str(),File.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", File.c_str(),File.c_str()); @@ -737,7 +737,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (InfoDir.empty() == false && FileExists(InfoDir + "/info") == true) { - ifstream F(string(InfoDir + "/info").c_str()); + ifstream F((InfoDir + "/info").c_str()); if (!F == 0) getline(F,Name); @@ -981,7 +981,7 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) cdrom.DeviceName = string(devnode); if (mountpath != "") { cdrom.MountPath = mountpath; - string s = string(mountpath); + string s = mountpath; cdrom.Mounted = IsMounted(s); } else { cdrom.Mounted = false; diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 17833f090..464950abd 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -891,7 +891,7 @@ bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, { for (; compressor != compressors.end(); ++compressor) { - std::string file = std::string(FileName).append(compressor->Extension); + std::string file = FileName + compressor->Extension; if (FileExists(file) == false) continue; FileName = file; @@ -1793,7 +1793,7 @@ bool FileFd::FileFdError(const char *Description,...) { } /*}}}*/ -gzFile FileFd::gzFd() { return (gzFile) d->gz; } +gzFile FileFd::gzFd() { return d->gz; } // Glob - wrapper around "glob()" /*{{{*/ diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 97b6a4ad9..f96188eb8 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -104,7 +104,7 @@ class SummationImplementation inline bool Add(const unsigned char *Data) { return Add(Data, strlen((const char *)Data)); } inline bool Add(const char *Data) - { return Add((const unsigned char *)Data, strlen((const char *)Data)); } + { return Add((const unsigned char *)Data, strlen(Data)); } inline bool Add(const unsigned char *Beg, const unsigned char *End) { return Add(Beg, End - Beg); } diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 51e8eb30f..37acba340 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -198,7 +198,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) { #ifdef _POSIX_SYNCHRONIZED_IO unsigned long long const PSize = sysconf(_SC_PAGESIZE); - if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0) + if (msync((char *)Base+(Start/PSize)*PSize, Stop - Start, MS_SYNC) < 0) return _error->Errno("msync", _("Unable to synchronize mmap")); #endif } diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index de95aa4ab..32b146581 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -198,7 +198,7 @@ void maybe_add_auth (URI &Uri, string NetRCFile) // if host did not work, try Host+Path next, this will trigger // a lookup uri.startswith(host) in the netrc file parser (because // of the "/" - char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str()); + char *hostpath = strdup((Uri.Host + Uri.Path).c_str()); if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0) { if (_config->FindB("Debug::Acquire::netrc", false) == true) 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 /*{{{*/ diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 89c9d531f..38356df18 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -65,7 +65,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0) + if (stat((file + c->Extension).c_str(), &Buf) != 0) continue; found = true; break; @@ -160,7 +160,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, // Get the size struct stat Buf; - if (stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0 || + if (stat((CDROM + Prefix + File).c_str(),&Buf) != 0 || Buf.st_size == 0) { bool Mangled = false; @@ -175,7 +175,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, } if (Mangled == false || - stat(string(CDROM + Prefix + File).c_str(),&Buf) != 0) + stat((CDROM + Prefix + File).c_str(),&Buf) != 0) { if (Debug == true) clog << "Missed(2): " << OrigFile << endl; @@ -286,7 +286,7 @@ bool IndexCopy::ReconstructPrefix(string &Prefix,string OrigPath,string CD, while (1) { struct stat Buf; - if (stat(string(CD + MyPrefix + File).c_str(),&Buf) != 0) + if (stat((CD + MyPrefix + File).c_str(),&Buf) != 0) { if (Debug == true) cout << "Failed, " << CD + MyPrefix + File << endl; @@ -315,7 +315,7 @@ bool IndexCopy::ReconstructChop(unsigned long &Chop,string Dir,string File) while (1) { struct stat Buf; - if (stat(string(Dir + File).c_str(),&Buf) != 0) + if (stat((Dir + File).c_str(),&Buf) != 0) { File = ChopDirs(File,1); Depth++; @@ -676,7 +676,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - if (stat(std::string(file + c->Extension).c_str(), &Buf) != 0) + if (stat((file + c->Extension).c_str(), &Buf) != 0) continue; found = true; break; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index f8097c3c6..c1c397e31 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -129,10 +129,10 @@ bool indexRecords::Load(const string Filename) /*{{{*/ // get the user settings for this archive and use what expires earlier int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); if (Label.empty() == false) - MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); + MaxAge = _config->FindI(("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); int MinAge = _config->FindI("Acquire::Min-ValidTime", 0); if (Label.empty() == false) - MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge); + MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge); if(MaxAge == 0 && (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file -- cgit v1.2.3 From c3ccac9232c2684b15f75fa8622a9a290aeca123 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 03:11:54 +0100 Subject: warning: no previous declaration for foobar() [-Wmissing-declarations] Git-Dch: Ignore Reported-By: gcc -Wmissing-declarations --- apt-pkg/depcache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 90d0c9314..946c1e254 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -889,7 +889,7 @@ bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg, and prevents mode changes for packages on hold for example. If you want to check Mode specific stuff you can use the virtual public IsOk methods instead */ -char const* PrintMode(char const mode) +static char const* PrintMode(char const mode) { switch (mode) { -- cgit v1.2.3 From ef74268b47fae1afd302a4a524b53143cbfd6ce1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 03:32:13 +0100 Subject: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations] Git-Dch: Ignore Reported-By: gcc -Wunsafe-loop-optimizations --- apt-pkg/contrib/strutl.cc | 2 +- apt-pkg/pkgcachegen.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 0d85b4fd3..61fcc6a7d 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1184,7 +1184,7 @@ unsigned long RegexChoice(RxChoiceList *Rxs,const char **ListBegin, R->Hit = false; unsigned long Hits = 0; - for (; ListBegin != ListEnd; ListBegin++) + for (; ListBegin < ListEnd; ++ListBegin) { // Check if the name is a regex const char *I; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 96b35f669..006f3952b 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1249,10 +1249,10 @@ static bool CheckValidity(const string &CacheFile, static unsigned long ComputeSize(FileIterator Start,FileIterator End) { unsigned long TotalSize = 0; - for (; Start != End; ++Start) + for (; Start < End; ++Start) { if ((*Start)->HasPackages() == false) - continue; + continue; TotalSize += (*Start)->Size(); } return TotalSize; -- cgit v1.2.3 From d64e130aa333837a8fda0f1bba51f2867ca520f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 13:55:20 +0100 Subject: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] Reported-By: gcc -Wignored-qualifiers Git-Dch: Ignore --- apt-pkg/aptconfiguration.cc | 4 ++-- apt-pkg/aptconfiguration.h | 4 ++-- apt-pkg/pkgcache.h | 4 ++-- apt-pkg/tagfile.cc | 2 +- apt-pkg/tagfile.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 3948854c6..4c609c603 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -270,7 +270,7 @@ std::vector const Configuration::getLanguages(bool const &All, } /*}}}*/ // checkLanguage - are we interested in the given Language? /*{{{*/ -bool const Configuration::checkLanguage(std::string Lang, bool const All) { +bool Configuration::checkLanguage(std::string Lang, bool const All) { // the empty Language is always interesting as it is the original if (Lang.empty() == true) return true; @@ -390,7 +390,7 @@ std::vector const Configuration::getArchitectures(bool const &Cache } /*}}}*/ // checkArchitecture - are we interested in the given Architecture? /*{{{*/ -bool const Configuration::checkArchitecture(std::string const &Arch) { +bool Configuration::checkArchitecture(std::string const &Arch) { if (Arch == "all") return true; std::vector const archs = getArchitectures(true); diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index 026493c6d..dfed194ae 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -73,7 +73,7 @@ public: /*{{{*/ * \param All defines if we check against all codes or only against used codes * \return true if we are interested, false otherwise */ - bool static const checkLanguage(std::string Lang, bool const All = false); + bool static checkLanguage(std::string Lang, bool const All = false); /** \brief Returns a vector of Architectures we support * @@ -89,7 +89,7 @@ public: /*{{{*/ * \param Arch we want to check * \return true if we are interested, false otherwise */ - bool static const checkArchitecture(std::string const &Arch); + bool static checkArchitecture(std::string const &Arch); /** \brief Representation of supported compressors */ struct Compressor { diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 9a88246a1..b3a714511 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -201,7 +201,7 @@ class pkgCache /*{{{*/ inline PkgFileIterator FileEnd(); inline bool MultiArchCache() const { return MultiArchEnabled; } - inline char const * const NativeArch() const; + inline char const * NativeArch(); // Make me a function pkgVersioningSystem *VS; @@ -661,7 +661,7 @@ struct pkgCache::StringItem /*}}}*/ -inline char const * const pkgCache::NativeArch() const +inline char const * pkgCache::NativeArch() { return StrP + HeaderP->Architecture; } #include diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 832a40d1e..e1459c80e 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -471,7 +471,7 @@ bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags, return true; return FindFlag(Flags, Flag, Start, Stop); } -bool const pkgTagSection::FindFlag(unsigned long &Flags, unsigned long Flag, +bool pkgTagSection::FindFlag(unsigned long &Flags, unsigned long Flag, char const* Start, char const* Stop) { switch (StringToBool(string(Start, Stop))) diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 518d3dbcd..2f600d397 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -65,7 +65,7 @@ class pkgTagSection unsigned long long FindULL(const char *Tag, unsigned long long const &Default = 0) const; bool FindFlag(const char *Tag,unsigned long &Flags, unsigned long Flag) const; - bool static const FindFlag(unsigned long &Flags, unsigned long Flag, + bool static FindFlag(unsigned long &Flags, unsigned long Flag, const char* Start, const char* Stop); bool Scan(const char *Start,unsigned long MaxLength); inline unsigned long size() const {return Stop - Section;}; -- 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/acquire-item.cc | 20 ++++++++++---------- apt-pkg/cachefile.cc | 4 ++-- apt-pkg/cacheset.cc | 28 ++++++++++++++-------------- apt-pkg/cdrom.cc | 2 +- apt-pkg/deb/debindexfile.h | 2 +- apt-pkg/deb/dpkgpm.cc | 2 +- apt-pkg/deb/dpkgpm.h | 4 ++-- apt-pkg/depcache.cc | 10 +++++----- apt-pkg/depcache.h | 2 +- apt-pkg/edsp.cc | 10 ++++------ apt-pkg/edsp.h | 6 ++---- apt-pkg/edsp/edspindexfile.cc | 2 +- apt-pkg/edsp/edsplistparser.cc | 4 ++-- apt-pkg/edsp/edspsystem.cc | 6 +++--- apt-pkg/indexcopy.cc | 2 +- apt-pkg/indexfile.cc | 6 +++--- apt-pkg/indexfile.h | 4 ++-- apt-pkg/install-progress.cc | 4 ++-- apt-pkg/install-progress.h | 18 +++++++++--------- apt-pkg/packagemanager.h | 4 ++-- apt-pkg/pkgcache.cc | 2 +- apt-pkg/pkgcachegen.cc | 2 +- apt-pkg/pkgcachegen.h | 4 ++-- apt-pkg/pkgrecords.h | 2 +- apt-pkg/policy.cc | 2 +- apt-pkg/vendor.cc | 2 +- 26 files changed, 75 insertions(+), 79 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 88b10d4b1..3b22743e7 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -108,8 +108,8 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long long Size) // Acquire::Item::Done - Item downloaded OK /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash, - pkgAcquire::MethodConfig *Cnf) +void pkgAcquire::Item::Done(string Message,unsigned long long Size,string /*Hash*/, + pkgAcquire::MethodConfig * /*Cnf*/) { // We just downloaded something.. string FileName = LookupTag(Message,"Filename"); @@ -253,10 +253,10 @@ string pkgAcqSubIndex::Custom600Headers() return "\nIndex-File: true\nFail-Ignore: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); } /*}}}*/ -void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/ +void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/ { if(Debug) - std::clog << "pkgAcqSubIndex failed: " << Desc.URI << std::endl; + std::clog << "pkgAcqSubIndex failed: " << Desc.URI << " with " << Message << std::endl; Complete = false; Status = StatDone; @@ -544,10 +544,10 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/ return false; } /*}}}*/ -void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/ +void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/ { if(Debug) - std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << std::endl + std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << " with " << Message << std::endl << "Falling back to normal index file acquire" << std::endl; new pkgAcqIndex(Owner, RealURI, Description, Desc.ShortDesc, @@ -624,10 +624,10 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner, } } /*}}}*/ -void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/ +void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/ { if(Debug) - std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl + std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl << "Falling back to normal index file acquire" << std::endl; new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, ExpectedHash); @@ -808,7 +808,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner, QueueURI(Desc); } /*}}}*/ -void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ +void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)/*{{{*/ { if(Debug) std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl; @@ -1698,7 +1698,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message) /*{{{*/ // pkgAcqMetaIndex::Failed - no Release file present or no signature file present /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) +void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/) { if (AuthPass == true) { diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 7c2276185..2401b015e 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -99,7 +99,7 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock) // CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgCacheFile::BuildSourceList(OpProgress *Progress) +bool pkgCacheFile::BuildSourceList(OpProgress * /*Progress*/) { if (SrcList != NULL) return true; @@ -113,7 +113,7 @@ bool pkgCacheFile::BuildSourceList(OpProgress *Progress) // CacheFile::BuildPolicy - Open and build all relevant preferences /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgCacheFile::BuildPolicy(OpProgress *Progress) +bool pkgCacheFile::BuildPolicy(OpProgress * /*Progress*/) { if (Policy != NULL) return true; diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 6b6fdb5ad..8a30d00a2 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -588,13 +588,13 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache, } /*}}}*/ // canNotFindTask - handle the case no package is found for a task /*{{{*/ -void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) { +void CacheSetHelper::canNotFindTask(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) { if (ShowError == true) _error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str()); } /*}}}*/ // canNotFindRegEx - handle the case no package is found by a regex /*{{{*/ -void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) { +void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string pattern) { if (ShowError == true) _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str()); } @@ -606,25 +606,25 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk } #endif /*}}}*/ // canNotFindPackage - handle the case no package is found from a string/*{{{*/ -void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) { +void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { } /*}}}*/ // canNotFindAllVer /*{{{*/ -void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str()); } /*}}}*/ // canNotFindInstCandVer /*{{{*/ -void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); } /*}}}*/ // canNotFindInstCandVer /*{{{*/ -void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache, +void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*vci*/, pkgCacheFile &/*Cache*/, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str()); @@ -655,13 +655,13 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache } /*}}}*/ // showTaskSelection /*{{{*/ -void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg, - std::string const &pattern) { +void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, + std::string const &/*pattern*/) { } /*}}}*/ // showRegExSelection /*{{{*/ -void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg, - std::string const &pattern) { +void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, + std::string const &/*pattern*/) { } /*}}}*/ #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) @@ -672,10 +672,10 @@ void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, /*}}}*/ #endif // showSelectedVersion /*{{{*/ -void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg, - pkgCache::VerIterator const Ver, - std::string const &ver, - bool const verIsRel) { +void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, + pkgCache::VerIterator const /*Ver*/, + std::string const &/*ver*/, + bool const /*verIsRel*/) { } /*}}}*/ } diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index ea5ed7e92..6f946b030 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -369,7 +369,7 @@ bool pkgCdrom::DropRepeats(vector &List,const char *Name) // --------------------------------------------------------------------- /* This takes the list of source list expressed entires and collects similar ones to form a single entry for each dist */ -void pkgCdrom::ReduceSourcelist(string CD,vector &List) +void pkgCdrom::ReduceSourcelist(string /*CD*/,vector &List) { sort(List.begin(),List.end()); 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 diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 946c1e254..b45f5d9b5 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -222,7 +222,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/ return true; } /*}}}*/ -bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/ +bool pkgDepCache::writeStateFile(OpProgress * /*prog*/, bool InstalledOnly) /*{{{*/ { bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false); @@ -868,7 +868,7 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge, return IsDeleteOkProtectInstallRequests(Pkg, rPurge, Depth, FromUser); } bool pkgDepCache::IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg, - bool const rPurge, unsigned long const Depth, bool const FromUser) + bool const /*rPurge*/, unsigned long const Depth, bool const FromUser) { if (FromUser == false && Pkg->CurrentVer == 0) { @@ -1297,7 +1297,7 @@ bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst, return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser); } bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, - bool const AutoInst, unsigned long const Depth, bool const FromUser) + bool const /*AutoInst*/, unsigned long const Depth, bool const FromUser) { if (FromUser == true) // as always: user is always right return true; @@ -1685,9 +1685,9 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) } /*}}}*/ // Policy::GetPriority - Get the priority of the package pin /*{{{*/ -signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &Pkg) +signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/) { return 0; } -signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &File) +signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/) { return 0; } /*}}}*/ pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc() /*{{{*/ diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index a02a86b87..50f810806 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -61,7 +61,7 @@ class pkgDepCache : protected pkgCache::Namespace class InRootSetFunc { public: - virtual bool InRootSet(const pkgCache::PkgIterator &pkg) {return false;}; + virtual bool InRootSet(const pkgCache::PkgIterator &/*pkg*/) {return false;}; virtual ~InRootSetFunc() {}; }; diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index e90598392..dbd2dba46 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -44,7 +44,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress) for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p) { WriteScenarioVersion(Cache, output, Pkg, Ver); - WriteScenarioDependency(Cache, output, Pkg, Ver); + WriteScenarioDependency(output, Ver); fprintf(output, "\n"); if (Progress != NULL && p % 100 == 0) Progress->Progress(p); @@ -64,7 +64,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output, for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { WriteScenarioVersion(Cache, output, Pkg, Ver); - WriteScenarioLimitedDependency(Cache, output, Pkg, Ver, pkgset); + WriteScenarioLimitedDependency(output, Ver, pkgset); fprintf(output, "\n"); if (Progress != NULL && p % 100 == 0) Progress->Progress(p); @@ -111,8 +111,7 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI } /*}}}*/ // EDSP::WriteScenarioDependency /*{{{*/ -void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, - pkgCache::VerIterator const &Ver) +void EDSP::WriteScenarioDependency( FILE* output, pkgCache::VerIterator const &Ver) { std::string dependencies[pkgCache::Dep::Enhances + 1]; bool orGroup = false; @@ -148,8 +147,7 @@ void EDSP::WriteScenarioDependency(pkgDepCache &Cache, FILE* output, pkgCache::P } /*}}}*/ // EDSP::WriteScenarioLimitedDependency /*{{{*/ -void EDSP::WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output, - pkgCache::PkgIterator const &Pkg, +void EDSP::WriteScenarioLimitedDependency(FILE* output, pkgCache::VerIterator const &Ver, APT::PackageSet const &pkgset) { diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index fd4436f60..828ee3753 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -35,11 +35,9 @@ class EDSP /*{{{*/ void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver); - void static WriteScenarioDependency(pkgDepCache &Cache, FILE* output, - pkgCache::PkgIterator const &Pkg, + void static WriteScenarioDependency(FILE* output, pkgCache::VerIterator const &Ver); - void static WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output, - pkgCache::PkgIterator const &Pkg, + void static WriteScenarioLimitedDependency(FILE* output, pkgCache::VerIterator const &Ver, APT::PackageSet const &pkgset); public: diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index 98ce4497a..80b9f79ea 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -63,7 +63,7 @@ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const class edspIFType: public pkgIndexFile::Type { public: - virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const + virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const { // we don't have a record parser for this type as the file is not presistent return NULL; diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index bcfdb1017..37959f37b 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -84,8 +84,8 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, } /*}}}*/ // ListParser::LoadReleaseInfo - Load the release information /*{{{*/ -bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, - FileFd &File, std::string component) +bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/, + FileFd & /*File*/, std::string /*component*/) { return true; } diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index aae969d9d..b509fa001 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -49,7 +49,7 @@ bool edspSystem::Lock() } /*}}}*/ // System::UnLock - Drop a lock /*{{{*/ -bool edspSystem::UnLock(bool NoErrors) +bool edspSystem::UnLock(bool /*NoErrors*/) { return true; } @@ -58,7 +58,7 @@ bool edspSystem::UnLock(bool NoErrors) // --------------------------------------------------------------------- /* we can't use edsp input as input for real installations - just a simulation can work, but everything else will fail bigtime */ -pkgPackageManager *edspSystem::CreatePM(pkgDepCache *Cache) const +pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const { return NULL; } @@ -81,7 +81,7 @@ bool edspSystem::Initialize(Configuration &Cnf) } /*}}}*/ // System::ArchiveSupported - Is a file format supported /*{{{*/ -bool edspSystem::ArchiveSupported(const char *Type) +bool edspSystem::ArchiveSupported(const char * /*Type*/) { return false; } diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 38356df18..59afa86ec 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -551,7 +551,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/ } /*}}}*/ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, /*{{{*/ - vector PkgList,vector SrcList) + vector /*PkgList*/,vector /*SrcList*/) { if (SigList.empty() == true) return true; diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 642a750d4..875c80336 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -47,7 +47,7 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type) // IndexFile::ArchiveInfo - Stub /*{{{*/ // --------------------------------------------------------------------- /* */ -std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const +std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator /*Ver*/) const { return std::string(); } @@ -63,8 +63,8 @@ pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const // IndexFile::SourceIndex - Stub /*{{{*/ // --------------------------------------------------------------------- /* */ -std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record, - pkgSrcRecords::File const &File) const +std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &/*Record*/, + pkgSrcRecords::File const &/*File*/) const { return std::string(); } diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index a0096fa34..9a5c74200 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -78,10 +78,10 @@ class pkgIndexFile virtual bool Exists() const = 0; virtual bool HasPackages() const = 0; virtual unsigned long Size() const = 0; - virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* Prog) const { return false; }; + virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; }; __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const { return Merge(Gen, &Prog); }; - virtual bool MergeFileProvides(pkgCacheGenerator &Gen,OpProgress* Prog) const {return true;}; + virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;}; __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const {return MergeFileProvides(Gen, &Prog);}; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index aec744360..657330b60 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -41,10 +41,10 @@ PackageManager* PackageManagerProgressFactory() return progress; } -bool PackageManager::StatusChanged(std::string PackageName, +bool PackageManager::StatusChanged(std::string /*PackageName*/, unsigned int StepsDone, unsigned int TotalSteps, - std::string HumanReadableAction) + std::string /*HumanReadableAction*/) { int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); percentage = StepsDone/(float)TotalSteps * 100.0; diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h index 8bcc32927..baf245376 100644 --- a/apt-pkg/install-progress.h +++ b/apt-pkg/install-progress.h @@ -29,7 +29,7 @@ namespace Progress { virtual ~PackageManager() {}; /* Global Start/Stop */ - virtual void Start(int child_pty=-1) {}; + virtual void Start(int /*child_pty*/=-1) {}; virtual void Stop() {}; /* When dpkg is invoked (may happen multiple times for each @@ -48,14 +48,14 @@ namespace Progress { unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) {} - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) {} + virtual void Error(std::string /*PackageName*/, + unsigned int /*StepsDone*/, + unsigned int /*TotalSteps*/, + std::string /*ErrorMessage*/) {} + virtual void ConffilePrompt(std::string /*PackageName*/, + unsigned int /*StepsDone*/, + unsigned int /*TotalSteps*/, + std::string /*ConfMessage*/) {} }; class PackageManagerProgressFd : public PackageManager diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 853b9bac8..d684463eb 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -89,9 +89,9 @@ class pkgPackageManager : protected pkgCache::Namespace virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) - virtual bool Go(APT::Progress::PackageManager *progress) {return true;}; + virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;}; #else - virtual bool Go(int statusFd=-1) {return true;}; + virtual bool Go(int /*statusFd*/=-1) {return true;}; #endif virtual void Reset() {}; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 7d57640c5..9c14e626e 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -695,7 +695,7 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End) // --------------------------------------------------------------------- /* Deps like self-conflicts should be ignored as well as implicit conflicts on virtual packages. */ -bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const +bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &/*Pkg*/) const { if (IsNegative() == false) return false; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 006f3952b..185b9ca45 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1580,7 +1580,7 @@ static bool IsDuplicateDescription(pkgCache::DescIterator Desc, } /*}}}*/ // CacheGenerator::FinishCache /*{{{*/ -bool pkgCacheGenerator::FinishCache(OpProgress *Progress) +bool pkgCacheGenerator::FinishCache(OpProgress * /*Progress*/) { return true; } diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 428e8459b..e8901025e 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -170,8 +170,8 @@ class pkgCacheGenerator::ListParser virtual bool Step() = 0; inline bool HasFileDeps() {return FoundFileDeps;}; - virtual bool CollectFileProvides(pkgCache &Cache, - pkgCache::VerIterator &Ver) {return true;}; + virtual bool CollectFileProvides(pkgCache &/*Cache*/, + pkgCache::VerIterator &/*Ver*/) {return true;}; ListParser() : FoundFileDeps(false) {}; virtual ~ListParser() {}; diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 3658435e8..ca0984bbf 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -70,7 +70,7 @@ class pkgRecords::Parser /*{{{*/ virtual std::string Homepage() {return std::string();} // An arbitrary custom field - virtual std::string RecordField(const char *fieldName) { return std::string();}; + virtual std::string RecordField(const char * /*fieldName*/) { return std::string();}; // The record in binary form virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;}; diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index d0f97441d..2176f1f42 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -349,7 +349,7 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File) all over the place rather than forcing a special format */ class PreferenceSection : public pkgTagSection { - void TrimRecord(bool BeforeRecord, const char* &End) + void TrimRecord(bool /*BeforeRecord*/, const char* &End) { for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++) if (Stop[0] == '#') diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc index fc03ec845..f19534171 100644 --- a/apt-pkg/vendor.cc +++ b/apt-pkg/vendor.cc @@ -31,7 +31,7 @@ const std::string Vendor::LookupFingerprint(std::string Print) const return (*Elt).second; } -bool Vendor::CheckDist(std::string Dist) +bool Vendor::CheckDist(std::string /*Dist*/) { return true; } -- cgit v1.2.3 From 54298f49d71347616df19b8d2f59c907374e07b3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 22:27:11 +0100 Subject: move defines for version to macros.h also adds namespaced attributes for good usage Git-Dch: Ignore --- apt-pkg/contrib/macros.h | 84 ++++++++++++++++++++++++++++++++++++++---------- apt-pkg/init.h | 11 +------ 2 files changed, 68 insertions(+), 27 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index e53d01b8f..294242e68 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -54,37 +54,87 @@ #define CLRFLAG(v,f) ((v) &=~FLAG(f)) #define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false) -// some nice optional GNUC features -#if __GNUC__ >= 3 - #define __must_check __attribute__ ((warn_unused_result)) - #define __deprecated __attribute__ ((deprecated)) - #define __attrib_const __attribute__ ((__const__)) - /* likely() and unlikely() can be used to mark boolean expressions - as (not) likely true which will help the compiler to optimise */ +#ifdef __GNUC__ +#define APT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__) +#else +#define APT_GCC_VERSION 0 +#endif + +/* likely() and unlikely() can be used to mark boolean expressions + as (not) likely true which will help the compiler to optimise */ +#if APT_GCC_VERSION >= 0x0300 #define likely(x) __builtin_expect (!!(x), 1) #define unlikely(x) __builtin_expect (!!(x), 0) #else - #define __must_check /* no warn_unused_result */ - #define __deprecated /* no deprecated */ - #define __attrib_const /* no const attribute */ #define likely(x) (x) #define unlikely(x) (x) #endif +#if APT_GCC_VERSION >= 0x0300 + #define APT_UNUSED __attribute__((unused)) + #define APT_CONST __attribute__((const)) + #define APT_PURE __attribute__((pure)) + #define APT_NORETURN __attribute__((noreturn)) + #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) +#else + #define APT_UNUSED + #define APT_CONST + #define APT_PURE + #define APT_NORETURN + #define APT_PRINTF(n) +#endif + +#if APT_GCC_VERSION > 0x0302 + #define APT_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) + #define APT_MUSTCHECK __attribute__((warn_unused_result)) +#else + #define APT_NONNULL(...) + #define APT_REQRET +#endif + +#if APT_GCC_VERSION >= 0x0400 + #define APT_SENTINEL __attribute__((sentinel)) +#else + #define APT_SENTINEL +#endif + // cold functions are unlikely() to be called -#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 - #define __cold __attribute__ ((__cold__)) - #define __hot __attribute__ ((__hot__)) +#if APT_GCC_VERSION >= 0x0403 + #define APT_COLD __attribute__ ((__cold__)) + #define APT_HOT __attribute__ ((__hot__)) #else - #define __cold /* no cold marker */ - #define __hot /* no hot marker */ + #define __cold + #define __hot #endif -#ifdef __GNUG__ -// Methods have a hidden this parameter that is visible to this attribute +#ifndef APT_10_CLEANER_HEADERS +#if APT_GCC_VERSION >= 0x0300 + #define __must_check __attribute__ ((warn_unused_result)) + #define __deprecated __attribute__ ((deprecated)) + #define __attrib_const __attribute__ ((__const__)) #define __like_printf(n) __attribute__((format(printf, n, n + 1))) #else + #define __must_check /* no warn_unused_result */ + #define __deprecated /* no deprecated */ + #define __attrib_const /* no const attribute */ #define __like_printf(n) /* no like-printf */ #endif +#if APT_GCC_VERSION >= 0x0403 + #define __cold __attribute__ ((__cold__)) + #define __hot __attribute__ ((__hot__)) +#else + #define __cold /* no cold marker */ + #define __hot /* no hot marker */ +#endif +#endif + +// These lines are extracted by the makefiles and the buildsystem +// Increasing MAJOR or MINOR results in the need of recompiling all +// reverse-dependencies of libapt-pkg against the new SONAME. +// Non-ABI-Breaks should only increase RELEASE number. +// See also buildlib/libversion.mak +#define APT_PKG_MAJOR 4 +#define APT_PKG_MINOR 12 +#define APT_PKG_RELEASE 0 #endif diff --git a/apt-pkg/init.h b/apt-pkg/init.h index b6f3df753..4ee7a95ac 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -1,6 +1,5 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: init.h,v 1.9.2.2 2004/01/02 18:51:00 mdz Exp $ /* ###################################################################### Init - Initialize the package library @@ -17,19 +16,11 @@ #include #include #endif +#include class pkgSystem; class Configuration; -// These lines are extracted by the makefiles and the buildsystem -// Increasing MAJOR or MINOR results in the need of recompiling all -// reverse-dependencies of libapt-pkg against the new SONAME. -// Non-ABI-Breaks should only increase RELEASE number. -// See also buildlib/libversion.mak -#define APT_PKG_MAJOR 4 -#define APT_PKG_MINOR 12 -#define APT_PKG_RELEASE 0 - extern const char *pkgVersion; extern const char *pkgLibVersion; -- 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/acquire-item.cc | 15 ++++++++--- apt-pkg/acquire-item.h | 4 +++ apt-pkg/acquire-method.cc | 12 +++++++-- apt-pkg/acquire-method.h | 1 + apt-pkg/acquire-worker.cc | 7 +++-- apt-pkg/acquire-worker.h | 3 +++ apt-pkg/acquire.cc | 6 +++++ apt-pkg/acquire.h | 7 ++++- apt-pkg/algorithms.cc | 13 +++++----- apt-pkg/algorithms.h | 5 +++- apt-pkg/aptconfiguration.cc | 9 +++++-- apt-pkg/cachefile.cc | 9 ++++++- apt-pkg/cachefile.h | 9 +++++-- apt-pkg/cachefilter.cc | 4 ++- apt-pkg/cachefilter.h | 1 + apt-pkg/cacheiterators.h | 4 +++ apt-pkg/cacheset.cc | 16 +++++++++--- apt-pkg/cacheset.h | 7 ++++- apt-pkg/cdrom.cc | 34 +++++++++++++------------ apt-pkg/cdrom.h | 2 ++ apt-pkg/clean.cc | 4 +++ apt-pkg/clean.h | 7 ++++- apt-pkg/contrib/cdromutl.cc | 5 +++- apt-pkg/contrib/cmndline.cc | 5 ++++ apt-pkg/contrib/configuration.cc | 13 +++++++--- apt-pkg/contrib/error.cc | 4 ++- apt-pkg/contrib/error.h | 27 ++++++++++---------- apt-pkg/contrib/fileutl.cc | 12 ++++++--- apt-pkg/contrib/fileutl.h | 11 ++++---- apt-pkg/contrib/gpgv.cc | 18 +++++++------ apt-pkg/contrib/gpgv.h | 14 +++++----- apt-pkg/contrib/hashes.cc | 6 ++++- apt-pkg/contrib/hashes.h | 13 +++++++--- apt-pkg/contrib/hashsum.cc | 3 +++ apt-pkg/contrib/hashsum_template.h | 10 +++++--- apt-pkg/contrib/macros.h | 8 +++--- apt-pkg/contrib/md5.cc | 6 +---- apt-pkg/contrib/md5.h | 9 ++++--- apt-pkg/contrib/mmap.cc | 4 +-- apt-pkg/contrib/netrc.cc | 3 +-- apt-pkg/contrib/netrc.h | 6 +++-- apt-pkg/contrib/progress.cc | 2 ++ apt-pkg/contrib/sha1.cc | 5 +--- apt-pkg/contrib/sha1.h | 7 ++--- apt-pkg/contrib/sha2.h | 10 +++++--- apt-pkg/contrib/sha2_internal.cc | 1 + apt-pkg/contrib/sha2_internal.h | 1 + apt-pkg/contrib/strutl.cc | 9 +++++-- apt-pkg/contrib/strutl.h | 23 +++++++++-------- 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 ++++++++-- apt-pkg/depcache.cc | 14 +++++++--- apt-pkg/depcache.h | 12 +++++++-- apt-pkg/edsp.cc | 17 ++++++++++--- apt-pkg/edsp.h | 5 +++- apt-pkg/edsp/edspindexfile.cc | 17 ++++++++----- apt-pkg/edsp/edspindexfile.h | 4 +++ apt-pkg/edsp/edsplistparser.cc | 10 +++++--- apt-pkg/edsp/edsplistparser.h | 4 +++ apt-pkg/edsp/edspsystem.cc | 15 ++++++----- apt-pkg/edsp/edspsystem.h | 9 +++++++ apt-pkg/indexcopy.cc | 6 ++--- apt-pkg/indexcopy.h | 10 +++++--- apt-pkg/indexfile.cc | 10 ++++++-- apt-pkg/indexfile.h | 15 ++++++----- apt-pkg/indexrecords.cc | 7 ++++- apt-pkg/indexrecords.h | 6 +++-- apt-pkg/init.cc | 4 ++- apt-pkg/init.h | 2 ++ apt-pkg/install-progress.cc | 30 +++++++++++++--------- apt-pkg/metaindex.h | 15 +++++++---- apt-pkg/orderlist.cc | 6 ++++- apt-pkg/orderlist.h | 6 +++-- apt-pkg/packagemanager.cc | 11 ++++++-- apt-pkg/packagemanager.h | 12 +++++---- apt-pkg/pkgcache.cc | 7 +++-- apt-pkg/pkgcachegen.cc | 20 ++++++++++----- apt-pkg/pkgcachegen.h | 12 +++++---- apt-pkg/pkgrecords.cc | 6 ++++- apt-pkg/pkgrecords.h | 3 ++- apt-pkg/pkgsystem.cc | 1 - apt-pkg/pkgsystem.h | 2 +- apt-pkg/policy.cc | 10 +++++++- apt-pkg/policy.h | 5 +++- apt-pkg/sourcelist.cc | 11 +++++++- apt-pkg/sourcelist.h | 12 +++++++-- apt-pkg/srcrecords.cc | 7 ++++- apt-pkg/tagfile.cc | 2 ++ apt-pkg/update.cc | 23 ++++++----------- apt-pkg/upgrade.cc | 19 +++++--------- apt-pkg/upgrade.h | 2 ++ apt-pkg/vendor.cc | 8 ++++-- apt-pkg/vendor.h | 2 +- apt-pkg/vendorlist.cc | 9 ++++++- apt-pkg/vendorlist.h | 2 +- apt-pkg/version.cc | 2 +- apt-pkg/versionmatch.cc | 7 ++++- apt-pkg/versionmatch.h | 3 ++- 112 files changed, 706 insertions(+), 310 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 3b22743e7..44a1f32df 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -22,12 +22,21 @@ #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/acquire-item.h b/apt-pkg/acquire-item.h index 0524743c6..f48d2a0d7 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -24,6 +24,10 @@ #include #include #include +#include + +#include +#include #ifndef APT_8_CLEANER_HEADERS #include diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 5bc1c159a..746c553f1 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -23,10 +23,18 @@ #include #include #include - +#include +#include +#include + +#include +#include +#include +#include +#include +#include #include #include -#include /*}}}*/ using namespace std; diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 00f99e0a0..f0f2a537a 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -21,6 +21,7 @@ #define PKGLIB_ACQUIRE_METHOD_H #include +#include #include #include diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index de62080da..047a655ce 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -14,20 +14,23 @@ // Include Files /*{{{*/ #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/acquire-worker.h b/apt-pkg/acquire-worker.h index a558f69a7..67aee4b59 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -22,6 +22,9 @@ #include #include +#include +#include +#include /** \brief A fetch subprocess. * diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index e8fa68338..a654d8219 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -23,12 +23,18 @@ #include #include +#include +#include #include #include #include +#include +#include +#include #include #include +#include #include #include diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 2c0b37635..1aac0ba11 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -72,8 +72,13 @@ #include #include +#include #include +#include + +#ifndef APT_10_CLEANER_HEADERS #include +#endif #ifndef APT_8_CLEANER_HEADERS using std::vector; @@ -353,7 +358,7 @@ class pkgAcquire void SetLog(pkgAcquireStatus *Progress) { Log = Progress; } /** \brief Construct a new pkgAcquire. */ - pkgAcquire(pkgAcquireStatus *Log) __deprecated; + pkgAcquire(pkgAcquireStatus *Log) APT_DEPRECATED; pkgAcquire(); /** \brief Destroy this pkgAcquire object. diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2e167119d..a7b676660 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -19,19 +19,18 @@ #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/algorithms.h b/apt-pkg/algorithms.h index 489d81159..82b6426c6 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -33,8 +33,11 @@ #include #include +#include +#include #include +#include #include @@ -140,7 +143,7 @@ class pkgProblemResolver /*{{{*/ // Try to resolve problems only by using keep bool ResolveByKeep(); - __deprecated void InstallProtect(); + APT_DEPRECATED void InstallProtect(); pkgProblemResolver(pkgDepCache *Cache); ~pkgProblemResolver(); diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 4c609c603..941a9c334 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -17,14 +17,19 @@ #include #include -#include #include #include #include - +#include +#include +#include +#include +#include #include #include #include + +#include /*}}}*/ namespace APT { // getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/ diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 2401b015e..0fd40106f 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -21,9 +21,16 @@ #include #include #include -#include #include #include +#include +#include +#include + +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index 802b12b61..36b20893a 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -17,8 +17,12 @@ #ifndef PKGLIB_CACHEFILE_H #define PKGLIB_CACHEFILE_H +#include + #include #include +#include +#include #ifndef APT_8_CLEANER_HEADERS #include @@ -26,6 +30,7 @@ #include #endif +class MMap; class pkgPolicy; class pkgSourceList; class OpProgress; @@ -60,13 +65,13 @@ class pkgCacheFile inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];}; bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); - __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; + APT_DEPRECATED bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; bool BuildSourceList(OpProgress *Progress = NULL); bool BuildPolicy(OpProgress *Progress = NULL); bool BuildDepCache(OpProgress *Progress = NULL); bool Open(OpProgress *Progress = NULL, bool WithLock = true); inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; - __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; + APT_DEPRECATED bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; static void RemoveCaches(); void Close(); diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc index 57b9af159..e388f2450 100644 --- a/apt-pkg/cachefilter.cc +++ b/apt-pkg/cachefilter.cc @@ -9,10 +9,12 @@ #include #include #include +#include #include +#include #include - +#include #include #include diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h index 81ae1383c..49d2855f5 100644 --- a/apt-pkg/cachefilter.h +++ b/apt-pkg/cachefilter.h @@ -7,6 +7,7 @@ #define APT_CACHEFILTER_H // Include Files /*{{{*/ #include +#include #include diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 64fec5daa..d9c8ed1e4 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -29,7 +29,11 @@ /*}}}*/ #ifndef PKGLIB_CACHEITERATORS_H #define PKGLIB_CACHEITERATORS_H +#include + #include +#include +#include #include diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 8a30d00a2..a58631d5b 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -16,14 +16,22 @@ #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/cacheset.h b/apt-pkg/cacheset.h index ef28bbc34..16a3daa42 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -9,7 +9,6 @@ #ifndef APT_CACHESET_H #define APT_CACHESET_H // Include Files /*{{{*/ -#include #include #include #include @@ -17,11 +16,17 @@ #include #include +#include + #include #include +#include #ifndef APT_8_CLEANER_HEADERS #include +#endif +#ifndef APT_10_CLEANER_HEADERS +#include #endif /*}}}*/ diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 6f946b030..262ff9eab 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -1,28 +1,30 @@ /* */ -#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 "indexcopy.h" - #include using namespace std; diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index c58593550..f4a873808 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -4,6 +4,8 @@ #include #include +#include + #ifndef APT_8_CLEANER_HEADERS #include using namespace std; diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 2dea8ffdd..0ee3b765d 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -16,7 +16,11 @@ #include #include #include +#include +#include +#include +#include #include #include #include diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index ad4049e83..930d54a7f 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -10,8 +10,13 @@ #ifndef APTPKG_CLEAN_H #define APTPKG_CLEAN_H - +#ifndef APT_10_CLEANER_HEADERS #include +#endif + +#include + +class pkgCache; class pkgArchiveCleaner { diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 20210ec0a..096d3bcf5 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -19,7 +19,10 @@ #include #include -#include +#include +#include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index ed5800007..3799c822d 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -18,6 +18,11 @@ #include #include +#include +#include +#include +#include + #include /*}}}*/ using namespace std; diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 003fd01d8..00f6ad0f9 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -21,11 +21,18 @@ #include #include #include -#include - +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 2d25f5ed9..892cd4874 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -17,12 +17,14 @@ #include +#include +#include +#include #include #include #include #include #include - #include #include diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index c06e45ee4..919b1e6d4 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -46,6 +46,7 @@ #include #include +#include #include class GlobalError /*{{{*/ @@ -73,7 +74,7 @@ public: /*{{{*/ * * \return \b false */ - bool FatalE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool FatalE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add an Error message with errno to the list * @@ -82,7 +83,7 @@ public: /*{{{*/ * * \return \b false */ - bool Errno(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool Errno(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a warning message with errno to the list * @@ -94,7 +95,7 @@ public: /*{{{*/ * * \return \b false */ - bool WarningE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool WarningE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a notice message with errno to the list * @@ -103,7 +104,7 @@ public: /*{{{*/ * * \return \b false */ - bool NoticeE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool NoticeE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief add a debug message with errno to the list * @@ -112,7 +113,7 @@ public: /*{{{*/ * * \return \b false */ - bool DebugE(const char *Function,const char *Description,...) __like_printf(3) __cold; + bool DebugE(const char *Function,const char *Description,...) APT_PRINTF(3) APT_COLD; /** \brief adds an errno message with the given type * @@ -121,7 +122,7 @@ public: /*{{{*/ * \param Description of the error */ bool InsertErrno(MsgType const &type, const char* Function, - const char* Description,...) __like_printf(4) __cold; + const char* Description,...) APT_PRINTF(4) APT_COLD; /** \brief adds an errno message with the given type * @@ -155,7 +156,7 @@ public: /*{{{*/ * * \return \b false */ - bool Fatal(const char *Description,...) __like_printf(2) __cold; + bool Fatal(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add an Error message to the list * @@ -163,7 +164,7 @@ public: /*{{{*/ * * \return \b false */ - bool Error(const char *Description,...) __like_printf(2) __cold; + bool Error(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a warning message to the list * @@ -174,7 +175,7 @@ public: /*{{{*/ * * \return \b false */ - bool Warning(const char *Description,...) __like_printf(2) __cold; + bool Warning(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a notice message to the list * @@ -187,7 +188,7 @@ public: /*{{{*/ * * \return \b false */ - bool Notice(const char *Description,...) __like_printf(2) __cold; + bool Notice(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief add a debug message to the list * @@ -195,14 +196,14 @@ public: /*{{{*/ * * \return \b false */ - bool Debug(const char *Description,...) __like_printf(2) __cold; + bool Debug(const char *Description,...) APT_PRINTF(2) APT_COLD; /** \brief adds an error message with the given type * * \param type of the error message * \param Description of the error */ - bool Insert(MsgType const &type, const char* Description,...) __like_printf(3) __cold; + bool Insert(MsgType const &type, const char* Description,...) APT_PRINTF(3) APT_COLD; /** \brief adds an error message with the given type * @@ -218,7 +219,7 @@ public: /*{{{*/ * should call this method again in that case */ bool Insert(MsgType type, const char* Description, - va_list &args, size_t &msgSize) __cold; + va_list &args, size_t &msgSize) APT_COLD; /** \brief is an error in the list? * diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 464950abd..55ba41128 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -26,16 +26,22 @@ #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/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index e752e9621..6fdea1294 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -94,7 +95,7 @@ class FileFd And as the auto-conversation converts a 'unsigned long *' to a 'bool' instead of 'unsigned long long *' we need to provide this explicitely - otherwise applications magically start to fail… */ - __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual) + bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED { unsigned long long R; bool const T = Read(To, Size, &R); @@ -118,7 +119,7 @@ class FileFd // Simple manipulators inline int Fd() {return iFd;}; inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);}; - __deprecated gzFile gzFd(); + gzFile gzFd() APT_DEPRECATED; inline bool IsOpen() {return iFd >= 0;}; inline bool Failed() {return (Flags & Fail) == Fail;}; @@ -152,8 +153,8 @@ class FileFd bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); // private helpers to set Fail flag and call _error->Error - bool FileFdErrno(const char* Function, const char* Description,...) __like_printf(3) __cold; - bool FileFdError(const char* Description,...) __like_printf(2) __cold; + bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; + bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; }; bool RunScripts(const char *Cnf); @@ -161,7 +162,7 @@ bool CopyFile(FileFd &From,FileFd &To); int GetLock(std::string File,bool Errors = true); bool FileExists(std::string File); bool RealFileExists(std::string File); -bool DirectoryExists(std::string const &Path) __attrib_const; +bool DirectoryExists(std::string const &Path) APT_CONST; bool CreateDirectory(std::string const &Parent, std::string const &Path); time_t GetModificationTime(std::string const &Path); diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 9de227062..f24dd9640 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -2,21 +2,23 @@ // Include Files /*{{{*/ #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/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h index d9712d6a8..ab3c68de5 100644 --- a/apt-pkg/contrib/gpgv.h +++ b/apt-pkg/contrib/gpgv.h @@ -9,17 +9,17 @@ #ifndef CONTRIB_GPGV_H #define CONTRIB_GPGV_H +#include + #include #include +#ifndef APT_10_CLEANER_HEADERS #include - -#if __GNUC__ >= 4 - #define APT_noreturn __attribute__ ((noreturn)) -#else - #define APT_noreturn /* no support */ #endif +class FileFd; + /** \brief generates and run the command to verify a file with gpgv * * If File and FileSig specify the same file it is assumed that we @@ -40,15 +40,13 @@ * @param FileSig is the signature (detached or clear-signed) */ void ExecGPGV(std::string const &File, std::string const &FileSig, - int const &statusfd, int fd[2]) APT_noreturn; + int const &statusfd, int fd[2]) APT_NORETURN; inline void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd = -1) { int fd[2]; ExecGPGV(File, FileSig, statusfd, fd); } -#undef APT_noreturn - /** \brief Split an inline signature into message and signature * * Takes a clear-signed message and puts the first signed message diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 890573d9c..5efafa511 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -16,8 +16,12 @@ #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 636cad257..979ee1eb8 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -17,17 +17,22 @@ #include #include #include -#include -#include -#include #include - +#include #ifndef APT_8_CLEANER_HEADERS using std::min; using std::vector; #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif + + +class FileFd; // helper class that contains hash function name // and hash diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index d02177724..25ccc187d 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -1,6 +1,9 @@ // Cryptographic API Base #include +#include + +#include #include #include "hashsum_template.h" diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index f96188eb8..869dc5cb7 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -10,20 +10,24 @@ #ifndef APTPKG_HASHSUM_TEMPLATE_H #define APTPKG_HASHSUM_TEMPLATE_H -#include #include #include -#include -#include #include +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; #endif +class FileFd; + template class HashSumValue { diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index 294242e68..d97053553 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -71,13 +71,13 @@ #endif #if APT_GCC_VERSION >= 0x0300 - #define APT_UNUSED __attribute__((unused)) + #define APT_DEPRECATED __attribute__ ((deprecated)) #define APT_CONST __attribute__((const)) #define APT_PURE __attribute__((pure)) #define APT_NORETURN __attribute__((noreturn)) #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) #else - #define APT_UNUSED + #define APT_DEPRECATED #define APT_CONST #define APT_PURE #define APT_NORETURN @@ -103,8 +103,8 @@ #define APT_COLD __attribute__ ((__cold__)) #define APT_HOT __attribute__ ((__hot__)) #else - #define __cold - #define __hot + #define APT_COLD + #define APT_HOT #endif #ifndef APT_10_CLEANER_HEADERS diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc index 4351aeb22..b487a96f9 100644 --- a/apt-pkg/contrib/md5.cc +++ b/apt-pkg/contrib/md5.cc @@ -38,13 +38,9 @@ #include #include -#include -#include +#include #include -#include -#include // For htonl -#include /*}}}*/ // byteSwap - Swap bytes in a buffer /*{{{*/ diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index 195455645..f4992c223 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -23,14 +23,15 @@ #ifndef APTPKG_MD5_H #define APTPKG_MD5_H - -#include -#include -#include #include #include "hashsum_template.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 37acba340..b2a53a6cb 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -22,11 +22,11 @@ #include #include #include +#include +#include #include -#include #include -#include #include #include #include diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 32b146581..feaed67c8 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -15,14 +15,13 @@ #include #include -#include -#include #include #include #include #include #include +#include #include #include "netrc.h" diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 6feb5b726..dbeb45386 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -16,6 +16,8 @@ #include +#include + #ifndef APT_8_CLEANER_HEADERS #include #endif @@ -25,9 +27,9 @@ class URI; -// kill this export on the next ABI break - strongly doubt its in use anyway +// FIXME: kill this export on the next ABI break - strongly doubt its in use anyway // outside of the apt itself, its really a internal interface -__deprecated int parsenetrc (char *host, char *login, char *password, char *filename); +APT_DEPRECATED int parsenetrc (char *host, char *login, char *password, char *filename); void maybe_add_auth (URI &Uri, std::string NetRCFile); #endif diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 9d74ed495..4ff4f181d 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include #include diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index b5a6a2440..bf6bc6cb6 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -32,12 +32,9 @@ #include #include -#include -#include +#include #include -#include -#include /*}}}*/ // SHA1Transform - Alters an existing SHA-1 hash /*{{{*/ diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index a8d55eb13..5770c315a 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -14,12 +14,13 @@ #ifndef APTPKG_SHA1_H #define APTPKG_SHA1_H +#include "hashsum_template.h" + +#ifndef APT_10_CLEANER_HEADERS #include #include #include - -#include "hashsum_template.h" - +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h index 8e0c99a1b..a25ad4d32 100644 --- a/apt-pkg/contrib/sha2.h +++ b/apt-pkg/contrib/sha2.h @@ -14,14 +14,18 @@ #ifndef APTPKG_SHA2_H #define APTPKG_SHA2_H -#include #include -#include -#include #include "sha2_internal.h" #include "hashsum_template.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif + + typedef HashSumValue<512> SHA512SumValue; typedef HashSumValue<256> SHA256SumValue; diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index bb2560252..131ff5beb 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -33,6 +33,7 @@ */ #include +#include #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ #include "sha2_internal.h" diff --git a/apt-pkg/contrib/sha2_internal.h b/apt-pkg/contrib/sha2_internal.h index d9d429c92..1b82d965d 100644 --- a/apt-pkg/contrib/sha2_internal.h +++ b/apt-pkg/contrib/sha2_internal.h @@ -44,6 +44,7 @@ #ifdef SHA2_USE_INTTYPES_H +#include #include #endif /* SHA2_USE_INTTYPES_H */ diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 61fcc6a7d..2100ee47b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -21,6 +21,11 @@ #include #include +#include +#include +#include +#include +#include #include #include #include @@ -33,9 +38,9 @@ #include #include - -using namespace std; /*}}}*/ +using namespace std; + // Strip - Remove white space from the front and back of a string /*{{{*/ // --------------------------------------------------------------------- namespace APT { diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 3a6d38b75..79479957d 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -18,15 +18,18 @@ #include -#include #include #include #include #include #include +#include #include "macros.h" +#ifndef APT_10_CLEANER_HEADERS +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::vector; @@ -60,9 +63,9 @@ std::string Base64Encode(const std::string &Str); std::string OutputInDepth(const unsigned long Depth, const char* Separator=" "); std::string URItoFileName(const std::string &URI); std::string TimeRFC1123(time_t Date); -bool RFC1123StrToTime(const char* const str,time_t &time) __must_check; -bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check; -__deprecated bool StrToTime(const std::string &Val,time_t &Result); +bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK; +bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK; +APT_DEPRECATED bool StrToTime(const std::string &Val,time_t &Result); std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); int StringToBool(const std::string &Text,int Default = -1); bool ReadMessages(int Fd, std::vector &List); @@ -76,7 +79,7 @@ bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); // split a given string by a char -std::vector VectorizeString(std::string const &haystack, char const &split) __attrib_const; +std::vector VectorizeString(std::string const &haystack, char const &split) APT_CONST; /* \brief Return a vector of strings from string "input" where "sep" * is used as the delimiter string. @@ -94,13 +97,13 @@ std::vector VectorizeString(std::string const &haystack, char const */ std::vector StringSplit(std::string const &input, std::string const &sep, - unsigned int maxsplit=std::numeric_limits::max()) __attrib_const; + unsigned int maxsplit=std::numeric_limits::max()) APT_CONST; -void ioprintf(std::ostream &out,const char *format,...) __like_printf(2); -void strprintf(std::string &out,const char *format,...) __like_printf(2); -char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3); +void ioprintf(std::ostream &out,const char *format,...) APT_PRINTF(2); +void strprintf(std::string &out,const char *format,...) APT_PRINTF(2); +char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_PRINTF(3); bool CheckDomainList(const std::string &Host, const std::string &List); -int tolower_ascii(int const c) __attrib_const __hot; +int tolower_ascii(int const c) APT_CONST APT_HOT; std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ 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, diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index b45f5d9b5..149dbc0e7 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -11,20 +11,26 @@ #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/depcache.h b/apt-pkg/depcache.h index 50f810806..3ffc3b47d 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -40,18 +40,26 @@ #include #include +#include + +#include -#include #include -#include #include +#include +#include #ifndef APT_8_CLEANER_HEADERS #include #include #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#endif class OpProgress; +class pkgVersioningSystem; class pkgDepCache : protected pkgCache::Namespace { diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index dbd2dba46..ee42267bc 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -11,16 +11,25 @@ #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/edsp.h b/apt-pkg/edsp.h index 828ee3753..ae20ed7db 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -9,8 +9,11 @@ #ifndef PKGLIB_EDSP_H #define PKGLIB_EDSP_H -#include #include +#include +#include + +#include #include #include diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index 80b9f79ea..10313fd61 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -10,15 +10,20 @@ #include #include -#include -#include -#include #include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include +#include +#include /*}}}*/ // edspIndex::edspIndex - Constructor /*{{{*/ diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index de10f2d2f..bd3b41cf2 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -9,11 +9,15 @@ #define PKGLIB_EDSPINDEXFILE_H #include +#include #ifndef APT_8_CLEANER_HEADERS #include #endif +class OpProgress; +class pkgCacheGenerator; + class edspIndex : public debStatusIndex { /** \brief dpointer placeholder (for later in case we need it) */ diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 37959f37b..139deb9f1 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -12,11 +12,13 @@ #include #include -#include -#include -#include #include -#include +#include +#include +#include +#include + +#include /*}}}*/ // ListParser::edspListParser - Constructor /*{{{*/ diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h index a7bf9de95..959fb587f 100644 --- a/apt-pkg/edsp/edsplistparser.h +++ b/apt-pkg/edsp/edsplistparser.h @@ -12,6 +12,10 @@ #define PKGLIB_EDSPLISTPARSER_H #include +#include +#include + +#include #ifndef APT_8_CLEANER_HEADERS #include diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index b509fa001..92edb8d77 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -11,16 +11,17 @@ // Include Files /*{{{*/ #include -#include +#include #include #include -#include -#include +#include #include -#include -#include -#include -#include +#include +#include + +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h index ca703fa84..eafff39ba 100644 --- a/apt-pkg/edsp/edspsystem.h +++ b/apt-pkg/edsp/edspsystem.h @@ -11,8 +11,17 @@ #define PKGLIB_EDSPSYSTEM_H #include +#include +#include +#include + +class Configuration; +class pkgDepCache; +class pkgIndexFile; +class pkgPackageManager; class edspIndex; + class edspSystem : public pkgSystem { /** \brief dpointer placeholder (for later in case we need it) */ diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 59afa86ec..3a1385fa5 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -20,17 +20,17 @@ #include #include #include -#include #include +#include +#include #include #include #include #include -#include -#include #include #include +#include #include "indexcopy.h" #include diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h index e6a07a887..43cdb3f0a 100644 --- a/apt-pkg/indexcopy.h +++ b/apt-pkg/indexcopy.h @@ -14,16 +14,18 @@ #include #include -#include #include +#ifndef APT_10_CLEANER_HEADERS +#include +class FileFd; +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::vector; #endif class pkgTagSection; -class FileFd; class indexRecords; class pkgCdromStatus; @@ -99,9 +101,9 @@ class SigVerify /*{{{*/ bool CopyAndVerify(std::string CDROM,std::string Name,std::vector &SigList, std::vector PkgList,std::vector SrcList); - __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut, + APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd, int fd[2]); - __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut, + APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd = -1); }; /*}}}*/ diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 875c80336..89615cb41 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -13,7 +13,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include /*}}}*/ @@ -82,7 +88,7 @@ bool pkgIndexFile::TranslationsAvailable() { is already done in getLanguages(). Note also that this check is rather bad (doesn't take three character like ast into account). TODO: Remove method with next API break */ -__attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *Lang) +APT_DEPRECATED bool pkgIndexFile::CheckLanguageCode(const char *Lang) { if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_')) return true; @@ -98,7 +104,7 @@ __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *La /* As we have now possibly more than one LanguageCode this method is supersided by a) private classmembers or b) getLanguages(). TODO: Remove method with next API break */ -__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() { +APT_DEPRECATED std::string pkgIndexFile::LanguageCode() { if (TranslationsAvailable() == false) return ""; return APT::Configuration::getLanguages()[0]; diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 9a5c74200..98cdda603 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -22,18 +22,21 @@ #ifndef PKGLIB_INDEXFILE_H #define PKGLIB_INDEXFILE_H - -#include -#include #include #include +#include +#include #include +#include + #ifndef APT_8_CLEANER_HEADERS using std::string; #endif - +#ifndef APT_10_CLEANER_HEADERS class pkgAcquire; +#endif + class pkgCacheGenerator; class OpProgress; @@ -79,10 +82,10 @@ class pkgIndexFile virtual bool HasPackages() const = 0; virtual unsigned long Size() const = 0; virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; }; - __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const + APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const { return Merge(Gen, &Prog); }; virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;}; - __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const + APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const {return MergeFileProvides(Gen, &Prog);}; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index c1c397e31..1123d1690 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -14,8 +14,13 @@ #include #include -#include +#include +#include #include +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index d003ec0fa..e31f889ad 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -5,17 +5,19 @@ #ifndef PKGLIB_INDEXRECORDS_H #define PKGLIB_INDEXRECORDS_H - -#include #include #include #include #include +#include #ifndef APT_8_CLEANER_HEADERS #include #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#endif class indexRecords { diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 6ab5ec42d..3a35f852e 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -15,9 +15,11 @@ #include #include #include +#include +#include +#include #include -#include #include /*}}}*/ diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 4ee7a95ac..d062392e3 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -16,7 +16,9 @@ #include #include #endif +#ifndef APT_10_CLEANER_HEADERS #include +#endif class pkgSystem; class Configuration; diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 657330b60..6f43e0bc0 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -1,17 +1,23 @@ +#include + #include #include #include #include -#include - -#include +#include +#include +#include +#include +#include #include #include #include #include #include +#include + namespace APT { namespace Progress { @@ -329,15 +335,15 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, int row = GetNumberTerminalRows(); - static string save_cursor = "\033[s"; - static string restore_cursor = "\033[u"; - - static string set_bg_color = "\033[42m"; // green - static string set_fg_color = "\033[30m"; // black - - static string restore_bg = "\033[49m"; - static string restore_fg = "\033[39m"; - + static std::string save_cursor = "\033[s"; + static std::string restore_cursor = "\033[u"; + + static std::string set_bg_color = "\033[42m"; // green + static std::string set_fg_color = "\033[30m"; // black + + static std::string restore_bg = "\033[49m"; + static std::string restore_fg = "\033[39m"; + std::cout << save_cursor // move cursor position to last row << "\033[" << row << ";0f" diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index 18a90a29d..ffabaadbf 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -1,12 +1,19 @@ #ifndef PKGLIB_METAINDEX_H #define PKGLIB_METAINDEX_H - -#include -#include #include #include +#include + +#include +#include + +#ifndef APT_10_CLEANER_HEADERS +#include +class pkgCacheGenerator; +class OpProgress; +#endif #ifndef APT_8_CLEANER_HEADERS #include #include @@ -15,8 +22,6 @@ using std::string; #endif class pkgAcquire; -class pkgCacheGenerator; -class OpProgress; class metaIndex { diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 21b5fc4e7..a1fcbcc98 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -68,10 +68,14 @@ #include #include #include -#include #include #include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index a2d7b321b..1fdfbf559 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -16,10 +16,12 @@ #ifndef PKGLIB_ORDERLIST_H #define PKGLIB_ORDERLIST_H - #include +#include #include +#include + class pkgDepCache; class pkgOrderList : protected pkgCache::Namespace { @@ -46,7 +48,7 @@ class pkgOrderList : protected pkgCache::Namespace bool Debug; // Main visit function - __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; + APT_DEPRECATED bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; bool VisitNode(PkgIterator Pkg, char const* from); bool VisitDeps(DepFunc F,PkgIterator Pkg); bool VisitRDeps(DepFunc F,PkgIterator Pkg); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 0be76b311..4d08fb3ba 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -13,7 +13,7 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include +#include #include #include @@ -24,7 +24,14 @@ #include #include #include - +#include +#include +#include +#include + +#include +#include +#include #include #include diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index d684463eb..a86b176a4 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -23,15 +23,17 @@ #ifndef PKGLIB_PACKAGEMANAGER_H #define PKGLIB_PACKAGEMANAGER_H -#include #include -#include #include +#include #include -#include #include +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS #include using std::string; @@ -109,7 +111,7 @@ class pkgPackageManager : protected pkgCache::Namespace #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) OrderResult DoInstall(APT::Progress::PackageManager *progress); // compat - __deprecated OrderResult DoInstall(int statusFd=-1); + APT_DEPRECATED OrderResult DoInstall(int statusFd=-1); #else OrderResult DoInstall(int statusFd=-1); #endif @@ -124,7 +126,7 @@ class pkgPackageManager : protected pkgCache::Namespace // stuff that needs to be done after the fork OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress); // compat - __deprecated OrderResult DoInstallPostFork(int statusFd=-1); + APT_DEPRECATED OrderResult DoInstallPostFork(int statusFd=-1); #else OrderResult DoInstallPostFork(int statusFd=-1); #endif diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 9c14e626e..a19b9571c 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -29,12 +29,15 @@ #include #include #include +#include #include +#include +#include +#include +#include #include #include -#include -#include #include /*}}}*/ diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 185b9ca45..525f1dfb4 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -18,20 +18,26 @@ #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 /*}}}*/ @@ -1333,7 +1339,7 @@ DynamicMMap* pkgCacheGenerator::CreateDynamicMMap(FileFd *CacheF, unsigned long the cache will be stored there. This is pretty much mandetory if you are using AllowMem. AllowMem lets the function be run as non-root where it builds the cache 'fast' into a memory buffer. */ -__deprecated bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, +APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, MMap **OutMap, bool AllowMem) { return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); } bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress, @@ -1534,7 +1540,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress // CacheGenerator::MakeOnlyStatusCache - Build only a status files cache/*{{{*/ // --------------------------------------------------------------------- /* */ -__deprecated bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) +APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); } bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap) { diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index e8901025e..9ccf71c7b 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -19,16 +19,18 @@ #ifndef PKGLIB_PKGCACHEGEN_H #define PKGLIB_PKGCACHEGEN_H - -#include #include +#include +#include +#include #include #include +#include +class FileFd; class pkgSourceList; class OpProgress; -class MMap; class pkgIndexFile; class pkgCacheGenerator /*{{{*/ @@ -80,7 +82,7 @@ class pkgCacheGenerator /*{{{*/ bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver, map_ptrloc const Version, unsigned int const &Op, unsigned int const &Type, map_ptrloc* &OldDepLast); - __deprecated unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next) + unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next) APT_DEPRECATED { return NewVersion(Ver, VerStr, 0, 0, Next); } unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr, map_ptrloc const ParentPkg, unsigned long const Hash, @@ -102,7 +104,7 @@ class pkgCacheGenerator /*{{{*/ bool HasFileDeps() {return FoundFileDeps;}; bool MergeFileProvides(ListParser &List); - __deprecated bool FinishCache(OpProgress *Progress); + bool FinishCache(OpProgress *Progress) APT_DEPRECATED; static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress, MMap **OutMap = 0,bool AllowMem = false); diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index 36dab3480..c403e4dc3 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -14,7 +14,11 @@ #include #include #include -#include +#include +#include + +#include +#include #include /*}}}*/ diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index ca0984bbf..b5237b3a0 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -17,8 +17,9 @@ #ifndef PKGLIB_PKGRECORDS_H #define PKGLIB_PKGRECORDS_H - #include + +#include #include class pkgRecords /*{{{*/ diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index 05ba6e0e6..ee6c3f4ec 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -13,7 +13,6 @@ #include #include -#include #include #include /*}}}*/ diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h index eb75df412..6e33c67ed 100644 --- a/apt-pkg/pkgsystem.h +++ b/apt-pkg/pkgsystem.h @@ -38,6 +38,7 @@ #define PKGLIB_PKGSYSTEM_H #include +#include #include @@ -50,7 +51,6 @@ class pkgPackageManager; class pkgVersioningSystem; class Configuration; class pkgIndexFile; -class PkgFileIterator; class pkgSystem { diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 2176f1f42..ae30b6f50 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -33,7 +33,15 @@ #include #include #include - +#include +#include +#include + +#include +#include +#include +#include +#include #include #include diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h index 5172a3c3b..f15d8c0a0 100644 --- a/apt-pkg/policy.h +++ b/apt-pkg/policy.h @@ -33,10 +33,13 @@ #ifndef PKGLIB_POLICY_H #define PKGLIB_POLICY_H - #include +#include +#include #include + #include +#include #ifndef APT_8_CLEANER_HEADERS using std::vector; diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 1f5179885..e37899ec6 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -18,7 +18,16 @@ #include #include #include - +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index 0ccb4aa00..af7569375 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -27,18 +27,26 @@ #ifndef PKGLIB_SOURCELIST_H #define PKGLIB_SOURCELIST_H +#include +#include + +#include + #include #include #include -#include -#include +#ifndef APT_8_CLEANER_HEADERS +#include +#endif #ifndef APT_8_CLEANER_HEADERS #include using std::string; using std::vector; #endif +class FileFd; +class pkgTagSection; class pkgAcquire; class pkgIndexFile; class metaIndex; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 60b62850a..775cf2e5f 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -16,8 +16,13 @@ #include #include #include -#include #include +#include +#include + +#include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index e1459c80e..906321456 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include /*}}}*/ diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc index 97be5490b..5d5b19626 100644 --- a/apt-pkg/update.cc +++ b/apt-pkg/update.cc @@ -1,24 +1,17 @@ - // Include Files /*{{{*/ #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/upgrade.cc b/apt-pkg/upgrade.cc index d6f6933dd..7926845c2 100644 --- a/apt-pkg/upgrade.cc +++ b/apt-pkg/upgrade.cc @@ -1,24 +1,17 @@ - // Include Files /*{{{*/ #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/upgrade.h b/apt-pkg/upgrade.h index 436d38300..aa883df10 100644 --- a/apt-pkg/upgrade.h +++ b/apt-pkg/upgrade.h @@ -10,6 +10,8 @@ #ifndef PKGLIB_UPGRADE_H #define PKGLIB_UPGRADE_H +class pkgDepCache; + namespace APT { namespace Upgrade { // FIXME: make this "enum class UpgradeMode {" once we enable c++11 diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc index f19534171..986636e97 100644 --- a/apt-pkg/vendor.cc +++ b/apt-pkg/vendor.cc @@ -1,10 +1,14 @@ #include -#include -#include #include #include +#include +#include +#include +#include +#include + Vendor::Vendor(std::string VendorID, std::string Origin, std::vector *FingerprintList) diff --git a/apt-pkg/vendor.h b/apt-pkg/vendor.h index 6484adf9b..2d2e2b0ae 100644 --- a/apt-pkg/vendor.h +++ b/apt-pkg/vendor.h @@ -11,7 +11,7 @@ using std::string; #endif // A class representing a particular software provider. -class __deprecated Vendor +class APT_DEPRECATED Vendor { public: struct Fingerprint diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 602425624..fb33ff17d 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -3,9 +3,16 @@ #include #include #include + +#include +#include +#include +#include + #include #if __GNUC__ >= 4 + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif @@ -157,5 +164,5 @@ const Vendor* pkgVendorList::FindVendor(const std::vector GPGVOutput) /* /*}}}*/ #if __GNUC__ >= 4 - #pragma GCC diagnostic warning "-Wdeprecated-declarations" + #pragma GCC diagnostic pop #endif diff --git a/apt-pkg/vendorlist.h b/apt-pkg/vendorlist.h index a86ccde7c..bc3702a93 100644 --- a/apt-pkg/vendorlist.h +++ b/apt-pkg/vendorlist.h @@ -27,7 +27,7 @@ using std::vector; class Vendor; class Configuration; -class __deprecated pkgVendorList +class APT_DEPRECATED pkgVendorList { protected: std::vector VendorList; diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc index cb2c34c0f..29bee46da 100644 --- a/apt-pkg/version.cc +++ b/apt-pkg/version.cc @@ -11,8 +11,8 @@ #include #include -#include +#include #include /*}}}*/ diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 26262a010..284098bdf 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -16,11 +16,16 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include -#include #include /*}}}*/ diff --git a/apt-pkg/versionmatch.h b/apt-pkg/versionmatch.h index 433396fc9..a889878ad 100644 --- a/apt-pkg/versionmatch.h +++ b/apt-pkg/versionmatch.h @@ -35,9 +35,10 @@ #ifndef PKGLIB_VERSIONMATCH_H #define PKGLIB_VERSIONMATCH_H +#include +#include #include -#include #ifndef APT_8_CLEANER_HEADERS using std::string; -- 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/acquire-item.cc | 2 +- apt-pkg/acquire.cc | 6 +++--- apt-pkg/acquire.h | 4 ++-- apt-pkg/algorithms.h | 2 +- apt-pkg/cacheiterators.h | 35 ++++++++++++++++++----------------- apt-pkg/cacheset.cc | 10 +++++----- apt-pkg/contrib/cmndline.h | 8 +++++--- apt-pkg/contrib/crc-16.h | 4 +++- apt-pkg/contrib/error.h | 8 ++++---- apt-pkg/contrib/fileutl.h | 2 +- apt-pkg/contrib/gpgv.h | 2 +- apt-pkg/contrib/hashes.cc | 2 +- apt-pkg/contrib/hashes.h | 2 +- apt-pkg/contrib/strutl.h | 36 ++++++++++++++++++------------------ apt-pkg/deb/debindexfile.cc | 2 +- apt-pkg/deb/debindexfile.h | 8 ++++---- apt-pkg/deb/debsystem.cc | 2 +- apt-pkg/deb/debversion.h | 14 +++++++------- apt-pkg/depcache.cc | 4 ++-- apt-pkg/depcache.h | 3 ++- apt-pkg/edsp/edspindexfile.h | 2 +- apt-pkg/edsp/edsplistparser.cc | 2 +- apt-pkg/edsp/edspsystem.h | 8 ++++---- apt-pkg/indexcopy.cc | 6 ++---- apt-pkg/indexfile.h | 2 +- apt-pkg/indexrecords.cc | 14 +++++++------- apt-pkg/install-progress.cc | 4 ++-- apt-pkg/orderlist.h | 8 ++++---- apt-pkg/packagemanager.h | 2 +- apt-pkg/pkgcache.h | 14 ++++++++------ apt-pkg/pkgcachegen.h | 2 +- apt-pkg/pkgsystem.cc | 4 +++- apt-pkg/policy.cc | 4 ++-- apt-pkg/sourcelist.h | 3 ++- apt-pkg/srcrecords.h | 3 ++- apt-pkg/tagfile.cc | 2 +- apt-pkg/vendor.cc | 2 +- apt-pkg/version.h | 2 +- apt-pkg/versionmatch.h | 14 +++++++------- 39 files changed, 132 insertions(+), 122 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 44a1f32df..ad38e3116 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -2162,7 +2162,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*}}}*/ // AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/ // --------------------------------------------------------------------- -bool pkgAcqArchive::IsTrusted() +APT_PURE bool pkgAcqArchive::IsTrusted() { return Trusted; } diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index a654d8219..a187a00ae 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -526,7 +526,7 @@ bool pkgAcquire::Clean(string Dir) // Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/ // --------------------------------------------------------------------- /* This is the total number of bytes needed */ -unsigned long long pkgAcquire::TotalNeeded() +APT_PURE unsigned long long pkgAcquire::TotalNeeded() { unsigned long long Total = 0; for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) @@ -537,7 +537,7 @@ unsigned long long pkgAcquire::TotalNeeded() // Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/ // --------------------------------------------------------------------- /* This is the number of bytes that is not local */ -unsigned long long pkgAcquire::FetchNeeded() +APT_PURE unsigned long long pkgAcquire::FetchNeeded() { unsigned long long Total = 0; for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) @@ -549,7 +549,7 @@ unsigned long long pkgAcquire::FetchNeeded() // Acquire::PartialPresent - Number of partial bytes we already have /*{{{*/ // --------------------------------------------------------------------- /* This is the number of bytes that is not local */ -unsigned long long pkgAcquire::PartialPresent() +APT_PURE unsigned long long pkgAcquire::PartialPresent() { unsigned long long Total = 0; for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 1aac0ba11..ef16d8556 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -298,7 +298,7 @@ class pkgAcquire * \return the worker immediately following I, or \b NULL if none * exists. */ - Worker *WorkerStep(Worker *I); + Worker *WorkerStep(Worker *I) APT_PURE; /** \brief Get the head of the list of items. */ inline ItemIterator ItemsBegin() {return Items.begin();}; @@ -481,7 +481,7 @@ class pkgAcquire::Queue * \return the first item in the queue whose URI is #URI and that * is being downloaded by #Owner. */ - QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner); + QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner) APT_PURE; /** Presumably this should start downloading an item? * diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index 82b6426c6..f35bd9a13 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -114,7 +114,7 @@ class pkgProblemResolver /*{{{*/ // Sort stuff static pkgProblemResolver *This; - static int ScoreSort(const void *a,const void *b); + static int ScoreSort(const void *a,const void *b) APT_PURE; struct PackageKill { diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index d9c8ed1e4..2fdf8404d 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -30,6 +30,7 @@ #ifndef PKGLIB_CACHEITERATORS_H #define PKGLIB_CACHEITERATORS_H #include +#include #include #include @@ -163,15 +164,15 @@ class pkgCache::PkgIterator: public Iterator { inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge || (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);} inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;} - inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);} + inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);} - inline VerIterator VersionList() const; - inline VerIterator CurrentVer() const; - inline DepIterator RevDependsList() const; - inline PrvIterator ProvidesList() const; - OkState State() const; - const char *CandVersion() const; - const char *CurVersion() const; + inline VerIterator VersionList() const APT_PURE; + inline VerIterator CurrentVer() const APT_PURE; + inline DepIterator RevDependsList() const APT_PURE; + inline PrvIterator ProvidesList() const APT_PURE; + OkState State() const APT_PURE; + const char *CandVersion() const APT_PURE; + const char *CurVersion() const APT_PURE; //Nice printable representation friend std::ostream& operator <<(std::ostream& out, PkgIterator i); @@ -224,7 +225,7 @@ class pkgCache::VerIterator : public Iterator { inline VerFileIterator FileList() const; bool Downloadable() const; inline const char *PriorityType() const {return Owner->Priority(S->Priority);} - const char *MultiArchType() const; + const char *MultiArchType() const APT_PURE; std::string RelStr() const; bool Automatic() const; @@ -286,13 +287,13 @@ class pkgCache::DepIterator : public Iterator { inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);} inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);} inline bool Reverse() const {return Type == DepRev;} - bool IsCritical() const; - bool IsNegative() const; - bool IsIgnorable(PrvIterator const &Prv) const; - bool IsIgnorable(PkgIterator const &Pkg) const; - bool IsMultiArchImplicit() const; - bool IsSatisfied(VerIterator const &Ver) const; - bool IsSatisfied(PrvIterator const &Prv) const; + bool IsCritical() const APT_PURE; + bool IsNegative() const APT_PURE; + bool IsIgnorable(PrvIterator const &Prv) const APT_PURE; + bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE; + bool IsMultiArchImplicit() const APT_PURE; + bool IsSatisfied(VerIterator const &Ver) const APT_PURE; + bool IsSatisfied(PrvIterator const &Prv) const APT_PURE; void GlobOr(DepIterator &Start,DepIterator &End); Version **AllTargets() const; bool SmartTargetPkg(PkgIterator &Result) const; @@ -337,7 +338,7 @@ class pkgCache::PrvIterator : public Iterator { inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);} inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);} - bool IsMultiArchImplicit() const; + bool IsMultiArchImplicit() const APT_PURE; inline PrvIterator() : Iterator(), Type(PrvVer) {} inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) : diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index a58631d5b..d453a2bfb 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -614,7 +614,7 @@ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pk } #endif /*}}}*/ // canNotFindPackage - handle the case no package is found from a string/*{{{*/ -void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { +APT_CONST void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const /*pci*/, pkgCacheFile &/*Cache*/, std::string const &/*str*/) { } /*}}}*/ // canNotFindAllVer /*{{{*/ @@ -663,24 +663,24 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache } /*}}}*/ // showTaskSelection /*{{{*/ -void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, +APT_CONST void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &/*pkg*/, std::string const &/*pattern*/) { } /*}}}*/ // showRegExSelection /*{{{*/ -void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, +APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/*pkg*/, std::string const &/*pattern*/) { } /*}}}*/ #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) // showFnmatchSelection /*{{{*/ -void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, +APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern) { } /*}}}*/ #endif // showSelectedVersion /*{{{*/ -void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, +APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, pkgCache::VerIterator const /*Ver*/, std::string const &/*ver*/, bool const /*verIsRel*/) { diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h index 180276633..143df58b2 100644 --- a/apt-pkg/contrib/cmndline.h +++ b/apt-pkg/contrib/cmndline.h @@ -44,6 +44,8 @@ #ifndef PKGLIB_CMNDLINE_H #define PKGLIB_CMNDLINE_H +#include + #ifndef APT_8_CLEANER_HEADERS #include #endif @@ -80,14 +82,14 @@ class CommandLine bool Parse(int argc,const char **argv); void ShowHelp(); - unsigned int FileSize() const; + unsigned int FileSize() const APT_PURE; bool DispatchArg(Dispatch *List,bool NoMatch = true); static char const * GetCommand(Dispatch const * const Map, - unsigned int const argc, char const * const * const argv); + unsigned int const argc, char const * const * const argv) APT_PURE; static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt, - char const *ConfName, unsigned long Flags); + char const *ConfName, unsigned long Flags) APT_CONST; CommandLine(Args *AList,Configuration *Conf); ~CommandLine(); diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h index 702de40b2..08acdafb7 100644 --- a/apt-pkg/contrib/crc-16.h +++ b/apt-pkg/contrib/crc-16.h @@ -10,8 +10,10 @@ #ifndef APTPKG_CRC16_H #define APTPKG_CRC16_H +#include + #define INIT_FCS 0xffff unsigned short AddCRC16(unsigned short fcs, void const *buf, - unsigned long long len); + unsigned long long len) APT_PURE; #endif diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index 919b1e6d4..ed8c19153 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -141,7 +141,7 @@ public: /*{{{*/ */ bool InsertErrno(MsgType type, const char* Function, const char* Description, va_list &args, - int const errsv, size_t &msgSize); + int const errsv, size_t &msgSize) APT_COLD; /** \brief add an fatal error message to the list * @@ -225,7 +225,7 @@ public: /*{{{*/ * * \return \b true if an error is included in the list, \b false otherwise */ - inline bool PendingError() const {return PendingFlag;}; + inline bool PendingError() const APT_PURE {return PendingFlag;}; /** \brief is the list empty? * @@ -237,7 +237,7 @@ public: /*{{{*/ * * \return \b true if an the list is empty, \b false otherwise */ - bool empty(MsgType const &threshold = WARNING) const; + bool empty(MsgType const &threshold = WARNING) const APT_PURE; /** \brief returns and removes the first (or last) message in the list * @@ -303,7 +303,7 @@ public: /*{{{*/ void MergeWithStack(); /** \brief return the deep of the stack */ - size_t StackCount() const { + size_t StackCount() const APT_PURE { return Stacks.size(); } diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 6fdea1294..35f3ab0f4 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -119,7 +119,7 @@ class FileFd // Simple manipulators inline int Fd() {return iFd;}; inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);}; - gzFile gzFd() APT_DEPRECATED; + gzFile gzFd() APT_DEPRECATED APT_PURE; inline bool IsOpen() {return iFd >= 0;}; inline bool Failed() {return (Flags & Fail) == Fail;}; diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h index ab3c68de5..f018893fd 100644 --- a/apt-pkg/contrib/gpgv.h +++ b/apt-pkg/contrib/gpgv.h @@ -41,7 +41,7 @@ class FileFd; */ void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd, int fd[2]) APT_NORETURN; -inline void ExecGPGV(std::string const &File, std::string const &FileSig, +inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig, int const &statusfd = -1) { int fd[2]; ExecGPGV(File, FileSig, statusfd, fd); diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 5efafa511..1fce0d75f 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -116,7 +116,7 @@ const char** HashString::SupportedHashes() return _SupportedHashes; } -bool HashString::empty() const +APT_PURE bool HashString::empty() const { return (Type.empty() || Hash.empty()); } diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 979ee1eb8..5cd1af03b 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -66,7 +66,7 @@ class HashString bool empty() const; // return the list of hashes we support - static const char** SupportedHashes(); + static APT_CONST const char** SupportedHashes(); }; class Hashes diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 79479957d..185cdc3fc 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -107,43 +107,43 @@ int tolower_ascii(int const c) APT_CONST APT_HOT; std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ -inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \ -inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ -inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \ -inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \ -inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);} +inline APT_PURE int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));} \ +inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ +inline APT_PURE int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));} \ +inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());} \ +inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);} #define APT_MKSTRCMP2(name,func) \ -inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ -inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \ -inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \ -inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);} +inline APT_PURE int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));} \ +inline APT_PURE int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));} \ +inline APT_PURE int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());} \ +inline APT_PURE int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);} -int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); -int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); +int APT_PURE stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); +int APT_PURE stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); /* We assume that GCC 3 indicates that libstdc++3 is in use too. In that case the definition of string::const_iterator is not the same as const char * and we need these extra functions */ #if __GNUC__ >= 3 -int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, +int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, +int APT_PURE stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, std::string::const_iterator B,std::string::const_iterator BEnd); -int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, +int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, +int APT_PURE stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, std::string::const_iterator B,std::string::const_iterator BEnd); -inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));} -inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));} +inline APT_PURE int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));} +inline APT_PURE int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));} #endif APT_MKSTRCMP2(stringcmp,stringcmp) APT_MKSTRCMP2(stringcasecmp,stringcasecmp) // Return the length of a NULL-terminated string array -size_t strv_length(const char **str_array); +size_t APT_PURE strv_length(const char **str_array); inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);} 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(); diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 149dbc0e7..e2c412757 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1691,9 +1691,9 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) } /*}}}*/ // Policy::GetPriority - Get the priority of the package pin /*{{{*/ -signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/) +APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgIterator const &/*Pkg*/) { return 0; } -signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/) +APT_CONST signed short pkgDepCache::Policy::GetPriority(pkgCache::PkgFileIterator const &/*File*/) { return 0; } /*}}}*/ pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc() /*{{{*/ diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 3ffc3b47d..bde648c65 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -239,7 +240,7 @@ class pkgDepCache : protected pkgCache::Namespace unsigned char DepState; // DepState Flags // Update of candidate version - const char *StripEpoch(const char *Ver); + const char *StripEpoch(const char *Ver) APT_PURE; void Update(PkgIterator Pkg,pkgCache &Cache); // Various test members for the current status of the package diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index bd3b41cf2..609a2cde4 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -25,7 +25,7 @@ class edspIndex : public debStatusIndex public: - virtual const Type *GetType() const; + virtual const Type *GetType() const APT_CONST; virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 139deb9f1..212dc7840 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -86,7 +86,7 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, } /*}}}*/ // ListParser::LoadReleaseInfo - Load the release information /*{{{*/ -bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/, +APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/, FileFd & /*File*/, std::string /*component*/) { return true; diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h index eafff39ba..65e36d714 100644 --- a/apt-pkg/edsp/edspsystem.h +++ b/apt-pkg/edsp/edspsystem.h @@ -31,11 +31,11 @@ class edspSystem : public pkgSystem public: - virtual bool Lock(); - virtual bool UnLock(bool NoErrors = false); - virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const; + virtual bool Lock() APT_CONST; + virtual bool UnLock(bool NoErrors = false) APT_CONST; + virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const APT_CONST; virtual bool Initialize(Configuration &Cnf); - virtual bool ArchiveSupported(const char *Type); + virtual bool ArchiveSupported(const char *Type) APT_CONST; virtual signed Score(Configuration const &Cnf); virtual bool AddStatusFiles(std::vector &List); virtual bool FindIndex(pkgCache::PkgFileIterator File, diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 3a1385fa5..854ba1bd7 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -642,15 +642,13 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, } /*}}}*/ // SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV /*{{{*/ -bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, +APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd, int fd[2]) { ExecGPGV(File, FileOut, statusfd, fd); - return false; } -bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, +APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, int const &statusfd) { ExecGPGV(File, FileOut, statusfd); - return false; } /*}}}*/ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 98cdda603..b5c9ac77e 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -54,7 +54,7 @@ class pkgIndexFile // Global list of Items supported static Type **GlobalList; static unsigned long GlobalListLen; - static Type *GetType(const char *Type); + static Type *GetType(const char *Type) APT_PURE; const char *Label; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 1123d1690..5353d1098 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -27,33 +27,33 @@ using std::string; -string indexRecords::GetDist() const +APT_PURE string indexRecords::GetDist() const { return this->Dist; } -string indexRecords::GetSuite() const +APT_PURE string indexRecords::GetSuite() const { return this->Suite; } -bool indexRecords::CheckDist(const string MaybeDist) const +APT_PURE bool indexRecords::CheckDist(const string MaybeDist) const { return (this->Dist == MaybeDist || this->Suite == MaybeDist); } -string indexRecords::GetExpectedDist() const +APT_PURE string indexRecords::GetExpectedDist() const { return this->ExpectedDist; } -time_t indexRecords::GetValidUntil() const +APT_PURE time_t indexRecords::GetValidUntil() const { return this->ValidUntil; } -const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) +APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) { std::map::const_iterator sum = Entries.find(MetaKey); if (sum == Entries.end()) @@ -61,7 +61,7 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) return sum->second; } -bool indexRecords::Exists(string const &MetaKey) const +APT_PURE bool indexRecords::Exists(string const &MetaKey) const { return Entries.count(MetaKey) == 1; } diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 6f43e0bc0..dfe4fb18c 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -93,7 +93,7 @@ void PackageManagerProgressFd::StartDpkg() WriteToStatusFd(status.str()); } -void PackageManagerProgressFd::Stop() +APT_CONST void PackageManagerProgressFd::Stop() { } @@ -176,7 +176,7 @@ void PackageManagerProgressDeb822Fd::StartDpkg() WriteToStatusFd(status.str()); } -void PackageManagerProgressDeb822Fd::Stop() +APT_CONST void PackageManagerProgressDeb822Fd::Stop() { } diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 1fdfbf559..b8bad81b3 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -70,9 +70,9 @@ class pkgOrderList : protected pkgCache::Namespace // For pre sorting static pkgOrderList *Me; - static int OrderCompareA(const void *a, const void *b); - static int OrderCompareB(const void *a, const void *b); - int FileCmp(PkgIterator A,PkgIterator B); + static int OrderCompareA(const void *a, const void *b) APT_PURE; + static int OrderCompareB(const void *a, const void *b) APT_PURE; + int FileCmp(PkgIterator A,PkgIterator B) APT_PURE; public: @@ -102,7 +102,7 @@ class pkgOrderList : protected pkgCache::Namespace inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~F;}; // IsNow will return true if the Pkg has been not been either configured or unpacked inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; - bool IsMissing(PkgIterator Pkg); + bool IsMissing(PkgIterator Pkg) APT_PURE; void WipeFlags(unsigned long F); void SetFileList(std::string *FileList) {this->FileList = FileList;}; diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index a86b176a4..344ed9192 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -75,7 +75,7 @@ class pkgPackageManager : protected pkgCache::Namespace bool CreateOrderList(); // Analysis helpers - bool DepAlwaysTrue(DepIterator D); + bool DepAlwaysTrue(DepIterator D) APT_PURE; // Install helpers bool ConfigureAll(); diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index b3a714511..5e8a9630a 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -74,9 +74,11 @@ #ifndef PKGLIB_PKGCACHE_H #define PKGLIB_PKGCACHE_H +#include +#include + #include #include -#include #ifndef APT_8_CLEANER_HEADERS using std::string; @@ -156,8 +158,8 @@ class pkgCache /*{{{*/ std::string CacheFile; MMap ⤅ - unsigned long sHash(const std::string &S) const; - unsigned long sHash(const char *S) const; + unsigned long sHash(const std::string &S) const APT_PURE; + unsigned long sHash(const char *S) const APT_PURE; public: @@ -207,8 +209,8 @@ class pkgCache /*{{{*/ pkgVersioningSystem *VS; // Converters - static const char *CompTypeDeb(unsigned char Comp); - static const char *CompType(unsigned char Comp); + static const char *CompTypeDeb(unsigned char Comp) APT_CONST; + static const char *CompType(unsigned char Comp) APT_CONST; static const char *DepType(unsigned char Dep); pkgCache(MMap *Map,bool DoMap = true); @@ -318,7 +320,7 @@ struct pkgCache::Header /** \brief Size of the complete cache file */ unsigned long CacheFileSize; - bool CheckSizes(Header &Against) const; + bool CheckSizes(Header &Against) const APT_PURE; Header(); }; /*}}}*/ diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 9ccf71c7b..898b34358 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -104,7 +104,7 @@ class pkgCacheGenerator /*{{{*/ bool HasFileDeps() {return FoundFileDeps;}; bool MergeFileProvides(ListParser &List); - bool FinishCache(OpProgress *Progress) APT_DEPRECATED; + bool FinishCache(OpProgress *Progress) APT_DEPRECATED APT_CONST; static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress, MMap **OutMap = 0,bool AllowMem = false); diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index ee6c3f4ec..14d090c7a 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -13,6 +13,8 @@ #include #include +#include + #include #include /*}}}*/ @@ -35,7 +37,7 @@ pkgSystem::pkgSystem() : Label(NULL), VS(NULL) // System::GetSystem - Get the named system /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgSystem *pkgSystem::GetSystem(const char *Label) +APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label) { for (unsigned I = 0; I != GlobalListLen; I++) if (strcmp(SysList[I]->Label,Label) == 0) diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index ae30b6f50..3cfc32829 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -333,7 +333,7 @@ pkgCache::VerIterator pkgPolicy::GetMatch(pkgCache::PkgIterator const &Pkg) // Policy::GetPriority - Get the priority of the package pin /*{{{*/ // --------------------------------------------------------------------- /* */ -signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg) +APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg) { if (Pins[Pkg->ID].Type != pkgVersionMatch::None) { @@ -345,7 +345,7 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg) return 0; } -signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File) +APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File) { return PFPriority[File->ID]; } diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index af7569375..9df0c1d74 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -29,6 +29,7 @@ #include #include +#include #include @@ -63,7 +64,7 @@ class pkgSourceList // Global list of Items supported static Type **GlobalList; static unsigned long GlobalListLen; - static Type *GetType(const char *Type); + static Type *GetType(const char *Type) APT_PURE; const char *Name; const char *Label; diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index ed69d0d72..9915debfe 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -13,6 +13,7 @@ #ifndef PKGLIB_SRCRECORDS_H #define PKGLIB_SRCRECORDS_H +#include #include #include @@ -73,7 +74,7 @@ class pkgSrcRecords //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching virtual bool BuildDepends(std::vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0; - static const char *BuildDepType(unsigned char const &Type); + static const char *BuildDepType(unsigned char const &Type) APT_PURE; virtual bool Files(std::vector &F) = 0; diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 906321456..91d176e3c 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -85,7 +85,7 @@ pkgTagFile::~pkgTagFile() } /*}}}*/ // TagFile::Offset - Return the current offset in the buffer /*{{{*/ -unsigned long pkgTagFile::Offset() +APT_PURE unsigned long pkgTagFile::Offset() { return d->iOffset; } diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc index 986636e97..d4add560e 100644 --- a/apt-pkg/vendor.cc +++ b/apt-pkg/vendor.cc @@ -35,7 +35,7 @@ const std::string Vendor::LookupFingerprint(std::string Print) const return (*Elt).second; } -bool Vendor::CheckDist(std::string /*Dist*/) +APT_CONST bool Vendor::CheckDist(std::string /*Dist*/) { return true; } diff --git a/apt-pkg/version.h b/apt-pkg/version.h index e0e0e6c14..d98809f7e 100644 --- a/apt-pkg/version.h +++ b/apt-pkg/version.h @@ -33,7 +33,7 @@ class pkgVersioningSystem // Global list of VS's static pkgVersioningSystem **GlobalList; static unsigned long GlobalListLen; - static pkgVersioningSystem *GetVS(const char *Label); + static pkgVersioningSystem *GetVS(const char *Label) APT_PURE; const char *Label; diff --git a/apt-pkg/versionmatch.h b/apt-pkg/versionmatch.h index a889878ad..4c8f704c8 100644 --- a/apt-pkg/versionmatch.h +++ b/apt-pkg/versionmatch.h @@ -45,7 +45,7 @@ using std::string; #endif class pkgVersionMatch -{ +{ // Version Matching std::string VerStr; bool VerPrefixMatch; @@ -61,20 +61,20 @@ class pkgVersionMatch std::string RelComponent; std::string RelArchitecture; bool MatchAll; - + // Origin Matching std::string OrSite; - + public: - + enum MatchType {None = 0,Version,Release,Origin} Type; - - bool MatchVer(const char *A,std::string B,bool Prefix); + + bool MatchVer(const char *A,std::string B,bool Prefix) APT_PURE; bool ExpressionMatches(const char *pattern, const char *string); bool ExpressionMatches(const std::string& pattern, const char *string); bool FileMatch(pkgCache::PkgFileIterator File); pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg); - + pkgVersionMatch(std::string Data,MatchType Type); }; -- cgit v1.2.3 From 0caa5a4c6472d1b74444c4f38ced6c3b89fa50fe Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 8 Mar 2014 17:29:46 +0100 Subject: do not configure already unpacked packages needlessly The unpack of a M-A:same package will force the unpack of all its siblings directly to prevent that they could be separated by later immediate actions. In commit 634985f8 a call to SmartConfigure was introduced to configure these packages at the time the installation order encounters them. Usually, the unpack order is already okay, so that this 'earlier' unpack was not needed and if it wouldn't have been done, the package would now only be unpacked, but by configuring the package now we impose new requirements which must be satisfied. The code is clever enough to handle this most of the time (it worked for 2 years!), but it isn't needed and in very coupled cases this can fail. Removing this call again removes this extra burden and so simplifies the ordering as can be seen in the modified tests. Famous last words, but I don't see a reason for this extra burden to exist hence the remove. Closes: 740843 --- apt-pkg/packagemanager.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 4d08fb3ba..5d6bc6bd2 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -622,6 +622,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c clog << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")"; if (PkgLoop) clog << " (Only Perform PreUnpack Checks)"; + if (Immediate) + clog << " immediately"; clog << endl; } @@ -963,21 +965,14 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); - + if (List->IsNow(Pkg) == false) { - if (!List->IsFlag(Pkg,pkgOrderList::Configured) && !NoImmConfigure) { - if (SmartConfigure(Pkg, 0) == false && Debug) - _error->Warning("Internal Error, Could not configure %s",Pkg.FullName().c_str()); - // FIXME: The above warning message might need changing - } else { - if (Debug == true) - clog << "Skipping already done " << Pkg.FullName() << endl; - } + if (Debug == true) + clog << "Skipping already done " << Pkg.FullName() << endl; continue; - } - + if (List->IsMissing(Pkg) == true) { if (Debug == true) -- cgit v1.2.3 From 79bde56ea93b396e509fff0ad7a490f949aa5aa4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Mar 2014 13:32:07 +0100 Subject: if mountpoint has a ".disk" directory it is mounted Checking that parent-directory of mountpoint and mountpoint are on different devices is fine most of the time, but is too restrictive for our testcases and there shouldn't be anything wrong with 'normal' users copying disk-contents around either if they want to. We check for the existance of the ".disk/" directory now as this will not be present if the disk isn't 'mounted'. Disks doesn't need to have such a directory through, so for those we fall back to the old way of detecting mounted or not mounted. --- apt-pkg/contrib/cdromutl.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 096d3bcf5..176cc2024 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -45,11 +45,16 @@ bool IsMounted(string &Path) { if (Path.empty() == true) return false; - + // Need that trailing slash for directories if (Path[Path.length() - 1] != '/') Path += '/'; - + + // if the path has a ".disk" directory we treat it as mounted + // this way even extracted copies of disks are recognized + if (DirectoryExists(Path + ".disk/") == true) + return true; + /* First we check if the path is actually mounted, we do this by stating the path and the previous directory (careful of links!) and comparing their device fields. */ -- cgit v1.2.3 From 454b97a57ff3b7ced87ac359658adecaae7af7ee Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Mar 2014 14:38:07 +0100 Subject: no error for non-existing mountpoints in MountCdrom The mountpoint might be auto-generated by the mount command so pushing an error on the stack will confuse the following code and let it believe an unrecoverable error occured while potentially everything is okay. Same goes for umount as a non-existing mountpoint is by definition not mounted. --- apt-pkg/contrib/cdromutl.cc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 176cc2024..f850e08a5 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -74,7 +74,13 @@ bool IsMounted(string &Path) leave /etc/mtab inconsitant. We drop all messages this produces. */ bool UnmountCdrom(string Path) { - if (IsMounted(Path) == false) + // do not generate errors, even if the mountpoint does not exist + // the mountpoint might be auto-created by the mount command + // and a non-existing mountpoint is surely not mounted + _error->PushToStack(); + bool const mounted = IsMounted(Path); + _error->RevertToStack(); + if (mounted == false) return true; for (int i=0;i<3;i++) @@ -86,8 +92,9 @@ bool UnmountCdrom(string Path) if (Child == 0) { // Make all the fds /dev/null - for (int I = 0; I != 3; I++) - dup2(open("/dev/null",O_RDWR),I); + int const null_fd = open("/dev/null",O_RDWR); + for (int I = 0; I != 3; ++I) + dup2(null_fd, I); if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true) { @@ -121,19 +128,24 @@ bool UnmountCdrom(string Path) /* We fork mount and drop all messages */ bool MountCdrom(string Path, string DeviceName) { - if (IsMounted(Path) == true) + // do not generate errors, even if the mountpoint does not exist + // the mountpoint might be auto-created by the mount command + _error->PushToStack(); + bool const mounted = IsMounted(Path); + _error->RevertToStack(); + if (mounted == true) return true; - + int Child = ExecFork(); // The child if (Child == 0) { // Make all the fds /dev/null - int null_fd = open("/dev/null",O_RDWR); - for (int I = 0; I != 3; I++) + int const null_fd = open("/dev/null",O_RDWR); + for (int I = 0; I != 3; ++I) dup2(null_fd, I); - + if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true) { if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0) -- cgit v1.2.3 From b374004b8ffebe393c5fd5e8056f7a99849c0ebd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 00:09:56 +0100 Subject: apt-cdrom ident shouldn't be interactive Commit 62dcbf84 changed the code of ident to look more like the code for add on my suggestion. This made ident interactive as it starts with a unmount, press enter, mount cycle. The first two are skipped now. This fixes d-i/apt-setup which is using it to get ID as well as label. Closes: 740673 --- apt-pkg/cdrom.cc | 27 +++++++++++++++------------ apt-pkg/cdrom.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 262ff9eab..dd6d51e97 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -563,7 +563,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) return true; } /*}}}*/ -bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log)/*{{{*/ +bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/ { // Startup CDROM = _config->FindDir("Acquire::cdrom::mount"); @@ -581,16 +581,19 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s // Unmount the CD and get the user to put in the one they want if (_config->FindB("APT::CDROM::NoMount", false) == false) { - if(log != NULL) - log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); - UnmountCdrom(CDROM); - - if(log != NULL) + if (interactive == true) { - log->Update(_("Waiting for disc...\n"), STEP_WAIT); - if(!log->ChangeCdrom()) { - // user aborted - return false; + if(log != NULL) + log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); + UnmountCdrom(CDROM); + + if(log != NULL) + { + log->Update(_("Waiting for disc...\n"), STEP_WAIT); + if(!log->ChangeCdrom()) { + // user aborted + return false; + } } } @@ -636,7 +639,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ { Configuration Database; std::string CDROM; - if (MountAndIdentCDROM(Database, CDROM, ident, log) == false) + if (MountAndIdentCDROM(Database, CDROM, ident, log, false) == false) return false; if (log != NULL) @@ -662,7 +665,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { Configuration Database; std::string ID, CDROM; - if (MountAndIdentCDROM(Database, CDROM, ID, log) == false) + if (MountAndIdentCDROM(Database, CDROM, ID, log, true) == false) return false; if(log != NULL) diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index f4a873808..0ed4a6a73 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -74,7 +74,7 @@ class pkgCdrom /*{{{*/ private: bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, - std::string &ident, pkgCdromStatus * const log); + std::string &ident, pkgCdromStatus * const log, bool const interactive); }; /*}}}*/ -- cgit v1.2.3 From 12844170ad33d96cb0c5fa411f4eb62fea6e3d5d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 01:49:37 +0100 Subject: support very long mtab entries in mountpoint discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Old code limited lines to 250 characters which is probably enough for everybody, but who knows… It also takes care of device nodes which start with the same prefix. --- apt-pkg/contrib/cdromutl.cc | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index f850e08a5..936e377fb 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -262,37 +263,34 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version) return true; } /*}}}*/ - // FindMountPointForDevice - Find mountpoint for the given device /*{{{*/ string FindMountPointForDevice(const char *devnode) { - char buf[255]; - char *out[10]; - int i=0; - // this is the order that mount uses as well - const char *mount[] = { "/etc/mtab", - "/proc/mount", - NULL }; + std::vector const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount"); - for (i=0; mount[i] != NULL; i++) { - if (FileExists(mount[i])) { - FILE *f=fopen(mount[i], "r"); - while ( fgets(buf, sizeof(buf), f) != NULL) { - if (strncmp(buf, devnode, strlen(devnode)) == 0) { - if(TokSplitString(' ', buf, out, 10)) - { - fclose(f); - // unescape the \0XXX chars in the path - string mount_point = out[1]; - return DeEscapeString(mount_point); - } - } - } - fclose(f); + for (std::vector::const_iterator m = mounts.begin(); m != mounts.end(); ++m) + if (FileExists(*m) == true) + { + char * line = NULL; + size_t line_len = 0; + FILE * f = fopen(m->c_str(), "r"); + while(getline(&line, &line_len, f) != -1) + { + char * out[] = { NULL, NULL, NULL }; + TokSplitString(' ', line, out, 3); + if (out[2] != NULL || out[1] == NULL || out[0] == NULL) + continue; + if (strcmp(out[0], devnode) != 0) + continue; + fclose(f); + // unescape the \0XXX chars in the path + string mount_point = out[1]; + return DeEscapeString(mount_point); + } + fclose(f); } - } - + return string(); } /*}}}*/ -- cgit v1.2.3 From 1166ea79889ecd6c88380f7988182647cf787f8f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 02:54:33 +0100 Subject: msgstr with elipses need three dots fixes some messages and their translation so that all of them have three dots for messages with an elipse. Many translations already had this. --- apt-pkg/cdrom.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index dd6d51e97..2635ede76 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -584,7 +584,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s if (interactive == true) { if(log != NULL) - log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); + log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); UnmountCdrom(CDROM); if(log != NULL) @@ -607,7 +607,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s // Hash the CD to get an ID if (log != NULL) - log->Update(_("Identifying.. "), STEP_IDENT); + log->Update(_("Identifying... "), STEP_IDENT); if (IdentCdrom(CDROM,ident) == false) { @@ -669,7 +669,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ return false; if(log != NULL) - log->Update(_("Scanning disc for index files..\n"),STEP_SCAN); + log->Update(_("Scanning disc for index files...\n"),STEP_SCAN); // Get the CD structure vector List; -- 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') 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 +++ apt-pkg/pkgcache.cc | 4 ++++ apt-pkg/pkgcachegen.cc | 14 ++++++++++---- apt-pkg/pkgcachegen.h | 9 +++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) (limited to 'apt-pkg') 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;}; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index a19b9571c..91b75f52e 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -55,7 +55,11 @@ pkgCache::Header::Header() /* Whenever the structures change the major version should be bumped, whenever the generator changes the minor version should be bumped. */ MajorVersion = 8; +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) + MinorVersion = 2; +#else MinorVersion = 1; +#endif Dirty = false; HeaderSz = sizeof(pkgCache::Header); diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 525f1dfb4..810f0b022 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -356,7 +356,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator map_ptrloc *LastVer = &Pkg->VersionList; void const * oldMap = Map.Data(); - unsigned long const Hash = List.VersionHash(); + unsigned short const Hash = List.VersionHash(); if (Ver.end() == false) { /* We know the list is sorted so we use that fact in the search. @@ -369,7 +369,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator if (Res > 0) break; // Versionstrings are equal - is hash also equal? - if (Res == 0 && Ver->Hash == Hash) + if (Res == 0 && List.SameVersion(Hash, Ver) == true) break; // proceed with the next till we have either the right // or we found another version (which will be lower) @@ -558,12 +558,12 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) if (Counter % 100 == 0 && Progress != 0) Progress->Progress(List.Offset()); - unsigned long Hash = List.VersionHash(); + unsigned short Hash = List.VersionHash(); pkgCache::VerIterator Ver = Pkg.VersionList(); Dynamic DynVer(Ver); for (; Ver.end() == false; ++Ver) { - if (Ver->Hash == Hash && Version == Ver.VerStr()) + if (List.SameVersion(Hash, Ver) == true && Version == Ver.VerStr()) { if (List.CollectFileProvides(Cache,Ver) == false) return _error->Error(_("Error occurred while processing %s (%s%d)"), @@ -1051,6 +1051,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver, return true; } /*}}}*/ +bool pkgCacheGenerator::ListParser::SameVersion(unsigned short const Hash,/*{{{*/ + pkgCache::VerIterator const &Ver) +{ + return Hash == Ver->Hash; +} + /*}}}*/ // CacheGenerator::SelectFile - Select the current file being parsed /*{{{*/ // --------------------------------------------------------------------- /* This is used to select which file is to be associated with all newly diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 898b34358..5994dab9f 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -164,6 +164,15 @@ class pkgCacheGenerator::ListParser virtual std::string DescriptionLanguage() = 0; virtual MD5SumValue Description_md5() = 0; virtual unsigned short VersionHash() = 0; + /** compare currently parsed version with given version + * + * \param Hash of the currently parsed version + * \param Ver to compare with + */ +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) + virtual +#endif + APT_PURE bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver); virtual bool UsePackage(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver) = 0; virtual unsigned long Offset() = 0; -- cgit v1.2.3 From 84baaae93badc2da7c1f4f356456762895cef278 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 31 May 2013 19:27:57 +0200 Subject: move fd duplication closer to the gz/bz2 open calls Git-Dch: Ignore --- apt-pkg/contrib/fileutl.cc | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 55ba41128..2188f616a 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1067,30 +1067,12 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration: { Close(); Flags = (AutoClose) ? FileFd::AutoClose : 0; - if (AutoClose == false && ( -#ifdef HAVE_ZLIB - compressor.Name == "gzip" || -#endif -#ifdef HAVE_BZ2 - compressor.Name == "bzip2" || -#endif - false)) - { - // Need to duplicate fd here or gzclose for cleanup will close the fd as well - iFd = dup(Fd); - } - else - iFd = Fd; + iFd = Fd; this->FileName = ""; - if (Fd == -1 || OpenInternDescriptor(Mode, compressor) == false) + if (OpenInternDescriptor(Mode, compressor) == false) { if (iFd != -1 && ( -#ifdef HAVE_ZLIB - compressor.Name == "gzip" || -#endif -#ifdef HAVE_BZ2 - compressor.Name == "bzip2" || -#endif + (Flags & Compressed) == Compressed || AutoClose == true)) { close (iFd); @@ -1102,6 +1084,8 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration: } bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor) { + if (iFd == -1) + return false; if (compressor.Name == "." || compressor.Binary.empty() == true) return true; @@ -1110,6 +1094,21 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C d = new FileFdPrivate(); d->openmode = Mode; d->compressor = compressor; + if (AutoClose == false && ( +#ifdef HAVE_ZLIB + compressor.Name == "gzip" || +#endif +#ifdef HAVE_BZ2 + compressor.Name == "bzip2" || +#endif + false)) + { + // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well + int const internFd = dup(iFd); + if (internFd == -1) + return FileFdErrno("OpenInternDescriptor", _("Could not open file descriptor %d"), iFd); + iFd = internFd; + } } #ifdef HAVE_ZLIB -- cgit v1.2.3 From 69d6988a1914881952c013cb63b4d835c3db0db7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 9 Jun 2013 14:32:48 +0200 Subject: refactor setup of file opening via zlib/bz2 lib Git-Dch: Ignore --- apt-pkg/contrib/fileutl.cc | 73 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2188f616a..057cb6a94 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1089,19 +1089,32 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C if (compressor.Name == "." || compressor.Binary.empty() == true) return true; +#if defined HAVE_ZLIB || defined HAVE_BZ2 + // the API to open files is similar, so setup to avoid code duplicates later + // and while at it ensure that we close before opening (if its a reopen) + void* (*compress_open)(int, const char *) = NULL; +#define APT_COMPRESS_INIT(NAME,OPEN,CLOSE,STRUCT) \ + if (compressor.Name == NAME) \ + { \ + compress_open = (void*(*)(int, const char *)) OPEN; \ + if (d != NULL && STRUCT != NULL) { CLOSE(STRUCT); STRUCT = NULL; } \ + } +#ifdef HAVE_ZLIB + APT_COMPRESS_INIT("gzip", gzdopen, gzclose, d->gz) +#endif +#ifdef HAVE_BZ2 + APT_COMPRESS_INIT("bzip2", BZ2_bzdopen, BZ2_bzclose, d->bz2) +#endif +#undef APT_COMPRESS_INIT +#endif + if (d == NULL) { d = new FileFdPrivate(); d->openmode = Mode; d->compressor = compressor; - if (AutoClose == false && ( -#ifdef HAVE_ZLIB - compressor.Name == "gzip" || -#endif -#ifdef HAVE_BZ2 - compressor.Name == "bzip2" || -#endif - false)) +#if defined HAVE_ZLIB || defined HAVE_BZ2 + if (AutoClose == false && compress_open != NULL) { // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well int const internFd = dup(iFd); @@ -1109,44 +1122,30 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C return FileFdErrno("OpenInternDescriptor", _("Could not open file descriptor %d"), iFd); iFd = internFd; } +#endif } -#ifdef HAVE_ZLIB - if (compressor.Name == "gzip") +#if defined HAVE_ZLIB || defined HAVE_BZ2 + if (compress_open != NULL) { - if (d->gz != NULL) - { - gzclose(d->gz); - d->gz = NULL; - } + void* compress_struct = NULL; if ((Mode & ReadWrite) == ReadWrite) - d->gz = gzdopen(iFd, "r+"); + compress_struct = compress_open(iFd, "r+"); else if ((Mode & WriteOnly) == WriteOnly) - d->gz = gzdopen(iFd, "w"); + compress_struct = compress_open(iFd, "w"); else - d->gz = gzdopen(iFd, "r"); - if (d->gz == NULL) + compress_struct = compress_open(iFd, "r"); + if (compress_struct == NULL) return false; - Flags |= Compressed; - return true; - } + +#ifdef HAVE_ZLIB + if (compressor.Name == "gzip") + d->gz = (gzFile) compress_struct; #endif #ifdef HAVE_BZ2 - if (compressor.Name == "bzip2") - { - if (d->bz2 != NULL) - { - BZ2_bzclose(d->bz2); - d->bz2 = NULL; - } - if ((Mode & ReadWrite) == ReadWrite) - d->bz2 = BZ2_bzdopen(iFd, "r+"); - else if ((Mode & WriteOnly) == WriteOnly) - d->bz2 = BZ2_bzdopen(iFd, "w"); - else - d->bz2 = BZ2_bzdopen(iFd, "r"); - if (d->bz2 == NULL) - return false; + if (compressor.Name == "bzip2") + d->bz2 = (BZFILE*) compress_struct; +#endif Flags |= Compressed; return true; } -- cgit v1.2.3 From 7f350a377e0c65a656b9b5437e27d037fd742901 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 14:39:18 +0100 Subject: use liblzma-dev to provide xz/lzma support We have xz/lzma support for a while, but only via an external binary provided by xz-utils. Now that the Debian archive provides xz by default and dpkg pre-depends on the library provided by liblzma-dev we can switch now to use this library as well to avoid requiring an external binary. For now the binary is in a prio:required package, but this might change in the future. API wise it is quiet similar to bz2 code expect that it doesn't provide file I/O methods, so we piece this together on our own. --- apt-pkg/aptconfiguration.cc | 8 ++ apt-pkg/contrib/fileutl.cc | 280 ++++++++++++++++++++++++++++++++++++++------ apt-pkg/makefile | 3 + 3 files changed, 256 insertions(+), 35 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 941a9c334..6ba047560 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -462,8 +462,16 @@ const Configuration::getCompressors(bool const Cached) { #endif if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true) compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4)); +#ifdef HAVE_LZMA + else + compressors.push_back(Compressor("xz",".xz","false", NULL, NULL, 4)); +#endif if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true) compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5)); +#ifdef HAVE_LZMA + else + compressors.push_back(Compressor("lzma",".lzma","false", NULL, NULL, 5)); +#endif std::vector const comp = _config->FindVector("APT::Compressor"); for (std::vector::const_iterator c = comp.begin(); diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 057cb6a94..22730ec04 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -58,6 +58,9 @@ #ifdef HAVE_BZ2 #include #endif +#ifdef HAVE_LZMA + #include +#endif #ifdef WORDS_BIGENDIAN #include @@ -72,13 +75,47 @@ class FileFdPrivate { public: #ifdef HAVE_ZLIB gzFile gz; -#else - void* gz; #endif #ifdef HAVE_BZ2 BZFILE* bz2; -#else - void* bz2; +#endif +#ifdef HAVE_LZMA + struct LZMAFILE { + FILE* file; + uint8_t buffer[4096]; + lzma_stream stream; + lzma_ret err; + bool eof; + bool compressing; + + LZMAFILE() : file(NULL), eof(false), compressing(false) {} + ~LZMAFILE() { + if (compressing == true) + { + for (;;) { + stream.avail_out = sizeof(buffer)/sizeof(buffer[0]); + stream.next_out = buffer; + err = lzma_code(&stream, LZMA_FINISH); + if (err != LZMA_OK && err != LZMA_STREAM_END) + { + _error->Error("~LZMAFILE: Compress finalisation failed"); + break; + } + size_t const n = sizeof(buffer)/sizeof(buffer[0]) - stream.avail_out; + if (n && fwrite(buffer, 1, n, file) != n) + { + _error->Errno("~LZMAFILE",_("Write error")); + break; + } + if (err == LZMA_STREAM_END) + break; + } + } + lzma_end(&stream); + fclose(file); + } + }; + LZMAFILE* lzma; #endif int compressed_fd; pid_t compressor_pid; @@ -86,7 +123,16 @@ class FileFdPrivate { APT::Configuration::Compressor compressor; unsigned int openmode; unsigned long long seekpos; - FileFdPrivate() : gz(NULL), bz2(NULL), + FileFdPrivate() : +#ifdef HAVE_ZLIB + gz(NULL), +#endif +#ifdef HAVE_BZ2 + bz2(NULL), +#endif +#ifdef HAVE_LZMA + lzma(NULL), +#endif compressed_fd(-1), compressor_pid(-1), pipe(false), openmode(0), seekpos(0) {}; bool CloseDown(std::string const &FileName) @@ -106,6 +152,12 @@ class FileFdPrivate { BZ2_bzclose(bz2); bz2 = NULL; } +#endif +#ifdef HAVE_LZMA + if (lzma != NULL) { + delete lzma; + lzma = NULL; + } #endif if (compressor_pid > 0) ExecWait(compressor_pid, "FileFdCompressor", true); @@ -1089,12 +1141,14 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C if (compressor.Name == "." || compressor.Binary.empty() == true) return true; -#if defined HAVE_ZLIB || defined HAVE_BZ2 +#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA // the API to open files is similar, so setup to avoid code duplicates later // and while at it ensure that we close before opening (if its a reopen) void* (*compress_open)(int, const char *) = NULL; + if (false) + /* dummy so that the rest can be 'else if's */; #define APT_COMPRESS_INIT(NAME,OPEN,CLOSE,STRUCT) \ - if (compressor.Name == NAME) \ + else if (compressor.Name == NAME) \ { \ compress_open = (void*(*)(int, const char *)) OPEN; \ if (d != NULL && STRUCT != NULL) { CLOSE(STRUCT); STRUCT = NULL; } \ @@ -1105,6 +1159,17 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C #ifdef HAVE_BZ2 APT_COMPRESS_INIT("bzip2", BZ2_bzdopen, BZ2_bzclose, d->bz2) #endif +#ifdef HAVE_LZMA + else if (compressor.Name == "xz" || compressor.Name == "lzma") + { + compress_open = (void*(*)(int, const char*)) fdopen; + if (d != NULL && d->lzma != NULL) + { + delete d->lzma; + d->lzma = NULL; + } + } +#endif #undef APT_COMPRESS_INIT #endif @@ -1113,7 +1178,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C d = new FileFdPrivate(); d->openmode = Mode; d->compressor = compressor; -#if defined HAVE_ZLIB || defined HAVE_BZ2 +#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA if (AutoClose == false && compress_open != NULL) { // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well @@ -1125,7 +1190,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C #endif } -#if defined HAVE_ZLIB || defined HAVE_BZ2 +#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA if (compress_open != NULL) { void* compress_struct = NULL; @@ -1138,13 +1203,60 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C if (compress_struct == NULL) return false; + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB - if (compressor.Name == "gzip") + else if (compressor.Name == "gzip") d->gz = (gzFile) compress_struct; #endif #ifdef HAVE_BZ2 - if (compressor.Name == "bzip2") + else if (compressor.Name == "bzip2") d->bz2 = (BZFILE*) compress_struct; +#endif +#ifdef HAVE_LZMA + else if (compressor.Name == "xz" || compressor.Name == "lzma") + { + uint32_t const xzlevel = 6; + uint64_t const memlimit = UINT64_MAX; + if (d->lzma == NULL) + d->lzma = new FileFdPrivate::LZMAFILE; + d->lzma->file = (FILE*) compress_struct; + d->lzma->stream = LZMA_STREAM_INIT; + + if ((Mode & ReadWrite) == ReadWrite) + return FileFdError("ReadWrite mode is not supported for file %s", FileName.c_str()); + + if ((Mode & WriteOnly) == WriteOnly) + { + if (compressor.Name == "xz") + { + if (lzma_easy_encoder(&d->lzma->stream, xzlevel, LZMA_CHECK_CRC32) != LZMA_OK) + return false; + } + else + { + lzma_options_lzma options; + lzma_lzma_preset(&options, xzlevel); + if (lzma_alone_encoder(&d->lzma->stream, &options) != LZMA_OK) + return false; + } + d->lzma->compressing = true; + } + else + { + if (compressor.Name == "xz") + { + if (lzma_auto_decoder(&d->lzma->stream, memlimit, 0) != LZMA_OK) + return false; + } + else + { + if (lzma_alone_decoder(&d->lzma->stream, memlimit) != LZMA_OK) + return false; + } + d->lzma->compressing = false; + } + } #endif Flags |= Compressed; return true; @@ -1202,7 +1314,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C } else { - if (FileName.empty() == true) + if (d->compressed_fd != -1) dup2(d->compressed_fd,STDIN_FILENO); dup2(Pipe[1],STDOUT_FILENO); } @@ -1271,24 +1383,55 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) *((char *)To) = '\0'; do { + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB - if (d != NULL && d->gz != NULL) + else if (d != NULL && d->gz != NULL) Res = gzread(d->gz,To,Size); - else #endif #ifdef HAVE_BZ2 - if (d != NULL && d->bz2 != NULL) + else if (d != NULL && d->bz2 != NULL) Res = BZ2_bzread(d->bz2,To,Size); - else #endif +#ifdef HAVE_LZMA + else if (d != NULL && d->lzma != NULL) + { + if (d->lzma->eof == true) + break; + + d->lzma->stream.next_out = (uint8_t *) To; + d->lzma->stream.avail_out = Size; + if (d->lzma->stream.avail_in == 0) + { + d->lzma->stream.next_in = d->lzma->buffer; + d->lzma->stream.avail_in = fread(d->lzma->buffer, 1, sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]), d->lzma->file); + } + d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN); + if (d->lzma->err == LZMA_STREAM_END) + { + d->lzma->eof = true; + Res = Size - d->lzma->stream.avail_out; + } + else if (d->lzma->err != LZMA_OK) + { + Res = -1; + errno = 0; + } + else + Res = Size - d->lzma->stream.avail_out; + } +#endif + else Res = read(iFd,To,Size); if (Res < 0) { if (errno == EINTR) continue; + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB - if (d != NULL && d->gz != NULL) + else if (d != NULL && d->gz != NULL) { int err; char const * const errmsg = gzerror(d->gz, &err); @@ -1297,13 +1440,17 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) } #endif #ifdef HAVE_BZ2 - if (d != NULL && d->bz2 != NULL) + else if (d != NULL && d->bz2 != NULL) { int err; char const * const errmsg = BZ2_bzerror(d->bz2, &err); if (err != BZ_IO_ERROR) return FileFdError("BZ2_bzread: %s (%d: %s)", _("Read error"), err, errmsg); } +#endif +#ifdef HAVE_LZMA + else if (d != NULL && d->lzma != NULL) + return FileFdError("lzma_read: %s (%d)", _("Read error"), d->lzma->err); #endif return FileFdErrno("read",_("Read error")); } @@ -1368,23 +1515,45 @@ bool FileFd::Write(const void *From,unsigned long long Size) errno = 0; do { + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB - if (d != NULL && d->gz != NULL) - Res = gzwrite(d->gz,From,Size); - else + else if (d != NULL && d->gz != NULL) + Res = gzwrite(d->gz,From,Size); #endif #ifdef HAVE_BZ2 - if (d != NULL && d->bz2 != NULL) - Res = BZ2_bzwrite(d->bz2,(void*)From,Size); - else + else if (d != NULL && d->bz2 != NULL) + Res = BZ2_bzwrite(d->bz2,(void*)From,Size); #endif - Res = write(iFd,From,Size); +#ifdef HAVE_LZMA + else if (d != NULL && d->lzma != NULL) + { + d->lzma->stream.next_in = (uint8_t *)From; + d->lzma->stream.avail_in = Size; + d->lzma->stream.next_out = d->lzma->buffer; + d->lzma->stream.avail_out = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]); + d->lzma->err = lzma_code(&d->lzma->stream, LZMA_RUN); + if (d->lzma->err != LZMA_OK) + return false; + size_t const n = sizeof(d->lzma->buffer)/sizeof(d->lzma->buffer[0]) - d->lzma->stream.avail_out; + size_t const m = (n == 0) ? 0 : fwrite(d->lzma->buffer, 1, n, d->lzma->file); + if (m != n) + Res = -1; + else + Res = Size - d->lzma->stream.avail_in; + } +#endif + else + Res = write(iFd,From,Size); + if (Res < 0 && errno == EINTR) continue; if (Res < 0) { + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB - if (d != NULL && d->gz != NULL) + else if (d != NULL && d->gz != NULL) { int err; char const * const errmsg = gzerror(d->gz, &err); @@ -1393,13 +1562,17 @@ bool FileFd::Write(const void *From,unsigned long long Size) } #endif #ifdef HAVE_BZ2 - if (d != NULL && d->bz2 != NULL) + else if (d != NULL && d->bz2 != NULL) { int err; char const * const errmsg = BZ2_bzerror(d->bz2, &err); if (err != BZ_IO_ERROR) return FileFdError("BZ2_bzwrite: %s (%d: %s)", _("Write error"), err, errmsg); } +#endif +#ifdef HAVE_LZMA + else if (d != NULL && d->lzma != NULL) + return FileFdErrno("lzma_fwrite", _("Write error")); #endif return FileFdErrno("write",_("Write error")); } @@ -1447,6 +1620,9 @@ bool FileFd::Seek(unsigned long long To) if (d != NULL && (d->pipe == true #ifdef HAVE_BZ2 || d->bz2 != NULL +#endif +#ifdef HAVE_LZMA + || d->lzma != NULL #endif )) { @@ -1459,12 +1635,21 @@ bool FileFd::Seek(unsigned long long To) if ((d->openmode & ReadOnly) != ReadOnly) return FileFdError("Reopen is only implemented for read-only files!"); + if (false) + /* dummy so that the rest can be 'else if's */; #ifdef HAVE_BZ2 - if (d->bz2 != NULL) - { - BZ2_bzclose(d->bz2); - d->bz2 = NULL; - } + else if (d->bz2 != NULL) + { + BZ2_bzclose(d->bz2); + d->bz2 = NULL; + } +#endif +#ifdef HAVE_LZMA + else if (d->lzma != NULL) + { + delete d->lzma; + d->lzma = NULL; + } #endif if (iFd != -1) close(iFd); @@ -1514,6 +1699,9 @@ bool FileFd::Skip(unsigned long long Over) if (d != NULL && (d->pipe == true #ifdef HAVE_BZ2 || d->bz2 != NULL +#endif +#ifdef HAVE_LZMA + || d->lzma != NULL #endif )) { @@ -1552,8 +1740,18 @@ bool FileFd::Truncate(unsigned long long To) // truncating /dev/null is always successful - as we get an error otherwise if (To == 0 && FileName == "/dev/null") return true; -#if defined HAVE_ZLIB || defined HAVE_BZ2 - if (d != NULL && (d->gz != NULL || d->bz2 != NULL)) +#if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA + if (d != NULL && ( +#ifdef HAVE_ZLIB + d->gz != NULL || +#endif +#ifdef HAVE_BZ2 + d->bz2 != NULL || +#endif +#ifdef HAVE_LZMA + d->lzma != NULL || +#endif + false)) return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str()); #endif if (ftruncate(iFd,To) != 0) @@ -1574,6 +1772,9 @@ unsigned long long FileFd::Tell() if (d != NULL && (d->pipe == true #ifdef HAVE_BZ2 || d->bz2 != NULL +#endif +#ifdef HAVE_LZMA + || d->lzma != NULL #endif )) return d->seekpos; @@ -1653,6 +1854,9 @@ unsigned long long FileFd::Size() if (d != NULL && (d->pipe == true #ifdef HAVE_BZ2 || (d->bz2 && size > 0) +#endif +#ifdef HAVE_LZMA + || (d->lzma && size > 0) #endif )) { @@ -1797,7 +2001,13 @@ bool FileFd::FileFdError(const char *Description,...) { } /*}}}*/ -gzFile FileFd::gzFd() { return d->gz; } +APT_DEPRECATED gzFile FileFd::gzFd() { +#ifdef HAVE_ZLIB + return d->gz; +#else + return NULL; +#endif +} // Glob - wrapper around "glob()" /*{{{*/ diff --git a/apt-pkg/makefile b/apt-pkg/makefile index a90131f80..1d456873b 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -21,6 +21,9 @@ endif ifeq ($(HAVE_BZ2),yes) SLIBS+= -lbz2 endif +ifeq ($(HAVE_LZMA),yes) +SLIBS+= -llzma +endif APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR) # Source code for the contributed non-core things -- cgit v1.2.3 From 4239dbca053512b6f8357ed143c24c50685b890f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 16:16:14 +0100 Subject: refactor FileFd to hide some #ifdefs They tend to be ugly to look at, so hide them. Git-Dch: Ignore --- apt-pkg/contrib/fileutl.cc | 299 ++++++++++++++++++++------------------------- 1 file changed, 131 insertions(+), 168 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 22730ec04..26945c183 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1,6 +1,5 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.cc,v 1.42 2002/09/14 05:29:22 jgg Exp $ /* ###################################################################### File Utilities @@ -59,6 +58,7 @@ #include #endif #ifdef HAVE_LZMA + #include #include #endif @@ -71,103 +71,6 @@ using namespace std; -class FileFdPrivate { - public: -#ifdef HAVE_ZLIB - gzFile gz; -#endif -#ifdef HAVE_BZ2 - BZFILE* bz2; -#endif -#ifdef HAVE_LZMA - struct LZMAFILE { - FILE* file; - uint8_t buffer[4096]; - lzma_stream stream; - lzma_ret err; - bool eof; - bool compressing; - - LZMAFILE() : file(NULL), eof(false), compressing(false) {} - ~LZMAFILE() { - if (compressing == true) - { - for (;;) { - stream.avail_out = sizeof(buffer)/sizeof(buffer[0]); - stream.next_out = buffer; - err = lzma_code(&stream, LZMA_FINISH); - if (err != LZMA_OK && err != LZMA_STREAM_END) - { - _error->Error("~LZMAFILE: Compress finalisation failed"); - break; - } - size_t const n = sizeof(buffer)/sizeof(buffer[0]) - stream.avail_out; - if (n && fwrite(buffer, 1, n, file) != n) - { - _error->Errno("~LZMAFILE",_("Write error")); - break; - } - if (err == LZMA_STREAM_END) - break; - } - } - lzma_end(&stream); - fclose(file); - } - }; - LZMAFILE* lzma; -#endif - int compressed_fd; - pid_t compressor_pid; - bool pipe; - APT::Configuration::Compressor compressor; - unsigned int openmode; - unsigned long long seekpos; - FileFdPrivate() : -#ifdef HAVE_ZLIB - gz(NULL), -#endif -#ifdef HAVE_BZ2 - bz2(NULL), -#endif -#ifdef HAVE_LZMA - lzma(NULL), -#endif - compressed_fd(-1), compressor_pid(-1), pipe(false), - openmode(0), seekpos(0) {}; - bool CloseDown(std::string const &FileName) - { - bool Res = true; -#ifdef HAVE_ZLIB - if (gz != NULL) { - int const e = gzclose(gz); - gz = NULL; - // gzdclose() on empty files always fails with "buffer error" here, ignore that - if (e != 0 && e != Z_BUF_ERROR) - Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str()); - } -#endif -#ifdef HAVE_BZ2 - if (bz2 != NULL) { - BZ2_bzclose(bz2); - bz2 = NULL; - } -#endif -#ifdef HAVE_LZMA - if (lzma != NULL) { - delete lzma; - lzma = NULL; - } -#endif - if (compressor_pid > 0) - ExecWait(compressor_pid, "FileFdCompressor", true); - compressor_pid = -1; - - return Res; - } - ~FileFdPrivate() { CloseDown(""); } -}; - // RunScripts - Run a set of scripts from a configuration subtree /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -932,6 +835,122 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap) } /*}}}*/ +class FileFdPrivate { /*{{{*/ + public: +#ifdef HAVE_ZLIB + gzFile gz; +#endif +#ifdef HAVE_BZ2 + BZFILE* bz2; +#endif +#ifdef HAVE_LZMA + struct LZMAFILE { + FILE* file; + uint8_t buffer[4096]; + lzma_stream stream; + lzma_ret err; + bool eof; + bool compressing; + + LZMAFILE() : file(NULL), eof(false), compressing(false) {} + ~LZMAFILE() { + if (compressing == true) + { + for (;;) { + stream.avail_out = sizeof(buffer)/sizeof(buffer[0]); + stream.next_out = buffer; + err = lzma_code(&stream, LZMA_FINISH); + if (err != LZMA_OK && err != LZMA_STREAM_END) + { + _error->Error("~LZMAFILE: Compress finalisation failed"); + break; + } + size_t const n = sizeof(buffer)/sizeof(buffer[0]) - stream.avail_out; + if (n && fwrite(buffer, 1, n, file) != n) + { + _error->Errno("~LZMAFILE",_("Write error")); + break; + } + if (err == LZMA_STREAM_END) + break; + } + } + lzma_end(&stream); + fclose(file); + } + }; + LZMAFILE* lzma; +#endif + int compressed_fd; + pid_t compressor_pid; + bool pipe; + APT::Configuration::Compressor compressor; + unsigned int openmode; + unsigned long long seekpos; + FileFdPrivate() : +#ifdef HAVE_ZLIB + gz(NULL), +#endif +#ifdef HAVE_BZ2 + bz2(NULL), +#endif +#ifdef HAVE_LZMA + lzma(NULL), +#endif + compressed_fd(-1), compressor_pid(-1), pipe(false), + openmode(0), seekpos(0) {}; + bool InternalClose(std::string const &FileName) + { + if (false) + /* dummy so that the rest can be 'else if's */; +#ifdef HAVE_ZLIB + else if (gz != NULL) { + int const e = gzclose(gz); + gz = NULL; + // gzdclose() on empty files always fails with "buffer error" here, ignore that + if (e != 0 && e != Z_BUF_ERROR) + return _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str()); + } +#endif +#ifdef HAVE_BZ2 + else if (bz2 != NULL) { + BZ2_bzclose(bz2); + bz2 = NULL; + } +#endif +#ifdef HAVE_LZMA + else if (lzma != NULL) { + delete lzma; + lzma = NULL; + } +#endif + return true; + } + bool CloseDown(std::string const &FileName) + { + bool const Res = InternalClose(FileName); + + if (compressor_pid > 0) + ExecWait(compressor_pid, "FileFdCompressor", true); + compressor_pid = -1; + + return Res; + } + bool InternalStream() const { + return false +#ifdef HAVE_BZ2 + || bz2 != NULL +#endif +#ifdef HAVE_LZMA + || lzma != NULL +#endif + ; + } + + + ~FileFdPrivate() { CloseDown(""); } +}; + /*}}}*/ // FileFd::Open - Open a file /*{{{*/ // --------------------------------------------------------------------- /* The most commonly used open mode combinations are given with Mode */ @@ -1147,28 +1166,21 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C void* (*compress_open)(int, const char *) = NULL; if (false) /* dummy so that the rest can be 'else if's */; -#define APT_COMPRESS_INIT(NAME,OPEN,CLOSE,STRUCT) \ +#define APT_COMPRESS_INIT(NAME,OPEN) \ else if (compressor.Name == NAME) \ { \ compress_open = (void*(*)(int, const char *)) OPEN; \ - if (d != NULL && STRUCT != NULL) { CLOSE(STRUCT); STRUCT = NULL; } \ + if (d != NULL) d->InternalClose(FileName); \ } #ifdef HAVE_ZLIB - APT_COMPRESS_INIT("gzip", gzdopen, gzclose, d->gz) + APT_COMPRESS_INIT("gzip", gzdopen) #endif #ifdef HAVE_BZ2 - APT_COMPRESS_INIT("bzip2", BZ2_bzdopen, BZ2_bzclose, d->bz2) + APT_COMPRESS_INIT("bzip2", BZ2_bzdopen) #endif #ifdef HAVE_LZMA - else if (compressor.Name == "xz" || compressor.Name == "lzma") - { - compress_open = (void*(*)(int, const char*)) fdopen; - if (d != NULL && d->lzma != NULL) - { - delete d->lzma; - d->lzma = NULL; - } - } + APT_COMPRESS_INIT("xz", fdopen) + APT_COMPRESS_INIT("lzma", fdopen) #endif #undef APT_COMPRESS_INIT #endif @@ -1617,14 +1629,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size) /* */ bool FileFd::Seek(unsigned long long To) { - if (d != NULL && (d->pipe == true -#ifdef HAVE_BZ2 - || d->bz2 != NULL -#endif -#ifdef HAVE_LZMA - || d->lzma != NULL -#endif - )) + if (d != NULL && (d->pipe == true || d->InternalStream() == true)) { // Our poor man seeking in pipes is costly, so try to avoid it unsigned long long seekpos = Tell(); @@ -1635,22 +1640,7 @@ bool FileFd::Seek(unsigned long long To) if ((d->openmode & ReadOnly) != ReadOnly) return FileFdError("Reopen is only implemented for read-only files!"); - if (false) - /* dummy so that the rest can be 'else if's */; -#ifdef HAVE_BZ2 - else if (d->bz2 != NULL) - { - BZ2_bzclose(d->bz2); - d->bz2 = NULL; - } -#endif -#ifdef HAVE_LZMA - else if (d->lzma != NULL) - { - delete d->lzma; - d->lzma = NULL; - } -#endif + d->InternalClose(FileName); if (iFd != -1) close(iFd); iFd = -1; @@ -1696,14 +1686,7 @@ bool FileFd::Seek(unsigned long long To) /* */ bool FileFd::Skip(unsigned long long Over) { - if (d != NULL && (d->pipe == true -#ifdef HAVE_BZ2 - || d->bz2 != NULL -#endif -#ifdef HAVE_LZMA - || d->lzma != NULL -#endif - )) + if (d != NULL && (d->pipe == true || d->InternalStream() == true)) { d->seekpos += Over; char buffer[1024]; @@ -1741,17 +1724,11 @@ bool FileFd::Truncate(unsigned long long To) if (To == 0 && FileName == "/dev/null") return true; #if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA - if (d != NULL && ( + if (d != NULL && (d->InternalStream() == true #ifdef HAVE_ZLIB - d->gz != NULL || -#endif -#ifdef HAVE_BZ2 - d->bz2 != NULL || + || d->gz != NULL #endif -#ifdef HAVE_LZMA - d->lzma != NULL || -#endif - false)) + )) return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str()); #endif if (ftruncate(iFd,To) != 0) @@ -1769,14 +1746,7 @@ unsigned long long FileFd::Tell() // seeking around, but not all users of FileFd use always Seek() and co // so d->seekpos isn't always true and we can just use it as a hint if // we have nothing else, but not always as an authority… - if (d != NULL && (d->pipe == true -#ifdef HAVE_BZ2 - || d->bz2 != NULL -#endif -#ifdef HAVE_LZMA - || d->lzma != NULL -#endif - )) + if (d != NULL && (d->pipe == true || d->InternalStream() == true)) return d->seekpos; off_t Res; @@ -1851,14 +1821,7 @@ unsigned long long FileFd::Size() // for compressor pipes st_size is undefined and at 'best' zero, // so we 'read' the content and 'seek' back - see there - if (d != NULL && (d->pipe == true -#ifdef HAVE_BZ2 - || (d->bz2 && size > 0) -#endif -#ifdef HAVE_LZMA - || (d->lzma && size > 0) -#endif - )) + if (d != NULL && (d->pipe == true || (d->InternalStream() == true && size > 0))) { unsigned long long const oldSeek = Tell(); char ignore[1000]; -- cgit v1.2.3 From 40f8a8ba8c2e7ff9ce80781250c863c07ac130dd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 13 Mar 2014 01:27:34 +0100 Subject: use the pretty fullname of a pkg as download desciption Otherwise the "WARNING: The following packages cannot be authenticated!" messages does not include the architecture of the package, so it would be slightly misinformative. --- apt-pkg/acquire-item.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ad38e3116..30743addf 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1865,7 +1865,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, _error->Error(_("I wasn't able to locate a file for the %s package. " "This might mean you need to manually fix this package. " "(due to missing arch)"), - Version.ParentPkg().Name()); + Version.ParentPkg().FullName().c_str()); return; } @@ -1993,7 +1993,7 @@ bool pkgAcqArchive::QueueNext() Desc.URI = Index->ArchiveURI(PkgFile); Desc.Description = Index->ArchiveInfo(Version); Desc.Owner = this; - Desc.ShortDesc = Version.ParentPkg().Name(); + Desc.ShortDesc = Version.ParentPkg().FullName(true); // See if we already have the file. (Legacy filenames) FileSize = Version->Size; @@ -2060,10 +2060,6 @@ bool pkgAcqArchive::QueueNext() // Create the item Local = false; - Desc.URI = Index->ArchiveURI(PkgFile); - Desc.Description = Index->ArchiveInfo(Version); - Desc.Owner = this; - Desc.ShortDesc = Version.ParentPkg().Name(); QueueURI(Desc); ++Vf; -- cgit v1.2.3 From f6ffe501d432d1299808ae307936877cf2c5f8ce Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 15 Mar 2014 17:59:47 +0100 Subject: Fix handling of autoclosing for compressed files (Closes: #741685) AutoClose is both an argument in OpenDescriptor() and an enum. In commit 84baaae93badc2da7c1f4f356456762895cef278 code using the AutoClose parameter was moved to OpenDescriptorInternal(). In that function, AutoClose meant the enum value, so the check was always false. --- apt-pkg/contrib/fileutl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 1eabf37f4..ba79720d8 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1191,7 +1191,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C d->openmode = Mode; d->compressor = compressor; #if defined HAVE_ZLIB || defined HAVE_BZ2 || defined HAVE_LZMA - if (AutoClose == false && compress_open != NULL) + if ((Flags & AutoClose) != AutoClose && compress_open != NULL) { // Need to duplicate fd here or gz/bz2 close for cleanup will close the fd as well int const internFd = dup(iFd); -- cgit v1.2.3 From c4b113e650dbdbb4c5c9c6f36437c94db6b214d9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 11:04:26 +0100 Subject: continue reading in xz even if it outputs nothing It can happen that content in our buffer is not enough to produce a meaningful output in which case no output is created by liblzma, but still reports that everything is okay and we should go on. The code assumes it has reached the end through if it encounters a null read, so this commit makes it so that it looks like this read was interrupted just like the lowlevel read() on uncompressed files could. It subsequently fixes the issue with that as well as until now our loop would still break even if we wanted it to continue on. (This bug triggers our usual "Hash sum mismatch" error) Reported-By: Stefan Lippers-Hollmann --- apt-pkg/contrib/fileutl.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index ba79720d8..69406a9bf 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1430,7 +1430,15 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) errno = 0; } else + { Res = Size - d->lzma->stream.avail_out; + if (Res == 0) + { + // lzma run was okay, but produced no output… + Res = -1; + errno = EINTR; + } + } } #endif else @@ -1439,7 +1447,12 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) if (Res < 0) { if (errno == EINTR) + { + // trick the while-loop into running again + Res = 1; + errno = 0; continue; + } if (false) /* dummy so that the rest can be 'else if's */; #ifdef HAVE_ZLIB -- cgit v1.2.3 From 63ff42089863cda53aee240ea0124106e8b4d983 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 15:54:15 +0100 Subject: enable fvisibility=hidden for our private library While it is a huge undertaking to enable it for our public libraries as basically everything we exported so far could be seen as public interface our private library is new and under our full control, so we can do whatever we like with it. The benefits are not that big in return of course, but it reduces the size a bit, so thats great nontheless. Git-Dch: ignore --- apt-pkg/contrib/macros.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index d97053553..2d6448e5e 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -94,8 +94,12 @@ #if APT_GCC_VERSION >= 0x0400 #define APT_SENTINEL __attribute__((sentinel)) + #define APT_PUBLIC __attribute__ ((visibility ("default"))) + #define APT_HIDDEN __attribute__ ((visibility ("hidden"))) #else #define APT_SENTINEL + #define APT_PUBLIC + #define APT_HIDDEN #endif // cold functions are unlikely() to be called -- 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/acquire-method.h | 4 +++- apt-pkg/cdrom.h | 4 +++- apt-pkg/contrib/fileutl.h | 6 +++--- apt-pkg/deb/deblistparser.h | 3 ++- apt-pkg/edsp.h | 11 ++++++----- apt-pkg/pkgcachegen.h | 18 +++++++++--------- apt-pkg/tagfile.h | 8 +++++--- 7 files changed, 31 insertions(+), 23 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index f0f2a537a..221ccf273 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -20,6 +20,8 @@ #ifndef PKGLIB_ACQUIRE_METHOD_H #define PKGLIB_ACQUIRE_METHOD_H +#include + #include #include @@ -107,7 +109,7 @@ class pkgAcqMethod virtual ~pkgAcqMethod() {}; private: - void Dequeue(); + APT_HIDDEN void Dequeue(); }; /** @} */ diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 0ed4a6a73..0f2c2cd02 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -1,6 +1,8 @@ #ifndef PKGLIB_CDROM_H #define PKGLIB_CDROM_H +#include + #include #include @@ -73,7 +75,7 @@ class pkgCdrom /*{{{*/ bool Add(pkgCdromStatus *log); private: - bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, + APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive); }; /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 278a25742..f25ed3622 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -150,11 +150,11 @@ class FileFd private: FileFdPrivate* d; - bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); + APT_HIDDEN bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor); // private helpers to set Fail flag and call _error->Error - bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; - bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; + APT_HIDDEN bool FileFdErrno(const char* Function, const char* Description,...) APT_PRINTF(3) APT_COLD; + APT_HIDDEN bool FileFdError(const char* Description,...) APT_PRINTF(2) APT_COLD; }; bool RunScripts(const char *Cnf); 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 diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index ae20ed7db..f3092d3c6 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -32,15 +33,15 @@ class EDSP /*{{{*/ static const char * const PrioMap[]; static const char * const DepMap[]; - bool static ReadLine(int const input, std::string &line); - bool static StringToBool(char const *answer, bool const defValue); + APT_HIDDEN bool static ReadLine(int const input, std::string &line); + APT_HIDDEN bool static StringToBool(char const *answer, bool const defValue); - void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, + APT_HIDDEN void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver); - void static WriteScenarioDependency(FILE* output, + APT_HIDDEN void static WriteScenarioDependency(FILE* output, pkgCache::VerIterator const &Ver); - void static WriteScenarioLimitedDependency(FILE* output, + APT_HIDDEN void static WriteScenarioLimitedDependency(FILE* output, pkgCache::VerIterator const &Ver, APT::PackageSet const &pkgset); public: diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 5994dab9f..1e1a71026 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -38,10 +38,10 @@ class pkgCacheGenerator /*{{{*/ private: pkgCache::StringItem *UniqHash[26]; - map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); }; - map_ptrloc WriteStringInMap(const char *String); - map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len); - map_ptrloc AllocateInMap(const unsigned long &size); + APT_HIDDEN map_ptrloc WriteStringInMap(std::string const &String) { return WriteStringInMap(String.c_str()); }; + APT_HIDDEN map_ptrloc WriteStringInMap(const char *String); + APT_HIDDEN map_ptrloc WriteStringInMap(const char *String, const unsigned long &Len); + APT_HIDDEN map_ptrloc AllocateInMap(const unsigned long &size); public: @@ -117,14 +117,14 @@ class pkgCacheGenerator /*{{{*/ ~pkgCacheGenerator(); private: - bool MergeListGroup(ListParser &List, std::string const &GrpName); - bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); - bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, + APT_HIDDEN bool MergeListGroup(ListParser &List, std::string const &GrpName); + APT_HIDDEN bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); + APT_HIDDEN bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, std::string const &Version, pkgCache::VerIterator* &OutVer); - bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P, + APT_HIDDEN bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P, pkgCache::VerIterator &V); - bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D); + APT_HIDDEN bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D); }; /*}}}*/ // This is the abstract package list parser class. /*{{{*/ diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 2f600d397..d5b62e76d 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -20,6 +20,8 @@ #ifndef PKGLIB_TAGFILE_H #define PKGLIB_TAGFILE_H +#include + #include #include @@ -93,9 +95,9 @@ class pkgTagFile { pkgTagFilePrivate *d; - bool Fill(); - bool Resize(); - bool Resize(unsigned long long const newSize); + APT_HIDDEN bool Fill(); + APT_HIDDEN bool Resize(); + APT_HIDDEN bool Resize(unsigned long long const newSize); public: -- 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') 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 be7ce6f1d067fa62b01685e48094f3f73c95189f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Mar 2014 15:32:40 +0100 Subject: do IsInstallOk call in MarkInstall unconditionally Hooked checks could be influenced by AutoInst as a lot can happen between a call without and one with this bit set. The real cache-hit check is above this call already. Individual hooked checks can then inspect the state if they want to cache. Calling them multiple times shouldn't be a problem either way. --- apt-pkg/depcache.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index e2c412757..5fa88a5d2 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1059,10 +1059,9 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, return true; } - // check if we are allowed to install the package (if we haven't already) - if (P.Mode != ModeInstall || P.InstallVer != P.CandidateVer) - if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false) - return false; + // check if we are allowed to install the package + if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false) + return false; ActionGroup group(*this); P.iFlags &= ~AutoKept; @@ -1308,6 +1307,11 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, if (FromUser == true) // as always: user is always right return true; + // if we have checked before and it was okay, it will still be okay + if (PkgState[Pkg->ID].Mode == ModeInstall && + PkgState[Pkg->ID].InstallVer == PkgState[Pkg->ID].CandidateVer) + return true; + // ignore packages with none-M-A:same candidates VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this); if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer() || -- cgit v1.2.3 From 21b3eac8f9ab8e12b43fa8998a5aa5465f29adc5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Mar 2014 10:31:44 +0100 Subject: discard candidates via IsInstallOk to allow override In commit 446551c8 I changed MarkInstall to discard the candidate if the candidate can't satisfy the dependency. This breaks interactive solvers like aptitude which can change the candidate on-the-fly later. In commit df77d8a5 I introduced this 'early' loop-breaking to begin with which can't be that helpful for interactive solvers as well, but makes perfect sense for non-interactives to stop them from exploring trees which can't be satisfied, but it isn't perfect as ideally we would check this before auto-installing the first dependency. This commit therefore moves the loop into its own IsInstallOk hook so that frontends can override this check if they want to and in exchange removes the loop-breaking from MarkInstall itself and does it before any dependency is installed. Closes: 740750 --- apt-pkg/depcache.cc | 78 +++++++++++++++++++++++++++++++++++++++-------------- apt-pkg/depcache.h | 2 ++ 2 files changed, 60 insertions(+), 20 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 5fa88a5d2..19a6e0d7e 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1122,32 +1122,22 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, continue; /* Check if this dep should be consider for install. If it is a user - defined important dep and we are installed a new package then + defined important dep and we are installed a new package then it will be installed. Otherwise we only check for important - deps that have changed from the installed version - */ + deps that have changed from the installed version */ if (IsImportantDep(Start) == false) continue; - /* If we are in an or group locate the first or that can - succeed. We have already cached this.. */ + /* If we are in an or group locate the first or that can + succeed. We have already cached this… */ for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors) ++Start; + + /* unsatisfiable dependency: IsInstallOkDependenciesSatisfiableByCandidates + would have prevented us to get here if not overridden, so just skip + over the problem here as the frontend will know what it is doing */ if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer && Start.IsNegative() == false) - { - if(DebugAutoInstall == true) - std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl; - if (Start.IsCritical() == false) - continue; - // if the dependency was critical, we have absolutely no chance to install it, - // so if it wasn't installed remove it again. If it was, discard the candidate - // as the problemresolver will trip over it otherwise trying to install it (#735967) - if (Pkg->CurrentVer == 0) - MarkDelete(Pkg,false,Depth + 1, false); - else - SetCandidateVersion(Pkg.CurrentVer()); - return false; - } + continue; /* Check if any ImportantDep() (but not Critical) were added * since we installed the package. Also check for deps that @@ -1299,7 +1289,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst, unsigned long Depth, bool FromUser) { - return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser); + return IsInstallOkMultiArchSameVersionSynced(Pkg,AutoInst, Depth, FromUser) && + IsInstallOkDependenciesSatisfiableByCandidates(Pkg,AutoInst, Depth, FromUser); } bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, bool const /*AutoInst*/, unsigned long const Depth, bool const FromUser) @@ -1342,6 +1333,53 @@ bool pkgDepCache::IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, return false; } + return true; +} +bool pkgDepCache::IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg, + bool const AutoInst, unsigned long const Depth, bool const /*FromUser*/) +{ + if (AutoInst == false) + return true; + + VerIterator const CandVer = PkgState[Pkg->ID].CandidateVerIter(*this); + if (unlikely(CandVer.end() == true) || CandVer == Pkg.CurrentVer()) + return true; + + for (DepIterator Dep = CandVer.DependsList(); Dep.end() != true;) + { + // Grok or groups + DepIterator Start = Dep; + bool Result = true; + unsigned Ors = 0; + for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors) + { + LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or; + + if ((DepState[Dep->ID] & DepInstall) == DepInstall) + Result = false; + } + + if (Start.IsCritical() == false || Start.IsNegative() == true || Result == false) + continue; + + /* If we are in an or group locate the first or that can succeed. + We have already cached this… */ + for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors) + ++Start; + + if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer) + { + if (DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl; + + // the dependency is critical, but can't be installed, so discard the candidate + // as the problemresolver will trip over it otherwise trying to install it (#735967) + if (Pkg->CurrentVer != 0) + SetCandidateVersion(Pkg.CurrentVer()); + return false; + } + } + return true; } /*}}}*/ diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index bde648c65..bec651279 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -506,6 +506,8 @@ class pkgDepCache : protected pkgCache::Namespace // methods call by IsInstallOk bool IsInstallOkMultiArchSameVersionSynced(PkgIterator const &Pkg, bool const AutoInst, unsigned long const Depth, bool const FromUser); + bool IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator const &Pkg, + bool const AutoInst, unsigned long const Depth, bool const FromUser); // methods call by IsDeleteOk bool IsDeleteOkProtectInstallRequests(PkgIterator const &Pkg, -- cgit v1.2.3 From c34d1202e991a6f0ab5bed82c2e1ca0d155038b1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Mar 2014 06:48:57 +0100 Subject: make fancy-progress fg/bg color configurable Add two new options: Dpkg::Progress-Fancy::Progress-{fg,bg} that allows customizing the colors in the dpkg fancy progress output. --- apt-pkg/install-progress.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index dfe4fb18c..96334b006 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -338,8 +338,12 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, static std::string save_cursor = "\033[s"; static std::string restore_cursor = "\033[u"; - static std::string set_bg_color = "\033[42m"; // green - static std::string set_fg_color = "\033[30m"; // black + // green + static std::string set_bg_color = DeQuoteString( + _config->Find("Dpkg::Progress-Fancy::Progress-fg", "%1b[42m")); + // black + static std::string set_fg_color = DeQuoteString( + _config->Find("Dpkg::Progress-Fancy::Progress-bg", "%1b[30m")); static std::string restore_bg = "\033[49m"; static std::string restore_fg = "\033[39m"; -- cgit v1.2.3 From fa211e2d3b0305cfdd184cdba9750259f6d9c98e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Mar 2014 07:56:42 +0100 Subject: Add progressbar to "Dpkg::Progress-Fancy" A text progressbar is now displayed in the Dpkg::Progress-Fancy mode. It can be turned off via the apt option Dpkg::Progress-Fancy::Progress-Bar=false --- apt-pkg/install-progress.cc | 63 +++++++++++++++++++++++++++++++++++++-------- apt-pkg/install-progress.h | 11 +++++++- 2 files changed, 62 insertions(+), 12 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 96334b006..8bb587f67 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -252,17 +252,22 @@ void PackageManagerFancy::staticSIGWINCH(int signum) (*I)->HandleSIGWINCH(signum); } -int PackageManagerFancy::GetNumberTerminalRows() +PackageManagerFancy::TermSize +PackageManagerFancy::GetTerminalSize() { struct winsize win; + PackageManagerFancy::TermSize s; + // FIXME: get from "child_pty" instead? if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0) - return -1; + return s; if(_config->FindB("Debug::InstallProgress::Fancy", false) == true) - std::cerr << "GetNumberTerminalRows: " << win.ws_row << std::endl; - - return win.ws_row; + std::cerr << "GetTerminalSize: " << win.ws_row << std::endl; + + s.rows = win.ws_row; + s.columns = win.ws_col; + return s; } void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) @@ -298,21 +303,21 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) void PackageManagerFancy::HandleSIGWINCH(int) { - int nr_terminal_rows = GetNumberTerminalRows(); + int nr_terminal_rows = GetTerminalSize().rows; SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Start(int a_child_pty) { child_pty = a_child_pty; - int nr_terminal_rows = GetNumberTerminalRows(); + int nr_terminal_rows = GetTerminalSize().rows; if (nr_terminal_rows > 0) SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Stop() { - int nr_terminal_rows = GetNumberTerminalRows(); + int nr_terminal_rows = GetTerminalSize().rows; if (nr_terminal_rows > 0) { SetupTerminalScrollArea(nr_terminal_rows + 1); @@ -324,6 +329,26 @@ void PackageManagerFancy::Stop() child_pty = -1; } +std::string +PackageManagerFancy::GetTextProgressStr(float Percent, int OutputSize) +{ + std::string output; + int i; + + // should we raise a exception here instead? + if (Percent < 0.0 || Percent > 1.0 || OutputSize < 3) + return output; + + int BarSize = OutputSize - 2; // bar without the leading "[" and trailing "]" + output += "["; + for(i=0; i < BarSize*Percent; i++) + output += "#"; + for (/*nothing*/; i < BarSize; i++) + output += "."; + output += "]"; + return output; +} + bool PackageManagerFancy::StatusChanged(std::string PackageName, unsigned int StepsDone, unsigned int TotalSteps, @@ -333,7 +358,7 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, HumanReadableAction)) return false; - int row = GetNumberTerminalRows(); + PackageManagerFancy::TermSize size = GetTerminalSize(); static std::string save_cursor = "\033[s"; static std::string restore_cursor = "\033[u"; @@ -350,14 +375,30 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, std::cout << save_cursor // move cursor position to last row - << "\033[" << row << ";0f" + << "\033[" << size.rows << ";0f" << set_bg_color << set_fg_color << progress_str - << restore_cursor << restore_bg << restore_fg; std::flush(std::cout); + + // draw text progress bar + if (_config->FindB("Dpkg::Progress-Fancy::Progress-Bar", true)) + { + int padding = 4; + float progressbar_size = size.columns - padding - progress_str.size(); + float current_percent = (float)StepsDone/(float)TotalSteps; + std::cout << " " + << GetTextProgressStr(current_percent, progressbar_size) + << " "; + std::flush(std::cout); + } + + // restore + std::cout << restore_cursor; + std::flush(std::cout); + last_reported_progress = percentage; return true; diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h index baf245376..112b034fb 100644 --- a/apt-pkg/install-progress.h +++ b/apt-pkg/install-progress.h @@ -125,7 +125,12 @@ namespace Progress { void SetupTerminalScrollArea(int nr_rows); void HandleSIGWINCH(int); - int GetNumberTerminalRows(); + typedef struct { + int rows; + int columns; + } TermSize; + TermSize GetTerminalSize(); + sighandler_t old_SIGWINCH; int child_pty; @@ -138,6 +143,10 @@ namespace Progress { unsigned int StepsDone, unsigned int TotalSteps, std::string HumanReadableAction); + + // return a progress bar of the given size for the given progress + // percent between 0.0 and 1.0 in the form "[####...]" + static std::string GetTextProgressStr(float percent, int OutputSize); }; class PackageManagerText : public PackageManager -- 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/contrib/fileutl.cc | 6 +++++- apt-pkg/deb/dpkgpm.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 69406a9bf..188bb87ee 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -104,7 +104,11 @@ bool RunScripts(const char *Cnf) { if (Opts->Value.empty() == true) continue; - + + if(_config->FindB("Debug::RunScripts", false) == true) + std::clog << "Running external script: '" + << Opts->Value << "'" << std::endl; + if (system(Opts->Value.c_str()) != 0) _exit(100+Count); } 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') 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 f22b65b47990237bd5d9a1c171919c3059fbd9b0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Apr 2014 10:12:10 +0200 Subject: Fix insecure file permissions when using FileFd with OpenMode::Atomic Commit 7335eebea6dd43581d4650a8818b06383ab89901 introduced a bug that caused FileFd to create insecure permissions when FileFd::Atomic is used. This commit fixes the permissions and adds a test. The bug is most likely caused by the confusing "Perm" parameter that is passed to Open() - its not the file permissions but intead the "mode" part of open/creat. --- apt-pkg/contrib/fileutl.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 188bb87ee..8b57e87a3 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1067,6 +1067,10 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co if_FLAGGED_SET(Exclusive, O_EXCL); #undef if_FLAGGED_SET + // there is no getumask() so we read it by setting it and reset + mode_t current_umask = umask(0); + umask(current_umask); + if ((Mode & Atomic) == Atomic) { char *name = strdup((FileName + ".XXXXXX").c_str()); @@ -1080,11 +1084,11 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co TemporaryFileName = string(name); free(name); - if(Perms != 600 && fchmod(iFd, Perms) == -1) + if(Perms != 600 && fchmod(iFd, Perms & ~current_umask) == -1) return FileFdErrno("fchmod", "Could not change permissions for temporary file %s", TemporaryFileName.c_str()); } else - iFd = open(FileName.c_str(), fileflags, Perms); + iFd = open(FileName.c_str(), fileflags, Perms & ~current_umask); this->FileName = FileName; if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false) -- cgit v1.2.3 From e5f3f8c101b772a6eb6326203a2174e809ab406d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Apr 2014 10:24:47 +0200 Subject: Rename FileFd::Open() Perms to AccessMode Bug lp:#1304657 was caused by confusion around the name Perms. The new name AccessMode should make it clear that its not the literal file permissions but instead the AccessMode passed to open() (i.e. the umask needs to be applied) --- apt-pkg/contrib/fileutl.cc | 12 ++++++------ apt-pkg/contrib/fileutl.h | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 8b57e87a3..c6072ca15 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -958,10 +958,10 @@ class FileFdPrivate { /*{{{*/ // FileFd::Open - Open a file /*{{{*/ // --------------------------------------------------------------------- /* The most commonly used open mode combinations are given with Mode */ -bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, unsigned long const Perms) +bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, unsigned long const AccessMode) { if (Mode == ReadOnlyGzip) - return Open(FileName, ReadOnly, Gzip, Perms); + return Open(FileName, ReadOnly, Gzip, AccessMode); if (Compress == Auto && (Mode & WriteOnly) == WriteOnly) return FileFdError("Autodetection on %s only works in ReadOnly openmode!", FileName.c_str()); @@ -1028,9 +1028,9 @@ bool FileFd::Open(string FileName,unsigned int const Mode,CompressMode Compress, if (compressor == compressors.end()) return FileFdError("Can't find a match for specified compressor mode for file %s", FileName.c_str()); - return Open(FileName, Mode, *compressor, Perms); + return Open(FileName, Mode, *compressor, AccessMode); } -bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor, unsigned long const Perms) +bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor, unsigned long const AccessMode) { Close(); Flags = AutoClose; @@ -1084,11 +1084,11 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co TemporaryFileName = string(name); free(name); - if(Perms != 600 && fchmod(iFd, Perms & ~current_umask) == -1) + if(AccessMode != 600 && fchmod(iFd, AccessMode & ~current_umask) == -1) return FileFdErrno("fchmod", "Could not change permissions for temporary file %s", TemporaryFileName.c_str()); } else - iFd = open(FileName.c_str(), fileflags, Perms & ~current_umask); + iFd = open(FileName.c_str(), fileflags, AccessMode & ~current_umask); this->FileName = FileName; if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index f25ed3622..cc1a98eae 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -103,10 +103,10 @@ class FileFd return T; } - bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const Perms = 0666); - bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const Perms = 0666); - inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const Perms = 0666) { - return Open(FileName, Mode, None, Perms); + bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const AccessMode = 0666); + bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const AccessMode = 0666); + inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const AccessMode = 0666) { + return Open(FileName, Mode, None, AccessMode); }; bool OpenDescriptor(int Fd, unsigned int const Mode, CompressMode Compress, bool AutoClose=false); bool OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration::Compressor const &compressor, bool AutoClose=false); @@ -129,13 +129,13 @@ class FileFd inline bool IsCompressed() {return (Flags & Compressed) == Compressed;}; inline std::string &Name() {return FileName;}; - FileFd(std::string FileName,unsigned int const Mode,unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL) + FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL) { - Open(FileName,Mode, None, Perms); + Open(FileName,Mode, None, AccessMode); }; - FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long Perms = 0666) : iFd(-1), Flags(0), d(NULL) + FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL) { - Open(FileName,Mode, Compress, Perms); + Open(FileName,Mode, Compress, AccessMode); }; FileFd() : iFd(-1), Flags(AutoClose), d(NULL) {}; FileFd(int const Fd, unsigned int const Mode = ReadWrite, CompressMode Compress = None) : iFd(-1), Flags(0), d(NULL) -- cgit v1.2.3 From db5bf949ed796395d281474c49033f882e73f3a9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Apr 2014 09:11:57 +0200 Subject: improve umask/fchmod code readability --- apt-pkg/contrib/fileutl.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index c6072ca15..69a675648 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1067,9 +1067,12 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co if_FLAGGED_SET(Exclusive, O_EXCL); #undef if_FLAGGED_SET - // there is no getumask() so we read it by setting it and reset - mode_t current_umask = umask(0); - umask(current_umask); + // umask() will always set the umask and return the previous value, so + // we first set the umask and then reset it to the old value + mode_t CurrentUmask = umask(0); + umask(CurrentUmask); + // calculate the actual file permissions (just like open/creat) + mode_t FilePermissions = (AccessMode & ~CurrentUmask); if ((Mode & Atomic) == Atomic) { @@ -1084,11 +1087,11 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co TemporaryFileName = string(name); free(name); - if(AccessMode != 600 && fchmod(iFd, AccessMode & ~current_umask) == -1) + if(FilePermissions != 600 && fchmod(iFd, FilePermissions) == -1) return FileFdErrno("fchmod", "Could not change permissions for temporary file %s", TemporaryFileName.c_str()); } else - iFd = open(FileName.c_str(), fileflags, AccessMode & ~current_umask); + iFd = open(FileName.c_str(), fileflags, FilePermissions); this->FileName = FileName; if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false) -- cgit v1.2.3 From 53c3a8fa16351f35b7b7d359c81dfbe36ab04444 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 23 Mar 2014 13:17:24 +0100 Subject: use wildcard to get files in our library makefiles The explicit listing is a pain every time you want to add a file to the list and serves no propose as we list all files there anyway, so this is not only easier but also documents this fact. Git-Dch: Ignore --- apt-pkg/makefile | 48 +++--------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 1d456873b..5603b51ed 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -11,6 +11,7 @@ include ../buildlib/defaults.mak # The library name and version (indirectly used from init.h) include ../buildlib/libversion.mak + LIBRARY=apt-pkg MAJOR=$(LIBAPTPKG_MAJOR) MINOR=$(LIBAPTPKG_RELEASE) @@ -26,50 +27,7 @@ SLIBS+= -llzma endif APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR) -# Source code for the contributed non-core things -SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \ - contrib/configuration.cc contrib/progress.cc contrib/cmndline.cc \ - contrib/hashsum.cc contrib/md5.cc contrib/sha1.cc \ - contrib/sha2_internal.cc contrib/hashes.cc \ - contrib/cdromutl.cc contrib/crc-16.cc contrib/netrc.cc \ - contrib/fileutl.cc contrib/gpgv.cc -HEADERS = mmap.h error.h configuration.h fileutl.h cmndline.h netrc.h \ - md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h sha2.h sha256.h \ - sha2_internal.h hashes.h hashsum_template.h \ - macros.h weakptr.h gpgv.h - -# Source code for the core main library -SOURCE+= pkgcache.cc version.cc depcache.cc \ - orderlist.cc tagfile.cc sourcelist.cc packagemanager.cc \ - pkgrecords.cc algorithms.cc acquire.cc\ - acquire-worker.cc acquire-method.cc init.cc clean.cc \ - srcrecords.cc cachefile.cc versionmatch.cc policy.cc \ - pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ - indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ - aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \ - install-progress.cc upgrade.cc update.cc -HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ - orderlist.h sourcelist.h packagemanager.h tagfile.h \ - init.h pkgcache.h version.h progress.h pkgrecords.h \ - acquire.h acquire-worker.h acquire-item.h acquire-method.h \ - clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ - pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ - vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h install-progress.h \ - upgrade.h update.h - -# Source code for the debian specific components -# In theory the deb headers do not need to be exported.. -SOURCE+= deb/deblistparser.cc deb/debrecords.cc deb/dpkgpm.cc \ - deb/debsrcrecords.cc deb/debversion.cc deb/debsystem.cc \ - deb/debindexfile.cc deb/debindexfile.cc deb/debmetaindex.cc -HEADERS+= debversion.h debsrcrecords.h dpkgpm.h debrecords.h \ - deblistparser.h debsystem.h debindexfile.h debmetaindex.h - -# Source code for the APT resolver interface specific components -SOURCE+= edsp/edsplistparser.cc edsp/edspindexfile.cc edsp/edspsystem.cc -HEADERS+= edsplistparser.h edspindexfile.h edspsystem.h - -HEADERS := $(addprefix apt-pkg/,$(HEADERS)) +SOURCE = $(wildcard *.cc */*.cc) +HEADERS = $(addprefix apt-pkg/,$(notdir $(wildcard *.h */*.h))) include $(LIBRARY_H) -- cgit v1.2.3 From 8056a00cd76c0f9dd6c444f23aa9998f96f805ed Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 Apr 2014 11:16:04 +0200 Subject: do not create an (additional) empty compressor FileFd code knows how to deal with such a compressor, so it isn't a problem, but it is absolutely not needed as we already have an (matching) identity compressor with '.' earlier in the list. Git-Dch: Ignore --- apt-pkg/aptconfiguration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 6ba047560..9982759c6 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -476,7 +476,7 @@ const Configuration::getCompressors(bool const Cached) { std::vector const comp = _config->FindVector("APT::Compressor"); for (std::vector::const_iterator c = comp.begin(); c != comp.end(); ++c) { - if (*c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz") + if (c->empty() || *c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz") continue; compressors.push_back(Compressor(c->c_str(), std::string(".").append(*c).c_str(), c->c_str(), "-9", "-d", 100)); } -- cgit v1.2.3 From 21ba8115c873ae4085770e4bf0bed765e0e099a6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 Apr 2014 11:18:58 +0200 Subject: don't double-count seeks in FileFd::Skip for bzip/xz FileFd::Read already deals with the increase of the skipposition so that we as the caller in FileFd::Skip really shouldn't increase it, too. --- apt-pkg/contrib/fileutl.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 69a675648..c51f75984 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1712,7 +1712,6 @@ bool FileFd::Skip(unsigned long long Over) { if (d != NULL && (d->pipe == true || d->InternalStream() == true)) { - d->seekpos += Over; char buffer[1024]; while (Over != 0) { -- cgit v1.2.3 From 230e69d718f761a39ee3ee057938dcd0264af74f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 Apr 2014 11:22:10 +0200 Subject: deal with umask only if we really need to for mkstemp As the comment actually says: open() does the umask dance by itself, so we don't need to do it for it. We have to do it after mkstemp in Atomic though, so move it into the if. Also removes the "micro-optimisation" "FilePermissions == 600" as it doesn't trigger at the moment anyway as 600 != 0600. --- apt-pkg/contrib/fileutl.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index c51f75984..c9d419fc4 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1067,13 +1067,6 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co if_FLAGGED_SET(Exclusive, O_EXCL); #undef if_FLAGGED_SET - // umask() will always set the umask and return the previous value, so - // we first set the umask and then reset it to the old value - mode_t CurrentUmask = umask(0); - umask(CurrentUmask); - // calculate the actual file permissions (just like open/creat) - mode_t FilePermissions = (AccessMode & ~CurrentUmask); - if ((Mode & Atomic) == Atomic) { char *name = strdup((FileName + ".XXXXXX").c_str()); @@ -1087,11 +1080,18 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co TemporaryFileName = string(name); free(name); - if(FilePermissions != 600 && fchmod(iFd, FilePermissions) == -1) + // umask() will always set the umask and return the previous value, so + // we first set the umask and then reset it to the old value + mode_t const CurrentUmask = umask(0); + umask(CurrentUmask); + // calculate the actual file permissions (just like open/creat) + mode_t const FilePermissions = (AccessMode & ~CurrentUmask); + + if(fchmod(iFd, FilePermissions) == -1) return FileFdErrno("fchmod", "Could not change permissions for temporary file %s", TemporaryFileName.c_str()); } else - iFd = open(FileName.c_str(), fileflags, FilePermissions); + iFd = open(FileName.c_str(), fileflags, AccessMode); this->FileName = FileName; if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false) -- cgit v1.2.3 From 4cd4a2e7033a2af214be1d830b56fab719088b7a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 Apr 2014 13:33:31 +0200 Subject: consider priorities only for downloadable pkgs in resolver A package which can't be downloaded anymore is very likely dropped from a release and can therefore no longer be 'standard' (or similar). We therefore do not grant points for them anymore and demote them to prio:extra instead which helps other packages breaking them away even if they have a lower priority. The testcase was initially created by Michael Vogt and just amended. --- apt-pkg/algorithms.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index a7b676660..608ec7fce 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -445,19 +445,22 @@ void pkgProblemResolver::MakeScores() || (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important) Score += PrioEssentials; - // We transform the priority - if (Cache[I].InstVerIter(Cache)->Priority <= 5) - Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority]; - + pkgCache::VerIterator const InstVer = Cache[I].InstVerIter(Cache); + // We apply priorities only to downloadable packages, all others are prio:extra + // as an obsolete prio:standard package can't be that standard anymore… + if (InstVer->Priority <= pkgCache::State::Extra && InstVer.Downloadable() == true) + Score += PrioMap[InstVer->Priority]; + else + Score += PrioMap[pkgCache::State::Extra]; + /* This helps to fix oddball problems with conflicting packages - on the same level. We enhance the score of installed packages - if those are not obsolete - */ + on the same level. We enhance the score of installed packages + if those are not obsolete */ if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable()) Score += PrioInstalledAndNotObsolete; // propagate score points along dependencies - for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) + for (pkgCache::DepIterator D = InstVer.DependsList(); D.end() == false; ++D) { if (DepMap[D->Type] == 0) continue; -- cgit v1.2.3 From 76bd63e2dc6ac5aaaf7f2cc98c2a83ab88ccc46c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 Apr 2014 17:12:09 +0200 Subject: force fancy progressbar redraw on window size change We always reacted on the size change, but the bar is only redraw if the precentage changes, which can take quiet a while in big upgrades, so with a bit of refactoring we can now call for a redraw immediate to fix this. This refactor also helps in avoiding obscure pitfalls clangs static analyser was complaining about (namely failure of ioctl resulting in garbage values in the struct). --- apt-pkg/install-progress.cc | 35 +++++++++++++++++++++++------------ apt-pkg/install-progress.h | 3 +++ 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 8bb587f67..cf6c85912 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -256,14 +256,14 @@ PackageManagerFancy::TermSize PackageManagerFancy::GetTerminalSize() { struct winsize win; - PackageManagerFancy::TermSize s; + PackageManagerFancy::TermSize s = { 0, 0 }; // FIXME: get from "child_pty" instead? if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0) return s; if(_config->FindB("Debug::InstallProgress::Fancy", false) == true) - std::cerr << "GetTerminalSize: " << win.ws_row << std::endl; + std::cerr << "GetTerminalSize: " << win.ws_row << " x " << win.ws_col << std::endl; s.rows = win.ws_row; s.columns = win.ws_col; @@ -275,6 +275,9 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) if(_config->FindB("Debug::InstallProgress::Fancy", false) == true) std::cerr << "SetupTerminalScrollArea: " << nr_rows << std::endl; + if (unlikely(nr_rows <= 1)) + return; + // scroll down a bit to avoid visual glitch when the screen // area shrinks by one row std::cout << "\n"; @@ -296,28 +299,30 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) // setup tty size to ensure xterm/linux console are working properly too // see bug #731738 struct winsize win; - ioctl(child_pty, TIOCGWINSZ, (char *)&win); - win.ws_row = nr_rows - 1; - ioctl(child_pty, TIOCSWINSZ, (char *)&win); + if (ioctl(child_pty, TIOCGWINSZ, (char *)&win) != -1) + { + win.ws_row = nr_rows - 1; + ioctl(child_pty, TIOCSWINSZ, (char *)&win); + } } void PackageManagerFancy::HandleSIGWINCH(int) { - int nr_terminal_rows = GetTerminalSize().rows; + int const nr_terminal_rows = GetTerminalSize().rows; SetupTerminalScrollArea(nr_terminal_rows); + DrawStatusLine(); } void PackageManagerFancy::Start(int a_child_pty) { child_pty = a_child_pty; - int nr_terminal_rows = GetTerminalSize().rows; - if (nr_terminal_rows > 0) - SetupTerminalScrollArea(nr_terminal_rows); + int const nr_terminal_rows = GetTerminalSize().rows; + SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Stop() { - int nr_terminal_rows = GetTerminalSize().rows; + int const nr_terminal_rows = GetTerminalSize().rows; if (nr_terminal_rows > 0) { SetupTerminalScrollArea(nr_terminal_rows + 1); @@ -358,7 +363,13 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, HumanReadableAction)) return false; - PackageManagerFancy::TermSize size = GetTerminalSize(); + return DrawStatusLine(); +} +bool PackageManagerFancy::DrawStatusLine() +{ + PackageManagerFancy::TermSize const size = GetTerminalSize(); + if (unlikely(size.rows < 1 || size.columns < 1)) + return false; static std::string save_cursor = "\033[s"; static std::string restore_cursor = "\033[u"; @@ -388,7 +399,7 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, { int padding = 4; float progressbar_size = size.columns - padding - progress_str.size(); - float current_percent = (float)StepsDone/(float)TotalSteps; + float current_percent = percentage / 100.0; std::cout << " " << GetTextProgressStr(current_percent, progressbar_size) << " "; diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h index 112b034fb..5d1a20e9b 100644 --- a/apt-pkg/install-progress.h +++ b/apt-pkg/install-progress.h @@ -1,6 +1,8 @@ #ifndef PKGLIB_IPROGRESS_H #define PKGLIB_IPROGRESS_H +#include + #include #include #include @@ -120,6 +122,7 @@ namespace Progress { private: static void staticSIGWINCH(int); static std::vector instances; + APT_HIDDEN bool DrawStatusLine(); protected: void SetupTerminalScrollArea(int nr_rows); -- cgit v1.2.3 From bb93178b8b5c2f8021977dbc34066f0d0fb8b9b9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 15 Apr 2014 10:21:52 +0200 Subject: clear HitEof flag in FileFd::Seek fseek and co do this to their eof-flags and it is more logic this way as we will usually seek away from the end (e.g. to re-read the file). The commit also improves the testcase further and adds a test for the binary compressor codepath (as gz, bzip2 and xz are handled by libraries) via the use of 'rev' as a 'compressor'. --- apt-pkg/contrib/fileutl.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index c9d419fc4..de73a7fd8 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1360,7 +1360,10 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C Args.push_back(a->c_str()); if (Comp == false && FileName.empty() == false) { - Args.push_back("--stdout"); + // commands not needing arguments, do not need to be told about using standard output + // in reality, only testcases with tools like cat, rev, rot13, … are able to trigger this + if (compressor.CompressArgs.empty() == false && compressor.UncompressArgs.empty() == false) + Args.push_back("--stdout"); if (TemporaryFileName.empty() == false) Args.push_back(TemporaryFileName.c_str()); else @@ -1653,6 +1656,8 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size) /* */ bool FileFd::Seek(unsigned long long To) { + Flags &= ~HitEof; + if (d != NULL && (d->pipe == true || d->InternalStream() == true)) { // Our poor man seeking in pipes is costly, so try to avoid it -- 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 +- apt-pkg/init.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') 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; diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 3a35f852e..241628632 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -86,6 +86,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$"); Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$"); Cnf.Set("Dir::Ignore-Files-Silently::", "\\.orig$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.distUpgrade$"); // Default cdrom mount point Cnf.CndSet("Acquire::cdrom::mount", "/media/cdrom/"); -- cgit v1.2.3 From 7187074bfc7a6932ab21c33546e71b61abe258e3 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Mon, 21 Apr 2014 11:54:34 +0200 Subject: properly undo CD-ROM mount in all error cases In bug #740673 various issues in the CD-ROM handling code were identified, while most the issues ended up being fixed in another way, the unmounting of the CD-ROM in error cases was not tackled so far. (The patch was modified by the commiter to apply) --- apt-pkg/cdrom.cc | 66 +++++++++++++++++++++++++++++++++++--------------------- apt-pkg/cdrom.h | 1 + 2 files changed, 42 insertions(+), 25 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2635ede76..a5ad6a9ff 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -563,6 +563,15 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) return true; } /*}}}*/ +bool pkgCdrom::UnmountCDROM(std::string const &CDROM, pkgCdromStatus * const log)/*{{{*/ +{ + if (_config->FindB("APT::CDROM::NoMount",false) == true) + return true; + if (log != NULL) + log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); + return UnmountCdrom(CDROM); +} + /*}}}*/ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/ { // Startup @@ -583,9 +592,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s { if (interactive == true) { - if(log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, log); if(log != NULL) { @@ -605,6 +612,9 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s return _error->Error("Failed to mount the cdrom."); } + if (IsMounted(CDROM) == false) + return _error->Error("Failed to mount the cdrom."); + // Hash the CD to get an ID if (log != NULL) log->Update(_("Identifying... "), STEP_IDENT); @@ -614,6 +624,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s ident = ""; if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } @@ -629,8 +640,11 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s if (FileExists(DFile) == true) { if (ReadConfigFile(Database,DFile) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); + } } return true; } @@ -651,13 +665,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) - { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ @@ -682,11 +690,15 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } if (chdir(StartDir.c_str()) != 0) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("chdir","Unable to change to %s", StartDir.c_str()); + } if (_config->FindB("Debug::aptcdrom",false) == true) { @@ -728,8 +740,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (List.empty() == true && SourceList.empty() == true) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error(_("Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture?")); } @@ -769,14 +780,14 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if(log == NULL) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("No disc name found and no way to ask for it"); } while(true) { if(!log->AskCdromName(Name)) { // user canceld + UnmountCDROM(CDROM, NULL); return false; } cout << "Name: '" << Name << "'" << endl; @@ -813,7 +824,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string const partialListDir = listDir + "partial/"; if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("cdrom", _("List directory %spartial is missing."), listDir.c_str()); + } // take care of the signatures and copy them if they are ok // (we do this before PackageCopy as it modifies "List" and "SourceList") @@ -827,7 +841,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (Copy.CopyPackages(CDROM,Name,List, log) == false || SrcCopy.CopyPackages(CDROM,Name,SourceList, log) == false || TransCopy.CopyTranslations(CDROM,Name,TransList, log) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } // reduce the List so that it takes less space in sources.list ReduceSourcelist(CDROM,List); @@ -837,13 +854,19 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (_config->FindB("APT::cdrom::NoAct",false) == false) { if (WriteDatabase(Database) == false) + { + UnmountCDROM(CDROM, NULL); return false; - + } + if(log != NULL) log->Update(_("Writing new source list\n"), STEP_WRITE); if (WriteSourceList(Name,List,false) == false || WriteSourceList(Name,SourceList,true) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } } // Print the sourcelist entries @@ -855,8 +878,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string::size_type Space = (*I).find(' '); if (Space == string::npos) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -874,8 +896,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string::size_type Space = (*I).find(' '); if (Space == string::npos) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -888,12 +909,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 0f2c2cd02..bd0902176 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -77,6 +77,7 @@ class pkgCdrom /*{{{*/ private: APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive); + APT_HIDDEN bool UnmountCDROM(std::string const &CDROM, pkgCdromStatus * const log); }; /*}}}*/ -- cgit v1.2.3 From d99854cac4065bc7b337815fb2116269d58dab73 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 21 Apr 2014 13:26:55 +0200 Subject: handle pkgnames shorter than modifiers The bugreport highlights the problem with an empty package name. We fix this by 'ignoring' these so that it behaves just like "apt-get install". The deeper problem is that modifier strings can be longer than a package name in which case the comparison doesn't make sense, so don't compare then. Was not noticed so far as all modifiers are of length 1, so the only package name shorter than this is in fact the empty package name. Closes: 744940 --- apt-pkg/cacheset.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index d453a2bfb..2ed6a96da 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -391,6 +391,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, CacheSetHelper &helper) { Version select = NEWEST; std::string str = cmdline; + if (unlikely(str.empty() == true)) + return false; bool modifierPresent = false; unsigned short fallback = modID; for (std::list::const_iterator mod = mods.begin(); @@ -400,8 +402,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, size_t const alength = strlen(mod->Alias); switch(mod->Pos) { case Modifier::POSTFIX: - if (str.compare(str.length() - alength, alength, - mod->Alias, 0, alength) != 0) + if (str.length() <= alength || + str.compare(str.length() - alength, alength, mod->Alias, 0, alength) != 0) continue; str.erase(str.length() - alength); modID = mod->ID; -- cgit v1.2.3 From 05eab8afb692823f86c53c4c2ced783a7c185cf9 Mon Sep 17 00:00:00 2001 From: Adam Conrad Date: Sat, 26 Apr 2014 10:24:40 +0200 Subject: fix FileFd::Size bitswap on big-endian architectures gzip only gives us 32bit of size, storing it in a 64bit container and doing a 32bit flip on it has therefore unintended results. So we just go with a exact size container and let the flipping be handled by eglibc provided le32toh removing our #ifdef machinery. Closes: 745866 --- apt-pkg/contrib/fileutl.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index de73a7fd8..b77c7ff7f 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -58,13 +58,10 @@ #include #endif #ifdef HAVE_LZMA - #include #include #endif - -#ifdef WORDS_BIGENDIAN -#include -#endif +#include +#include #include /*}}}*/ @@ -1880,19 +1877,13 @@ unsigned long long FileFd::Size() FileFdErrno("lseek","Unable to seek to end of gzipped file"); return 0; } - size = 0; + uint32_t size = 0; if (read(iFd, &size, 4) != 4) { FileFdErrno("read","Unable to read original size of gzipped file"); return 0; } - -#ifdef WORDS_BIGENDIAN - uint32_t tmp_size = size; - uint8_t const * const p = (uint8_t const * const) &tmp_size; - tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; - size = tmp_size; -#endif + size = le32toh(size); if (lseek(iFd, oldPos, SEEK_SET) < 0) { -- 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') 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