From fa5404ab01bdf06eaf147d9f133139e6c89b906a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 7 Nov 2014 18:18:14 +0100 Subject: [PATCH] explicit overload methods instead of adding parameters Adding a new parameter (with a default) is an ABI break, but you can overload a method, which is "just" an API break for everyone doing references to this method (aka: nobody). Git-Dch: Ignore --- apt-pkg/algorithms.cc | 12 ++++++++++++ apt-pkg/algorithms.h | 10 ++++++++++ apt-pkg/contrib/configuration.cc | 6 ++++++ apt-pkg/contrib/configuration.h | 8 ++++++++ apt-pkg/depcache.h | 4 ++-- apt-pkg/indexrecords.cc | 13 +++++++++++++ apt-pkg/indexrecords.h | 6 +++++- apt-pkg/tagfile.cc | 6 ++++++ apt-pkg/tagfile.h | 6 ++++++ apt-pkg/upgrade.cc | 18 ++++++++++++++++-- apt-pkg/upgrade.h | 13 +++++++++---- debian/libapt-pkg4.15.symbols | 6 ++++-- 12 files changed, 97 insertions(+), 11 deletions(-) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 71b5ac2c1..c8696b8ad 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -640,6 +640,12 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) // ProblemResolver::Resolve - calls a resolver to fix the situation /*{{{*/ // --------------------------------------------------------------------- /* */ +#if APT_PKG_ABI < 413 +bool pkgProblemResolver::Resolve(bool BrokenFix) +{ + return Resolve(BrokenFix, NULL); +} +#endif bool pkgProblemResolver::Resolve(bool BrokenFix, OpProgress * const Progress) { std::string const solver = _config->Find("APT::Solver", "internal"); @@ -1138,6 +1144,12 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I) /* This is the work horse of the soft upgrade routine. It is very gental in that it does not install or remove any packages. It is assumed that the system was non-broken previously. */ +#if APT_PKG_ABI < 413 +bool pkgProblemResolver::ResolveByKeep() +{ + return ResolveByKeep(NULL); +} +#endif bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress) { std::string const solver = _config->Find("APT::Solver", "internal"); diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index b6da1f2bf..2ac28c0d7 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -138,10 +138,20 @@ class pkgProblemResolver /*{{{*/ inline void Clear(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] &= ~(Protected | ToRemove);}; // Try to intelligently resolve problems by installing and removing packages +#if APT_PKG_ABI >= 413 bool Resolve(bool BrokenFix = false, OpProgress * const Progress = NULL); +#else + bool Resolve(bool BrokenFix = false); + bool Resolve(bool BrokenFix, OpProgress * const Progress); +#endif // Try to resolve problems only by using keep +#if APT_PKG_ABI >= 413 bool ResolveByKeep(OpProgress * const Progress = NULL); +#else + bool ResolveByKeep(); + bool ResolveByKeep(OpProgress * const Progress); +#endif APT_DEPRECATED void InstallProtect(); diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 4380d64b9..483d5bb1b 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -253,6 +253,12 @@ 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 */ +#if APT_PKG_ABI < 413 +vector Configuration::FindVector(const char *Name) const +{ + return FindVector(Name, ""); +} +#endif vector Configuration::FindVector(const char *Name, std::string const &Default) const { vector Vec; diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2ecea8bee..8d7d51037 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -84,8 +84,16 @@ class Configuration * * \param Name of the parent node * \param Default list of values separated by commas */ +#if APT_PKG_ABI >= 413 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); }; +#else + 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); }; + std::vector FindVector(const char *Name) const; + std::vector FindVector(std::string const &Name) const { return FindVector(Name.c_str(), ""); }; +#endif + 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/depcache.h b/apt-pkg/depcache.h index 5554e1a69..20d263c67 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -109,7 +109,7 @@ class pkgDepCache : protected pkgCache::Namespace * * \return \b false if an error occurred. */ - APT_HIDDEN bool MarkRequired(InRootSetFunc &rootFunc); + bool MarkRequired(InRootSetFunc &rootFunc); /** \brief Set the StateCache::Garbage flag on all packages that * should be removed. @@ -120,7 +120,7 @@ class pkgDepCache : protected pkgCache::Namespace * * \return \b false if an error occurred. */ - APT_HIDDEN bool Sweep(); + bool Sweep(); public: diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 0f27af32b..d65266f64 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -270,10 +270,23 @@ void indexRecords::SetTrusted(bool const Trusted) this->Trusted = NEVER_TRUSTED; } +#if APT_PKG_ABI >= 413 indexRecords::indexRecords(const string &ExpectedDist) : Trusted(CHECK_TRUST), d(NULL), ExpectedDist(ExpectedDist), ValidUntil(0), SupportsAcquireByHash(false) { } +#else +indexRecords::indexRecords() : + Trusted(CHECK_TRUST), d(NULL), ExpectedDist(""), ValidUntil(0), + SupportsAcquireByHash(false) +{ +} +indexRecords::indexRecords(const string ExpectedDist) : + Trusted(CHECK_TRUST), d(NULL), ExpectedDist(ExpectedDist), ValidUntil(0), + SupportsAcquireByHash(false) +{ +} +#endif indexRecords::~indexRecords() {} diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index 06b9dafa6..35e534c12 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -42,8 +42,12 @@ class indexRecords std::map Entries; public: - +#if APT_PKG_ABI >= 413 indexRecords(const std::string &ExpectedDist = ""); +#else + indexRecords(); + indexRecords(const std::string ExpectedDist); +#endif // Lookup function virtual checkSum *Lookup(const std::string MetaKey); diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index e667c495f..3ee5c7076 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -281,6 +281,12 @@ pkgTagSection::pkgTagSection() } /*}}}*/ // TagSection::Scan - Scan for the end of the header information /*{{{*/ +#if APT_PKG_ABI < 413 +bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength) +{ + return Scan(Start, MaxLength, true); +} +#endif bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const Restart) { Section = Start; diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 99e2a8d93..ac6d42089 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -86,7 +86,13 @@ class pkgTagSection * @return \b true if section end was found, \b false otherwise. * Beware that internal state will be inconsistent if \b false is returned! */ +#if APT_PKG_ABI >= 413 APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const Restart = true); +#else + APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const Restart); + APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength); +#endif + inline unsigned long size() const {return Stop - Section;}; void Trim(); virtual void TrimRecord(bool BeforeRecord, const char* &End); diff --git a/apt-pkg/upgrade.cc b/apt-pkg/upgrade.cc index 41e76802a..6c8721da8 100644 --- a/apt-pkg/upgrade.cc +++ b/apt-pkg/upgrade.cc @@ -24,7 +24,7 @@ The problem resolver is used to resolve the problems. */ -bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress) +static bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress) { std::string const solver = _config->Find("APT::Solver", "internal"); if (solver != "internal") @@ -119,6 +119,10 @@ bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress) if (Progress != NULL) Progress->Done(); return success; +} +bool pkgDistUpgrade(pkgDepCache &Cache) +{ + return pkgDistUpgrade(Cache, NULL); } /*}}}*/ // AllUpgradeNoNewPackages - Upgrade but no removals or new pkgs /*{{{*/ @@ -229,9 +233,13 @@ static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache, OpProgress * const /* Right now the system must be consistent before this can be called. It also will not change packages marked for install, it only tries to install packages not marked for install */ -bool pkgAllUpgrade(pkgDepCache &Cache, OpProgress * const Progress) +static bool pkgAllUpgrade(pkgDepCache &Cache, OpProgress * const Progress) { return pkgAllUpgradeNoNewPackages(Cache, Progress); +} +bool pkgAllUpgrade(pkgDepCache &Cache) +{ + return pkgAllUpgrade(Cache, NULL); } /*}}}*/ // MinimizeUpgrade - Minimizes the set of packages to be upgraded /*{{{*/ @@ -280,6 +288,12 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) } /*}}}*/ // APT::Upgrade::Upgrade - Upgrade using a specific strategy /*{{{*/ +#if APT_PKG_ABI < 413 +bool APT::Upgrade::Upgrade(pkgDepCache &Cache, int mode) +{ + return Upgrade(Cache, mode, NULL); +} +#endif bool APT::Upgrade::Upgrade(pkgDepCache &Cache, int mode, OpProgress * const Progress) { APT_IGNORE_DEPRECATED_PUSH diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h index a3f693d86..18b6aac7b 100644 --- a/apt-pkg/upgrade.h +++ b/apt-pkg/upgrade.h @@ -20,17 +20,22 @@ namespace APT { namespace Upgrade { // FIXME: make this "enum class UpgradeMode {" once we enable c++11 enum UpgradeMode { - ALLOW_EVERYTHING = 0, FORBID_REMOVE_PACKAGES = 1, - FORBID_INSTALL_NEW_PACKAGES = 2 + FORBID_INSTALL_NEW_PACKAGES = 2, + ALLOW_EVERYTHING = 0 }; +#if APT_PKG_ABI >= 413 bool Upgrade(pkgDepCache &Cache, int UpgradeMode, OpProgress * const Progress = NULL); +#else + bool Upgrade(pkgDepCache &Cache, int UpgradeMode); + bool Upgrade(pkgDepCache &Cache, int UpgradeMode, OpProgress * const Progress); +#endif } } // please use APT::Upgrade::Upgrade() instead -APT_DEPRECATED bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress = NULL); -APT_DEPRECATED bool pkgAllUpgrade(pkgDepCache &Cache, OpProgress * const Progress = NULL); +APT_DEPRECATED bool pkgDistUpgrade(pkgDepCache &Cache); +APT_DEPRECATED bool pkgAllUpgrade(pkgDepCache &Cache); bool pkgMinimizeUpgrade(pkgDepCache &Cache); #endif diff --git a/debian/libapt-pkg4.15.symbols b/debian/libapt-pkg4.15.symbols index 9888223a9..5e0c0244d 100644 --- a/debian/libapt-pkg4.15.symbols +++ b/debian/libapt-pkg4.15.symbols @@ -49,6 +49,8 @@ libapt-pkg.so.4.15 libapt-pkg4.15 #MINVER# (c++)"pkgPrioSortList(pkgCache&, pkgCache::Version**)@Base" 0.8.0 (c++)"pkgMakeStatusCache(pkgSourceList&, OpProgress&, MMap**, bool)@Base" 0.8.0 (c++)"pkgMinimizeUpgrade(pkgDepCache&)@Base" 0.8.0 + (c++)"pkgAllUpgrade(pkgDepCache&)@Base" 0.8.0 + (c++)"pkgDistUpgrade(pkgDepCache&)@Base" 0.8.0 (c++)"GetListOfFilesInDir(std::basic_string, std::allocator > const&, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, bool const&)@Base" 0.8.0 (c++)"GetListOfFilesInDir(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&, bool const&, bool const&)@Base" 0.8.0 (c++)"pkgMakeOnlyStatusCache(OpProgress&, DynamicMMap**)@Base" 0.8.0 @@ -233,6 +235,8 @@ libapt-pkg.so.4.15 libapt-pkg4.15 #MINVER# (c++)"pkgDepCache::CheckDep(pkgCache::DepIterator, int, pkgCache::PkgIterator&)@Base" 0.8.0 (c++)"pkgDepCache::MarkAuto(pkgCache::PkgIterator const&, bool)@Base" 0.8.0 (c++)"pkgDepCache::MarkKeep(pkgCache::PkgIterator const&, bool, bool, unsigned long)@Base" 0.8.0 + (c++)"pkgDepCache::MarkRequired(pkgDepCache::InRootSetFunc&)@Base" 0.8.0 + (c++)"pkgDepCache::Sweep()@Base" 0.8.0 (c++)"pkgDepCache::pkgDepCache(pkgCache*, pkgDepCache::Policy*)@Base" 0.8.0 (c++)"pkgDepCache::~pkgDepCache()@Base" 0.8.0 (c++)"pkgSimulate::Policy::GetCandidateVer(pkgCache::PkgIterator const&)@Base" 0.8.0 @@ -1362,8 +1366,6 @@ libapt-pkg.so.4.15 libapt-pkg4.15 #MINVER# (c++)"Popen(char const**, FileFd&, int&, FileFd::OpenMode)@Base" 1.1~exp1 (c++)"APT::String::Startswith(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)@Base" 1.1~exp2 (c++)"APT::Upgrade::Upgrade(pkgDepCache&, int, OpProgress*)@Base" 1.1~exp4 - (c++)"pkgAllUpgrade(pkgDepCache&, OpProgress*)@Base" 1.1~exp4 - (c++)"pkgDistUpgrade(pkgDepCache&, OpProgress*)@Base" 1.1~exp4 (c++)"pkgProblemResolver::Resolve(bool, OpProgress*)@Base" 1.1~exp4 (c++)"pkgProblemResolver::ResolveByKeep(OpProgress*)@Base" 1.1~exp4 (c++)"pkgCache::PkgIterator::Section() const@Base" 1.1~exp4 -- 2.45.2