summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-05-19 14:16:43 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-05-19 14:16:43 +0200
commit388f2962666a265709ad7c6e18902d49726b1f2c (patch)
tree153e9158101d6805f2580c8cd7484acba46bbe64
parent470a5c38519989313514ebaec6920aafee53d798 (diff)
remove invalid pkgcache.bin and rebuild it if possible
The next invocation of APT tried to load an outdated big (and possible io-cold) file just to end up rebuilding it (possibly only as non-root in memory again and again), so we remove it here and if we have a srcpkgcache we are going to rebuild, too.
-rw-r--r--apt-pkg/deb/dpkgpm.cc19
-rw-r--r--debian/changelog1
2 files changed, 19 insertions, 1 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index b37980b7e..a9d23ea67 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -14,8 +14,8 @@
#include <apt-pkg/depcache.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/strutl.h>
-#include <apti18n.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/cachefile.h>
#include <unistd.h>
#include <stdlib.h>
@@ -1269,6 +1269,23 @@ bool pkgDPkgPM::Go(int OutStatusFd)
if (RunScripts("DPkg::Post-Invoke") == false)
return false;
+ if (_config->FindB("Debug::pkgDPkgPM",false) == false)
+ {
+ std::string const oldpkgcache = _config->FindFile("Dir::cache::pkgcache");
+ if (oldpkgcache.empty() == false && RealFileExists(oldpkgcache) == true &&
+ unlink(oldpkgcache.c_str()) == 0)
+ {
+ std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+ if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
+ {
+ _error->PushToStack();
+ pkgCacheFile CacheFile;
+ CacheFile.BuildCaches(NULL, true);
+ _error->RevertToStack();
+ }
+ }
+ }
+
Cache.writeStateFile(NULL);
return true;
}
diff --git a/debian/changelog b/debian/changelog
index b64594c2c..7f52d844e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,7 @@ apt (0.8.14.2) UNRELEASED; urgency=low
- let VisitRProvides report if the calls were successful
* apt-pkg/deb/dpkgpm.cc:
- replace obsolete usleep with nanosleep
+ - remove invalid pkgcache.bin and rebuild it if possible
* debian/apt{,-utils}.symbols:
- update both experimental symbol-files to reflect 0.8.14 state
* debian/rules: