diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-31 11:22:24 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-31 11:22:24 +0100 |
commit | 600268e36cdefa39c01d9a7be741d152d317c880 (patch) | |
tree | b4dd92b40e68ac0ef0d7936e2e6e562494d7db17 /apt-pkg | |
parent | c7ed2c0e34546e12a035e4c4c2f034a6ee765748 (diff) | |
parent | a13554816fac2ab7c5e876355f7b929790722b2c (diff) |
merged from lp:~mvo/apt/mvo
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 38 |
1 files changed, 36 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); |