summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc49
-rw-r--r--apt-pkg/deb/dpkgpm.h9
2 files changed, 32 insertions, 26 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index d14155d01..4a49774f8 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1297,37 +1297,34 @@ static void cleanUpTmpDir(char * const tmpdir) /*{{{*/
* through to human readable (and i10n-able)
* names and calculates a percentage for each step.
*/
-bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
+static bool ItemIsEssential(pkgDPkgPM::Item const &I)
+{
+ static auto const cachegen = _config->Find("pkgCacheGen::Essential");
+ if (cachegen == "none" || cachegen == "native")
+ return true;
+ if (unlikely(I.Pkg.end()))
+ return true;
+ return (I.Pkg->Flags & pkgCache::Flag::Essential) != 0;
+}
+bool pkgDPkgPM::ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache)
{
- // we remove the last configures (and after that removes) from the list here
- // as they will be covered by the pending calls, so explicit calls are busy work
- decltype(List)::const_iterator::difference_type explicitIdx =
- std::distance(List.cbegin(),
- _config->FindB("Dpkg::ExplicitLastConfigure", false) ? List.cend() :
- std::find_if_not(
- std::find_if_not(List.crbegin(), List.crend(), [](Item const &i) { return i.Op == Item::Configure; }),
- List.crend(), [](Item const &i) { return i.Op == Item::Remove || i.Op == Item::Purge; }).base());
-
- // explicitely remove everything for hookscripts and progress building
{
std::unordered_set<decltype(pkgCache::Package::ID)> alreadyRemoved;
for (auto && I : List)
if (I.Op == Item::Remove || I.Op == Item::Purge)
alreadyRemoved.insert(I.Pkg->ID);
- decltype(List) AppendList;
+ std::remove_reference<decltype(List)>::type AppendList;
for (auto Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
if (Cache[Pkg].Delete() && alreadyRemoved.insert(Pkg->ID).second == true)
AppendList.emplace_back(Cache[Pkg].Purge() ? Item::Purge : Item::Remove, Pkg);
std::move(AppendList.begin(), AppendList.end(), std::back_inserter(List));
}
-
- // explicitely configure everything for hookscripts and progress building
{
std::unordered_set<decltype(pkgCache::Package::ID)> alreadyConfigured;
for (auto && I : List)
if (I.Op == Item::Configure)
alreadyConfigured.insert(I.Pkg->ID);
- decltype(List) AppendList;
+ std::remove_reference<decltype(List)>::type AppendList;
for (auto && I : List)
if (I.Op == Item::Install && alreadyConfigured.insert(I.Pkg->ID).second == true)
AppendList.emplace_back(Item::Configure, I.Pkg);
@@ -1336,15 +1333,21 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
AppendList.emplace_back(Item::Configure, Pkg);
std::move(AppendList.begin(), AppendList.end(), std::back_inserter(List));
}
+ return true;
+}
+bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
+{
+ // we remove the last configures (and after that removes) from the list here
+ // as they will be covered by the pending calls, so explicit calls are busy work
+ decltype(List)::const_iterator::difference_type explicitIdx =
+ std::distance(List.cbegin(),
+ _config->FindB("Dpkg::ExplicitLastConfigure", false) ? List.cend() :
+ std::find_if_not(
+ std::find_if_not(List.crbegin(), List.crend(), [](Item const &i) { return i.Op == Item::Configure; }),
+ List.crend(), [](Item const &i) { return i.Op == Item::Remove || i.Op == Item::Purge; }).base());
- auto const ItemIsEssential = [](pkgDPkgPM::Item const &I) {
- static auto const cachegen = _config->Find("pkgCacheGen::Essential");
- if (cachegen == "none" || cachegen == "native")
- return true;
- if (unlikely(I.Pkg.end()))
- return true;
- return (I.Pkg->Flags & pkgCache::Flag::Essential) != 0;
- };
+ // explicitely remove&configure everything for hookscripts and progress building
+ ExpandPendingCalls(List, Cache);
auto const StripAlreadyDoneFromPending = [&](APT::VersionVector & Pending) {
Pending.erase(std::remove_if(Pending.begin(), Pending.end(), [&](pkgCache::VerIterator const &Ver) {
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<Item> 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<Item> &List, pkgDepCache &Cache);
};
void SigINT(int sig);