From 4326680d2ed23d597f45ca8872a7054368560acc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 28 Jul 2016 11:43:36 +0200 Subject: simulate all package manager actions explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a planner lets actions to be figured out by dpkg in pending calls these actions aren't mentioned in a simulation. While that might be a good thing for debugging, it would be a change in behavior and especially if a planner avoids explicit removals could be confusing for users. As such we perform the same 'trick' as in the dpkg implementation by performing explicitly what would be done by the pending calls. To save us some work and avoid desyncs we perform a layer violation by using deb/ code in the generic simulation – and further we perform ugly dynamic_cast to avoid breaking the ABI for nothing; aptitude is the only other user of the simulation class according to codesearch.d.n and for that our little trick works. It just isn't working if you happen to extend pkgSimulate or otherwise manage to call the protected Go methods directly – which isn't very realistic/practical. --- apt-pkg/deb/dpkgpm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb/dpkgpm.h') diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 07c99aead..193754644 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -76,7 +76,8 @@ class pkgDPkgPM : public pkgPackageManager // progress reporting unsigned int PackagesDone; unsigned int PackagesTotal; - + + public: struct Item { enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending, @@ -86,8 +87,8 @@ class pkgDPkgPM : public pkgPackageManager Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op), File(File), Pkg(Pkg) {}; Item() {}; - }; + protected: std::vector List; // Helpers @@ -126,7 +127,7 @@ class pkgDPkgPM : public pkgPackageManager virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE; virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE; - virtual bool Go(int StatusFd=-1) APT_OVERRIDE; + APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int StatusFd=-1) APT_OVERRIDE; virtual void Reset() APT_OVERRIDE; @@ -134,6 +135,8 @@ class pkgDPkgPM : public pkgPackageManager pkgDPkgPM(pkgDepCache *Cache); virtual ~pkgDPkgPM(); + + APT_HIDDEN static bool ExpandPendingCalls(std::vector &List, pkgDepCache &Cache); }; void SigINT(int sig); -- cgit v1.2.3