]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/dpkgpm.cc
merged from the debian-sid branch
[apt.git] / apt-pkg / deb / dpkgpm.cc
index 01808be243b3cfef5329c86aec9d27aba43d70c0..e957ce5fd14f32f90d9af9ca6044d0bdf5f41917 100644 (file)
@@ -1289,7 +1289,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    string::size_type pos;
    FILE *report;
 
-   if (_config->FindB("Dpkg::ApportFailureReport", false) == false)
+   if (_config->FindB("Dpkg::ApportFailureReport", true) == false)
    {
       std::clog << "configured to not write apport reports" << std::endl;
       return;
@@ -1316,16 +1316,28 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    }
 
    // do not report out-of-memory failures 
-   if(strstr(errormsg, strerror(ENOMEM)) != NULL) {
+   if(strstr(errormsg, strerror(ENOMEM)) != NULL ||
+      strstr(errormsg, "Cannot allocate memory") != NULL) {
       std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl;
       return;
    }
 
-   // do not report dpkg I/O errors
-   // XXX - this message is localized, but this only matches the English version.  This is better than nothing.
-   if(strstr(errormsg, "short read in buffer_copy (")) {
-      std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
-      return;
+   // do not report dpkg I/O errors, this is a format string, so we compare
+   // the prefix and the suffix of the error with the dpkg error message
+   const char *short_read_error = dgettext("dpkg", "short read in buffer_copy %s");
+   vector<string> list = VectorizeString(short_read_error, '%');
+   if (list.size() > 1) 
+   {
+      // we need to split %s, VectorizeString only allows char so we need
+      // to kill the "s" manually
+      if (list[1].size() > 1) {
+         list[1].erase(0, 1);
+         if(strstr(errormsg, list[0].c_str()) && 
+            strstr(errormsg, list[1].c_str())) {
+            std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
+            return;
+         }
+      }
    }
 
    // get the pkgname and reportfile