summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/deb/dpkgpm.cc38
-rw-r--r--debian/changelog5
2 files changed, 41 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 51e896a4a..8c63b0c9b 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -135,6 +135,33 @@ static void dpkgChrootDirectory()
}
/*}}}*/
+
+// FindNowVersion - Helper to find a Version in "now" state /*{{{*/
+// ---------------------------------------------------------------------
+/* This is helpful when a package is no longer installed but has residual
+ * config files
+ */
+static
+pkgCache::VerIterator FindNowVersion(const pkgCache::PkgIterator &Pkg)
+{
+ pkgCache::VerIterator Ver;
+ for (Ver = Pkg.VersionList(); Ver.end() == false; Ver++)
+ {
+ pkgCache::VerFileIterator Vf = Ver.FileList();
+ pkgCache::PkgFileIterator F = Vf.File();
+ for (F = Vf.File(); F.end() == false; F++)
+ {
+ if (F && F.Archive())
+ {
+ if (strcmp(F.Archive(), "now"))
+ return Ver;
+ }
+ }
+ }
+ return Ver;
+}
+ /*}}}*/
+
// DPkgPM::pkgDPkgPM - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -1107,11 +1134,18 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
pkgCache::VerIterator PkgVer;
std::string name = I->Pkg.Name();
- if (Op == Item::Remove || Op == Item::Purge)
+ if (Op == Item::Remove || Op == Item::Purge)
+ {
PkgVer = I->Pkg.CurrentVer();
+ if(PkgVer.end() == true)
+ PkgVer = FindNowVersion(I->Pkg);
+ }
else
PkgVer = Cache[I->Pkg].InstVerIter(Cache);
- name.append(":").append(PkgVer.Arch());
+ if (PkgVer.end() == false)
+ name.append(":").append(PkgVer.Arch());
+ else
+ _error->Warning("Can not find PkgVer for '%s'", name.c_str());
char * const fullname = strdup(name.c_str());
Packages.push_back(fullname);
ADDARG(fullname);
diff --git a/debian/changelog b/debian/changelog
index 988a0e41e..122c2ce36 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -27,6 +27,11 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
of them in a single iteration (Closes: #657695, LP: #922485)
- use a signed int instead of short for score calculation as upgrades
become so big now that it can overflow (Closes: #657732, LP: #917173)
+
+ [ Michael Vogt ]
+ * apt-pkg/deb/dpkgpm.cc:
+ - fix crash when a package is in removed but residual config state
+ (LP: #923807)
-- David Kalnischkies <kalnischkies@gmail.com> Mon, 30 Jan 2012 19:17:09 +0100