]> git.saurik.com Git - apt.git/commitdiff
- when writting apport reports, attach the dpkg
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 3 Aug 2007 16:43:46 +0000 (18:43 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 3 Aug 2007 16:43:46 +0000 (18:43 +0200)
    terminal log too

apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h
debian/changelog

index 08c95b7a4f9d9c7f5780639aa71126c69efa8334..6cb444ef12d3d461c210b736780dc9894d2fdd5f 100644 (file)
@@ -44,7 +44,8 @@ using namespace std;
 // ---------------------------------------------------------------------
 /* */
 pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) 
-   : pkgPackageManager(Cache), dpkgbuf_pos(0), PackagesTotal(0), PackagesDone(0)
+   : pkgPackageManager(Cache), dpkgbuf_pos(0), PackagesTotal(0), 
+     PackagesDone(0), term_out(NULL)
 {
 }
                                                                        /*}}}*/
@@ -351,7 +352,7 @@ void pkgDPkgPM::DoStdin(int master)
 /*
  * read the terminal pty and write log
  */
-void pkgDPkgPM::DoTerminalPty(int master, FILE *term_out)
+void pkgDPkgPM::DoTerminalPty(int master)
 {
    char term_buf[1024] = {0,};
 
@@ -569,7 +570,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       return _error->Error(_("Directory '%s' missing"), logdir.c_str());
    string logfile_name = flCombine(logdir,
                                   _config->Find("Dir::Log::Terminal"));
-   FILE *term_out = NULL;
    if (!logfile_name.empty())
    {
       term_out = fopen(logfile_name.c_str(),"a");
@@ -812,7 +812,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
            continue;
 
         if(FD_ISSET(master, &rfds))
-           DoTerminalPty(master, term_out);
+           DoTerminalPty(master);
         if(FD_ISSET(0, &rfds))
            DoStdin(master);
         if(FD_ISSET(_dpkgin, &rfds))
@@ -956,6 +956,27 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    fprintf(report, "Package: %s %s\n", pkgname.c_str(), pkgver.c_str());
    fprintf(report, "SourcePackage: %s\n", srcpkgname.c_str());
    fprintf(report, "ErrorMessage:\n %s\n", errormsg);
+
+   // ensure that the log is flushed
+   if(term_out)
+      fflush(term_out);
+
+   // attach terminal log it if we have it
+   string logfile_name = _config->FindFile("Dir::Log::Terminal");
+   if (!logfile_name.empty())
+   {
+      FILE *log = NULL;
+      char buf[1024];
+
+      fprintf(report, "DpkgTerminalLog:\n");
+      log = fopen(logfile_name.c_str(),"r");
+      if(log != NULL)
+      {
+        while( fgets(buf, sizeof(buf), log) != NULL)
+           fprintf(report, " %s", buf);
+        fclose(log);
+      }
+   }
    fclose(report);
 }
                                                                        /*}}}*/
index f8e9e44a8e59f48185b4c83a83b14f6a11b6e607..222add98f7c886f4c4d03bf497a0aacbbc9b8395 100644 (file)
@@ -26,7 +26,8 @@ class pkgDPkgPM : public pkgPackageManager
    // the buffer we use for the dpkg status-fd reading
    char dpkgbuf[1024];
    int dpkgbuf_pos;
-
+   FILE *term_out;
+   
    protected:
    int pkgFailures;
 
@@ -71,7 +72,7 @@ class pkgDPkgPM : public pkgPackageManager
 
    // input processing
    void DoStdin(int master);
-   void DoTerminalPty(int master, FILE *out);
+   void DoTerminalPty(int master);
    void DoDpkgStatusFd(int statusfd, int OutStatusFd);
    void ProcessDpkgStatusLine(int OutStatusFd, char *line);
 
index a2dafbaeaa0af45cab49ed77807c31b8e010c92a..1e951187577a9c429bb0760e0aed1bda97fc13ad 100644 (file)
@@ -14,6 +14,8 @@ apt (0.7.6ubuntu1) gutsy; urgency=low
     - merged dpkg-log branch, this lets you specify a 
       Dir::Log::Terminal file to log dpkg output to
     (ABI break)
+    - when writting apport reports, attach the dpkg
+      terminal log too
   * merged apt--sha256 branch to fully support the new
     sha256 checksums in the Packages and Release files
     (ABI break)