]> git.saurik.com Git - apt.git/commitdiff
* merged from apt--mvo
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 6 Aug 2007 13:53:07 +0000 (15:53 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 6 Aug 2007 13:53:07 +0000 (15:53 +0200)
1  2 
apt-pkg/deb/dpkgpm.cc
configure.in

diff --combined apt-pkg/deb/dpkgpm.cc
index e9333600c807baf97244b7dd9443c55324d1feba,8eddc04ca8d01981aac9ee5ac76b65157534b3b7..a65f6eb0a08008f9e6c2af18b92a51fdf4cca066
@@@ -12,7 -12,6 +12,7 @@@
  #include <apt-pkg/error.h>
  #include <apt-pkg/configuration.h>
  #include <apt-pkg/depcache.h>
 +#include <apt-pkg/pkgrecords.h>
  #include <apt-pkg/strutl.h>
  #include <apti18n.h>
  
@@@ -45,8 -44,8 +45,8 @@@ using namespace std
  // ---------------------------------------------------------------------
  /* */
  pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) 
-    : pkgPackageManager(Cache), dpkgbuf_pos(0), 
-      PackagesTotal(0), PackagesDone(0), term_out(NULL)
+    : pkgPackageManager(Cache), dpkgbuf_pos(0), PackagesDone(0), 
+      PackagesTotal(0), term_out(NULL)
  {
  }
                                                                        /*}}}*/
@@@ -412,8 -411,6 +412,8 @@@ void pkgDPkgPM::ProcessDpkgStatusLine(i
         write(OutStatusFd, status.str().c_str(), status.str().size());
        if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
         std::clog << "send: '" << status.str() << "'" << endl;
 +      pkgFailures++;
 +      WriteApportReport(list[1], list[3]);
        return;
     }
     if(strncmp(action,"conffile",strlen("conffile")) == 0)
@@@ -819,7 -816,7 +819,7 @@@ bool pkgDPkgPM::Go(int OutStatusFd
            continue;
  
         if(master >= 0 && FD_ISSET(master, &rfds))
-           DoTerminalPty(master, term_out);
+           DoTerminalPty(master);
         if(master >= 0 && FD_ISSET(0, &rfds))
            DoStdin(master);
         if(FD_ISSET(_dpkgin, &rfds))
@@@ -876,115 -873,3 +876,115 @@@ void pkgDPkgPM::Reset(
     List.erase(List.begin(),List.end());
  }
                                                                        /*}}}*/
 +// pkgDpkgPM::WriteApportReport - write out error report pkg failure  /*{{{*/
 +// ---------------------------------------------------------------------
 +/* */
 +void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) 
 +{
 +   string pkgname, reportfile, srcpkgname, pkgver, arch;
 +   string::size_type pos;
 +   FILE *report;
 +
 +   if (_config->FindB("Dpkg::ApportFailureReport",true) == false)
 +      return;
 +
 +   // only report the first error if we are in StopOnError=false mode
 +   // to prevent bogus reports
 +   if((_config->FindB("Dpkg::StopOnError",true) == false) && pkgFailures > 1)
 +      return;
 +
 +   // get the pkgname and reportfile
 +   pkgname = flNotDir(pkgpath);
 +   pos = pkgname.rfind('_');
 +   if(pos != string::npos)
 +      pkgname = string(pkgname, 0, pos);
 +
 +   // find the package versin and source package name
 +   pkgCache::PkgIterator Pkg = Cache.FindPkg(pkgname);
 +   if (Pkg.end() == true)
 +      return;
 +   pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
 +   pkgver = Ver.VerStr();
 +   if (Ver.end() == true)
 +      return;
 +   pkgRecords Recs(Cache);
 +   pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
 +   srcpkgname = Parse.SourcePkg();
 +   if(srcpkgname.empty())
 +      srcpkgname = pkgname;
 +
 +   // if the file exists already, we check:
 +   // - if it was reported already (touched by apport). 
 +   //   If not, we do nothing, otherwise
 +   //    we overwrite it. This is the same behaviour as apport
 +   // - if we have a report with the same pkgversion already
 +   //   then we skip it
 +   reportfile = flCombine("/var/crash",pkgname+".0.crash");
 +   if(FileExists(reportfile))
 +   {
 +      struct stat buf;
 +      char strbuf[255];
 +
 +      // check atime/mtime
 +      stat(reportfile.c_str(), &buf);
 +      if(buf.st_mtime > buf.st_atime)
 +       return;
 +
 +      // check if the existing report is the same version
 +      report = fopen(reportfile.c_str(),"r");
 +      while(fgets(strbuf, sizeof(strbuf), report) != NULL)
 +      {
 +       if(strstr(strbuf,"Package:") == strbuf)
 +       {
 +          char pkgname[255], version[255];
 +          if(sscanf(strbuf, "Package: %s %s", pkgname, version) == 2)
 +             if(strcmp(pkgver.c_str(), version) == 0)
 +             {
 +                fclose(report);
 +                return;
 +             }
 +       }
 +      }
 +      fclose(report);
 +   }
 +
 +   // now write the report
 +   arch = _config->Find("APT::Architecture");
 +   report = fopen(reportfile.c_str(),"w");
 +   if(report == NULL)
 +      return;
 +   if(_config->FindB("DPkgPM::InitialReportOnly",false) == true)
 +      chmod(reportfile.c_str(), 0);
 +   else
 +      chmod(reportfile.c_str(), 0600);
 +   fprintf(report, "ProblemType: Package\n");
 +   fprintf(report, "Architecture: %s\n", arch.c_str());
 +   time_t now = time(NULL);
 +   fprintf(report, "Date: %s" , ctime(&now));
 +   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);
 +}
 +                                                                      /*}}}*/
diff --combined configure.in
index 364a23159881877babdabb95caf8719c73b2b46a,0294b9ae7b231a64096931bb6d4cf14bca614cca..b2f10baed3647eb902a784239d566416da1d2726
@@@ -18,7 -18,7 +18,7 @@@ AC_CONFIG_AUX_DIR(buildlib
  AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
  
  dnl -- SET THIS TO THE RELEASE VERSION --
- AC_DEFINE_UNQUOTED(VERSION,"0.7.6ubuntu1")
 -AC_DEFINE_UNQUOTED(VERSION,"0.7.5")
++AC_DEFINE_UNQUOTED(VERSION,"0.7.6ubuntu2")
  PACKAGE="apt"
  AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
  AC_SUBST(PACKAGE)