]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/dpkgpm.cc
* cmdline/apt-cache.cc:
[apt.git] / apt-pkg / deb / dpkgpm.cc
index 74f672dd95aa8c6072dd03283dc6f8f00cfa0c36..2e9dedefa481613df033677856f923ec1139823c 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/wait.h>
 #include <signal.h>
 #include <errno.h>
+#include <string.h>
 #include <stdio.h>
 #include <sstream>
 #include <map>
@@ -47,7 +48,7 @@ using namespace std;
 /* */
 pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) 
    : pkgPackageManager(Cache), dpkgbuf_pos(0),
-     term_out(NULL), PackagesDone(0), PackagesTotal(0)
+     term_out(NULL), PackagesDone(0), PackagesTotal(0), pkgFailures(0)
 {
 }
                                                                        /*}}}*/
@@ -341,7 +342,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
       'processing: trigproc: trigger'
            
    */
-   char* list[5];
+   char* list[6];
    //        dpkg sends multiline error messages sometimes (see
    //        #374195 for a example. we should support this by
    //        either patching dpkg to not send multiline over the
@@ -387,6 +388,14 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
 
    if(strncmp(action,"error",strlen("error")) == 0)
    {
+      // urgs, sometime has ":" in its error string so that we
+      // end up with the error message split between list[3]
+      // and list[4], e.g. the message: 
+      // "failed in buffer_write(fd) (10, ret=-1): backend dpkg-deb ..."
+      // concat them again
+      if( list[4] != NULL )
+        list[3][strlen(list[3])] = ':';
+
       status << "pmerror:" << list[1]
             << ":"  << (PackagesDone/float(PackagesTotal)*100.0) 
             << ":" << list[3]
@@ -498,7 +507,7 @@ bool pkgDPkgPM::OpenLog()
       struct tm *tmp = localtime(&t);
       strftime(outstr, sizeof(outstr), "%F  %T", tmp);
       fprintf(term_out, "\nLog started: ");
-      fprintf(term_out, outstr);
+      fprintf(term_out, "%s", outstr);
       fprintf(term_out, "\n");
    }
    return true;
@@ -513,7 +522,7 @@ bool pkgDPkgPM::CloseLog()
       struct tm *tmp = localtime(&t);
       strftime(outstr, sizeof(outstr), "%F  %T", tmp);
       fprintf(term_out, "Log ended: ");
-      fprintf(term_out, outstr);
+      fprintf(term_out, "%s", outstr);
       fprintf(term_out, "\n");
       fclose(term_out);
    }
@@ -556,6 +565,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 {
    unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024);   
    unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024);
+   bool NoTriggers = _config->FindB("DPkg::NoTriggers",false);
 
    if (RunScripts("DPkg::Pre-Invoke") == false)
       return false;
@@ -606,7 +616,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    PackageProcessingOps.insert( make_pair("install",N_("Installing %s")) );
    PackageProcessingOps.insert( make_pair("configure",N_("Configuring %s")) );
    PackageProcessingOps.insert( make_pair("remove",N_("Removing %s")) );
-   PackageProcessingOps.insert( make_pair("trigproc",N_("Triggering %s")) );
+   PackageProcessingOps.insert( make_pair("trigproc",N_("Running post-installation trigger %s")) );
    
    // init the PackageOps map, go over the list of packages that
    // that will be [installed|configured|removed|purged] and add
@@ -691,6 +701,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
         
         case Item::Configure:
         Args[n++] = "--configure";
+        if (NoTriggers)
+           Args[n++] = "--no-triggers";
         Size += strlen(Args[n-1]);
         break;
         
@@ -946,11 +958,30 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    FILE *report;
 
    if (_config->FindB("Dpkg::ApportFailureReport",true) == false)
+   {
+      std::clog << "configured to not write apport reports" << std::endl;
       return;
+   }
 
-   // only report the first error
+   // only report the first errors
    if(pkgFailures > _config->FindI("APT::Apport::MaxReports", 3))
+   {
+      std::clog << _("No apport report written because MaxReports is reached already") << std::endl;
       return;
+   }
+
+   // check if its not a follow up error 
+   const char *needle = dgettext("dpkg", "dependency problems - leaving unconfigured");
+   if(strstr(errormsg, needle) != NULL) {
+      std::clog << _("No apport report written because the error message indicates its a followup error from a previous failure.") << std::endl;
+      return;
+   }
+
+   // do not report disk-full failures 
+   if(strstr(errormsg, strerror(ENOSPC)) != NULL) {
+      std::clog << _("No apport report written because the error message indicates a disk full error") << std::endl;
+      return;
+   }
 
    // get the pkgname and reportfile
    pkgname = flNotDir(pkgpath);