From 4c437a3fcf067541f9d3b5d6c9c738c8da71ad06 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Sep 2018 18:43:34 +0200 Subject: Don't expect duplicated dpkg status-fd messages The progress reporting relies on parsing the status reports of dpkg which used to repeat being in the same state multiple times in the same run, but by fixing #365921 it will stop doing so. The problem is in theory just with 'config-files' in case we do purge as this (can) do remove + purge in one step, but we remove this also for the unpack + configure combination althrough we handle these currently in two independent dpkg calls. --- apt-pkg/deb/dpkgpm.cc | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'apt-pkg/deb/dpkgpm.cc') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 01282efcc..474f61fde 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1131,16 +1131,14 @@ void pkgDPkgPM::BuildPackagesProgressMap() { // map the dpkg states to the operations that are performed // (this is sorted in the same way as Item::Ops) - static const std::array, 4> DpkgStatesOpMap = {{ + static const std::array, 4> DpkgStatesOpMap = {{ // Install operation {{ {"half-installed", N_("Preparing %s")}, {"unpacked", N_("Unpacking %s") }, - {nullptr, nullptr} }}, // Configure operation {{ - {"unpacked",N_("Preparing to configure %s") }, {"half-configured", N_("Configuring %s") }, { "installed", N_("Installed %s")}, }}, @@ -1148,13 +1146,11 @@ void pkgDPkgPM::BuildPackagesProgressMap() {{ {"half-configured", N_("Preparing for removal of %s")}, {"half-installed", N_("Removing %s")}, - {"config-files", N_("Removed %s")}, }}, // Purge operation {{ {"config-files", N_("Preparing to completely remove %s")}, {"not-installed", N_("Completely removed %s")}, - {nullptr, nullptr} }}, }}; static_assert(Item::Purge == 3, "Enum item has unexpected index for mapping array"); @@ -1170,21 +1166,16 @@ void pkgDPkgPM::BuildPackagesProgressMap() string const name = I.Pkg.FullName(); PackageOpsDone[name] = 0; - auto AddToPackageOps = std::back_inserter(PackageOps[name]); - if (I.Op == Item::Purge && I.Pkg->CurrentVer != 0) - { - // purging a package which is installed first passes through remove states - auto const DpkgOps = DpkgStatesOpMap[Item::Remove]; - std::copy(DpkgOps.begin(), DpkgOps.end(), AddToPackageOps); + auto AddToPackageOps = [&](decltype(I.Op) const Op) { + auto const DpkgOps = DpkgStatesOpMap[Op]; + std::copy(DpkgOps.begin(), DpkgOps.end(), std::back_inserter(PackageOps[name])); PackagesTotal += DpkgOps.size(); - } - auto const DpkgOps = DpkgStatesOpMap[I.Op]; - std::copy_if(DpkgOps.begin(), DpkgOps.end(), AddToPackageOps, [&](DpkgState const &state) { - if (state.state == nullptr) - return false; - ++PackagesTotal; - return true; - }); + }; + // purging a package which is installed first passes through remove states + if (I.Op == Item::Purge && I.Pkg->CurrentVer != 0) + AddToPackageOps(Item::Remove); + AddToPackageOps(I.Op); + if ((I.Op == Item::Remove || I.Op == Item::Purge) && I.Pkg->CurrentVer != 0) { if (I.Pkg->CurrentState == pkgCache::State::UnPacked || @@ -1610,9 +1601,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) approvedStates.Remove(*Ver); Purges.erase(Ver); auto && RemOp = PackageOps[C.first->Pkg.FullName()]; - if (RemOp.size() == 5) + if (RemOp.size() == 4) { - RemOp.erase(std::next(RemOp.begin(), 3), RemOp.end()); + RemOp.erase(std::next(RemOp.begin(), 2), RemOp.end()); PackagesTotal -= 2; } else -- cgit v1.2.3