From da7de99f8473ae0ac90c90fad3eee80f5f72889a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 26 Feb 2020 14:29:06 +0100 Subject: pkgsystem: Drop more virtual workaround shenanigans --- apt-pkg/deb/debsystem.cc | 4 ++-- apt-pkg/deb/debsystem.h | 10 +++++----- apt-pkg/deb/dpkgpm.cc | 5 ++--- apt-pkg/edsp/edspsystem.h | 8 ++++++++ apt-pkg/pkgsystem.cc | 41 ----------------------------------------- apt-pkg/pkgsystem.h | 10 +++++----- 6 files changed, 22 insertions(+), 56 deletions(-) diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 0c7e9ff39..225761e9d 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -419,7 +419,7 @@ pid_t debSystem::ExecDpkg(std::vector const &sArgs, int * const inp return dpkg; } /*}}}*/ -bool debSystem::SupportsMultiArch() /*{{{*/ +bool debSystem::MultiArchSupported() const /*{{{*/ { std::vector Args = GetDpkgBaseCommand(); Args.push_back("--assert-multi-arch"); @@ -440,7 +440,7 @@ bool debSystem::SupportsMultiArch() /*{{{*/ return false; } /*}}}*/ -std::vector debSystem::SupportedArchitectures() /*{{{*/ +std::vector debSystem::ArchitecturesSupported() const /*{{{*/ { std::vector archs; { diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h index 3a308fb1c..a331af351 100644 --- a/apt-pkg/deb/debsystem.h +++ b/apt-pkg/deb/debsystem.h @@ -45,12 +45,12 @@ class debSystem : public pkgSystem APT_HIDDEN static std::vector GetDpkgBaseCommand(); APT_HIDDEN static void DpkgChrootDirectory(); APT_HIDDEN static pid_t ExecDpkg(std::vector const &sArgs, int * const inputFd, int * const outputFd, bool const DiscardOutput); - APT_HIDDEN static bool SupportsMultiArch(); - APT_HIDDEN static std::vector SupportedArchitectures(); + bool MultiArchSupported() const override; + std::vector ArchitecturesSupported() const override; - APT_HIDDEN bool LockInner(); - APT_HIDDEN bool UnLockInner(bool NoErrors=false); - APT_HIDDEN bool IsLocked(); + bool LockInner() override; + bool UnLockInner(bool NoErrors=false) override; + bool IsLocked() override; }; extern debSystem debSys; diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 0b807d668..ef73881c8 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1711,7 +1711,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) // create log OpenLog(); - bool dpkgMultiArch = debSystem::SupportsMultiArch(); + bool dpkgMultiArch = _system->MultiArchSupported(); // start pty magic before the loop StartPtyMagic(); @@ -2014,8 +2014,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) else setenv("DPKG_COLORS", "never", 0); - if (dynamic_cast(_system) != nullptr - && dynamic_cast(_system)->IsLocked() == true) { + if (_system->IsLocked() == true) { setenv("DPKG_FRONTEND_LOCKED", "true", 1); } if (_config->Find("DPkg::Path", "").empty() == false) diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h index 8f5452dcb..9e34345cd 100644 --- a/apt-pkg/edsp/edspsystem.h +++ b/apt-pkg/edsp/edspsystem.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -37,6 +38,13 @@ public: virtual bool FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const APT_OVERRIDE; + bool MultiArchSupported() const override { return true; } + std::vector ArchitecturesSupported() const override { return {}; }; + + bool LockInner() override { return _error->Error("LockInner is not implemented"); }; + bool UnLockInner(bool NoErrors=false) override { return _error->Error("UnLockInner is not implemented"); }; + bool IsLocked() override { return true; }; + explicit edspLikeSystem(char const * const Label); virtual ~edspLikeSystem(); }; diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index eaa3f5ab7..7e48a68c7 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -56,22 +56,6 @@ APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label) return 0; } /*}}}*/ -bool pkgSystem::MultiArchSupported() const /*{{{*/ -{ - debSystem const * const deb = dynamic_cast(this); - if (deb != NULL) - return deb->SupportsMultiArch(); - return true; -} - /*}}}*/ -std::vector pkgSystem::ArchitecturesSupported() const /*{{{*/ -{ - debSystem const * const deb = dynamic_cast(this); - if (deb != NULL) - return deb->SupportedArchitectures(); - return {}; -} - /*}}}*/ // pkgSystem::Set/GetVersionMapping - for internal/external communication/*{{{*/ void pkgSystem::SetVersionMapping(map_id_t const in, map_id_t const out) { @@ -85,29 +69,4 @@ map_id_t pkgSystem::GetVersionMapping(map_id_t const in) const return (o == d->idmap.end()) ? in : o->second; } /*}}}*/ - -bool pkgSystem::LockInner() /*{{{*/ -{ - debSystem * const deb = dynamic_cast(this); - if (deb != NULL) - return deb->LockInner(); - return _error->Error("LockInner is not implemented"); -} - /*}}}*/ -bool pkgSystem::UnLockInner(bool NoErrors) /*{{{*/ -{ - debSystem * const deb = dynamic_cast(this); - if (deb != NULL) - return deb->UnLockInner(NoErrors); - return _error->Error("UnLockInner is not implemented"); -} - /*}}}*/ -bool pkgSystem::IsLocked() /*{{{*/ -{ - debSystem * const deb = dynamic_cast(this); - if (deb != NULL) - return deb->IsLocked(); - return true; -} - /*}}}*/ pkgSystem::~pkgSystem() {} diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h index 051b11ac2..1ccdcd1fb 100644 --- a/apt-pkg/pkgsystem.h +++ b/apt-pkg/pkgsystem.h @@ -100,7 +100,7 @@ class pkgSystem * * @return \b true if the system supports MultiArch, \b false if not. */ - bool MultiArchSupported() const; + virtual bool MultiArchSupported() const = 0; /** architectures supported by this system * * A MultiArch capable system might be configured to use @@ -109,7 +109,7 @@ class pkgSystem * @return a list of all architectures (native + foreign) configured * for on this system (aka: which can be installed without force) */ - std::vector ArchitecturesSupported() const; + virtual std::vector ArchitecturesSupported() const = 0; APT_HIDDEN void SetVersionMapping(map_id_t const in, map_id_t const out); APT_HIDDEN map_id_t GetVersionMapping(map_id_t const in) const; @@ -124,10 +124,10 @@ class pkgSystem * lock without releasing the overall outer lock, so that dpkg can run * correctly but no other APT instance can acquire the system lock. */ - bool LockInner(); - bool UnLockInner(bool NoErrors = false); + virtual bool LockInner() = 0; + virtual bool UnLockInner(bool NoErrors = false) = 0; /// checks if the system is currently locked - bool IsLocked(); + virtual bool IsLocked() = 0; private: pkgSystemPrivate * const d; }; -- cgit v1.2.3