From 1d52ce01e449db043e0c8343e838cb686ed6250e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 5 Oct 2006 13:41:09 +0200 Subject: * merged i18n fixes from apt--mvo --- apt-pkg/deb/dpkgpm.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 93dff390d..f66962387 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -355,28 +355,28 @@ bool pkgDPkgPM::Go(int OutStatusFd) static const struct DpkgState DpkgStatesOpMap[][5] = { // Install operation { - {"half-installed", _("Preparing %s")}, - {"unpacked", _("Unpacking %s") }, + {"half-installed", N_("Preparing %s")}, + {"unpacked", N_("Unpacking %s") }, {NULL, NULL} }, // Configure operation { - {"unpacked",_("Preparing to configure %s") }, - {"half-configured", _("Configuring %s") }, - { "installed", _("Installed %s")}, + {"unpacked",N_("Preparing to configure %s") }, + {"half-configured", N_("Configuring %s") }, + { "installed", N_("Installed %s")}, {NULL, NULL} }, // Remove operation { - {"half-configured", _("Preparing for removal of %s")}, - {"half-installed", _("Removing %s")}, - {"config-files", _("Removed %s")}, + {"half-configured", N_("Preparing for removal of %s")}, + {"half-installed", N_("Removing %s")}, + {"config-files", N_("Removed %s")}, {NULL, NULL} }, // Purge operation { - {"config-files", _("Preparing to completely remove %s")}, - {"not-installed", _("Completely removed %s")}, + {"config-files", N_("Preparing to completely remove %s")}, + {"not-installed", N_("Completely removed %s")}, {NULL, NULL} }, }; @@ -672,7 +672,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) { // only read the translation if there is actually a next // action - const char *translation = states[PackageOpsDone[pkg]].str; + const char *translation = _(states[PackageOpsDone[pkg]].str); char s[200]; snprintf(s, sizeof(s), translation, pkg); -- cgit v1.2.3 From 5e457a9336967e4851e094a84f9f94f4141ee393 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 5 Jun 2007 16:14:08 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - apport integration added, this means that a apport report is written on dpkg failures --- apt-pkg/deb/dpkgpm.cc | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++- apt-pkg/deb/dpkgpm.h | 4 +++ 2 files changed, 100 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index cebdafe7d..5c069458e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,8 @@ using namespace std; // DPkgPM::pkgDPkgPM - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) : pkgPackageManager(Cache) +pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) + : pkgPackageManager(Cache), pkgFailures(0) { } /*}}}*/ @@ -654,6 +656,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) line[0]=0; if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true) std::clog << "send: '" << status.str() << "'" << endl; + pkgFailures++; + WriteApportReport(list[1], list[3]); continue; } if(strncmp(action,"conffile",strlen("conffile")) == 0) @@ -746,3 +750,94 @@ 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); + fclose(report); +} + /*}}}*/ diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 0b181dc43..1a1fdc191 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -23,6 +23,7 @@ using std::vector; class pkgDPkgPM : public pkgPackageManager { protected: + int pkgFailures; // used for progress reporting struct DpkgState @@ -48,6 +49,9 @@ class pkgDPkgPM : public pkgPackageManager bool RunScriptsWithPkgs(const char *Cnf); bool SendV2Pkgs(FILE *F); + // apport integration + void WriteApportReport(const char *pkgpath, const char *errormsg); + // The Actuall installation implementation virtual bool Install(PkgIterator Pkg,string File); virtual bool Configure(PkgIterator Pkg); -- cgit v1.2.3 From b3aac1bb35d4f8e11ffc45462f450632de9a571f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Aug 2007 15:01:18 +0200 Subject: * debian/changelog: updated credits * apt-pkg/deb/dpkgpm.cc: merged from dpkg-log branch --- apt-pkg/deb/dpkgpm.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index befd9124c..08c95b7a4 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -846,12 +846,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) if(stopOnError) { - fclose(term_out); + if(term_out) + fclose(term_out); return false; } } } - fclose(term_out); + if(term_out) + fclose(term_out); if (RunScripts("DPkg::Post-Invoke") == false) return false; -- cgit v1.2.3 From 8ecd1fedeace0e22f96259e250094006c673d065 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Aug 2007 18:43:46 +0200 Subject: - when writting apport reports, attach the dpkg terminal log too --- apt-pkg/deb/dpkgpm.cc | 29 +++++++++++++++++++++++++---- apt-pkg/deb/dpkgpm.h | 5 +++-- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 08c95b7a4..6cb444ef1 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -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); } /*}}}*/ diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index f8e9e44a8..222add98f 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -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); -- cgit v1.2.3 From 25ffa4e814c5e8cceae339476787291d3ee584cf Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Aug 2007 16:48:55 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - fix packagename extraction when writting apport reports --- apt-pkg/deb/dpkgpm.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index a65f6eb0a..dad8da9ed 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -895,9 +895,9 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) // get the pkgname and reportfile pkgname = flNotDir(pkgpath); - pos = pkgname.rfind('_'); + pos = pkgname.find('_'); if(pos != string::npos) - pkgname = string(pkgname, 0, pos); + pkgname = pkgname.substr(0, pos); // find the package versin and source package name pkgCache::PkgIterator Pkg = Cache.FindPkg(pkgname); -- cgit v1.2.3 From fb7bf91ccc01c6fa16ea2eb2b714d5a1b808c1ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 16 Aug 2007 01:10:35 +0100 Subject: dpkg-triggers: deal properly with new package states; 0.7.6ubuntu6 --- apt-pkg/deb/deblistparser.cc | 2 ++ apt-pkg/deb/dpkgpm.cc | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 074abea6d..896d4d6d8 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -293,6 +293,8 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg, {"installed",pkgCache::State::Installed}, {"half-installed",pkgCache::State::HalfInstalled}, {"config-files",pkgCache::State::ConfigFiles}, + {"triggers-awaited",pkgCache::State::TriggersAwaited}, + {"triggers-pending",pkgCache::State::TriggersPending}, {"post-inst-failed",pkgCache::State::HalfConfigured}, {"removal-failed",pkgCache::State::HalfInstalled}, {}}; diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index dad8da9ed..c386e4b24 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -521,7 +521,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // map the dpkg states to the operations that are performed // (this is sorted in the same way as Item::Ops) - static const struct DpkgState DpkgStatesOpMap[][5] = { + static const struct DpkgState DpkgStatesOpMap[][7] = { // Install operation { {"half-installed", N_("Preparing %s")}, @@ -532,12 +532,17 @@ bool pkgDPkgPM::Go(int OutStatusFd) { {"unpacked",N_("Preparing to configure %s") }, {"half-configured", N_("Configuring %s") }, + {"triggers-awaited", N_("Processing triggers for %s") }, + {"triggers-pending", N_("Processing triggers for %s") }, + {"half-configured", N_("Configuring %s") }, { "installed", N_("Installed %s")}, {NULL, NULL} }, // Remove operation { {"half-configured", N_("Preparing for removal of %s")}, + {"triggers-awaited", N_("Preparing for removal of %s")}, + {"triggers-pending", N_("Preparing for removal of %s")}, {"half-installed", N_("Removing %s")}, {"config-files", N_("Removed %s")}, {NULL, NULL} -- cgit v1.2.3 From 5d053270a275d1c825c793151f50bf3b680f55ec Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 Sep 2007 15:10:55 +0200 Subject: * apt-pkg/deb/dpkgpm.{cc,h}: - fix bug in dpkg log writing when a signal is caught during select() (LP: #134858) - write end marker in the log as well --- apt-pkg/deb/dpkgpm.cc | 78 ++++++++++++++++++++++++++++++++++----------------- apt-pkg/deb/dpkgpm.h | 4 +++ 2 files changed, 56 insertions(+), 26 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c386e4b24..90ae413f4 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -498,6 +498,46 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd) } /*}}}*/ +bool pkgDPkgPM::OpenLog() +{ + string logdir = _config->FindDir("Dir::Log"); + if(not FileExists(logdir)) + return _error->Error(_("Directory '%s' missing"), logdir.c_str()); + string logfile_name = flCombine(logdir, + _config->Find("Dir::Log::Terminal")); + if (!logfile_name.empty()) + { + term_out = fopen(logfile_name.c_str(),"a"); + chmod(logfile_name.c_str(), 0600); + // output current time + char outstr[200]; + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + strftime(outstr, sizeof(outstr), "%F %T", tmp); + fprintf(term_out, "\nLog started: "); + fprintf(term_out, outstr); + fprintf(term_out, "\n"); + } + return true; +} + +bool pkgDPkgPM::CloseLog() +{ + if(term_out) + { + char outstr[200]; + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + strftime(outstr, sizeof(outstr), "%F %T", tmp); + fprintf(term_out, "Log ended: "); + fprintf(term_out, outstr); + fprintf(term_out, "\n"); + fclose(term_out); + } + term_out = NULL; + return true; +} + // DPkgPM::Go - Run the sequence /*{{{*/ // --------------------------------------------------------------------- @@ -571,24 +611,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) } // create log - string logdir = _config->FindDir("Dir::Log"); - if(not FileExists(logdir)) - return _error->Error(_("Directory '%s' missing"), logdir.c_str()); - string logfile_name = flCombine(logdir, - _config->Find("Dir::Log::Terminal")); - if (!logfile_name.empty()) - { - term_out = fopen(logfile_name.c_str(),"a"); - chmod(logfile_name.c_str(), 0600); - // output current time - char outstr[200]; - time_t t = time(NULL); - struct tm *tmp = localtime(&t); - strftime(outstr, sizeof(outstr), "%F %T", tmp); - fprintf(term_out, "\nLog started: "); - fprintf(term_out, outstr); - fprintf(term_out, "\n"); - } + OpenLog(); // this loop is runs once per operation for (vector::iterator I = List.begin(); I != List.end();) @@ -818,10 +841,15 @@ bool pkgDPkgPM::Go(int OutStatusFd) tv.tv_sec = 1; tv.tv_usec = 0; select_ret = select(max(master, _dpkgin)+1, &rfds, NULL, NULL, &tv); - if (select_ret < 0) - std::cerr << "Error in select()" << std::endl; - else if (select_ret == 0) - continue; + if (select_ret == 0) + continue; + else if (select_ret < 0 && errno == EINTR) + continue; + else if (select_ret < 0) + { + perror("select() returned error"); + continue; + } if(master >= 0 && FD_ISSET(master, &rfds)) DoTerminalPty(master); @@ -859,14 +887,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) if(stopOnError) { - if(term_out) - fclose(term_out); + CloseLog(); return false; } } } - if(term_out) - fclose(term_out); + CloseLog(); if (RunScripts("DPkg::Post-Invoke") == false) return false; diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index debde36a3..e5f197405 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -70,6 +70,10 @@ class pkgDPkgPM : public pkgPackageManager // apport integration void WriteApportReport(const char *pkgpath, const char *errormsg); + // dpkg log + bool OpenLog(); + bool CloseLog(); + // input processing void DoStdin(int master); void DoTerminalPty(int master); -- cgit v1.2.3 From a44aeb52f0476ed56feff82b1cfd2fa84e7a1223 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 10 Sep 2007 15:09:28 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - fix progress reporting precent calculation (LP: #137798) --- apt-pkg/deb/dpkgpm.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 90ae413f4..8b4e6701a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -572,17 +572,20 @@ bool pkgDPkgPM::Go(int OutStatusFd) { {"unpacked",N_("Preparing to configure %s") }, {"half-configured", N_("Configuring %s") }, +#if 0 {"triggers-awaited", N_("Processing triggers for %s") }, {"triggers-pending", N_("Processing triggers for %s") }, - {"half-configured", N_("Configuring %s") }, +#endif { "installed", N_("Installed %s")}, {NULL, NULL} }, // Remove operation { {"half-configured", N_("Preparing for removal of %s")}, +#if 0 {"triggers-awaited", N_("Preparing for removal of %s")}, {"triggers-pending", N_("Preparing for removal of %s")}, +#endif {"half-installed", N_("Removing %s")}, {"config-files", N_("Removed %s")}, {NULL, NULL} -- cgit v1.2.3 From a60beec6cffa558221d845a05db63bdfff101e5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 3 Oct 2007 02:19:54 +0200 Subject: * apt-pkg/deb/debmetaindex.cc: comparison with string literal results in unspecified behaviour; --- apt-pkg/deb/debmetaindex.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 94995798f..c700f8d58 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -224,7 +224,7 @@ class debSLTypeDebian : public pkgSourceList::Type // This check insures that there will be only one Release file // queued for all the Packages files and Sources files it // corresponds to. - if ((*I)->GetType() == "deb") + if (strcmp((*I)->GetType(), "deb") == 0) { debReleaseIndex *Deb = (debReleaseIndex *) (*I); // This check insures that there will be only one Release file -- cgit v1.2.3 From 986d97bb0d62d7529a6a0328c39ddbd47be879a1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 4 Oct 2007 19:35:59 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - fix crash in WriteApportReport (LP: #144537) --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e1e26e903..466d3628b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -938,9 +938,9 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) if (Pkg.end() == true) return; pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg); - pkgver = Ver.VerStr(); if (Ver.end() == true) return; + pkgver = Ver.VerStr() == NULL ? "unknown" : Ver.VerStr(); pkgRecords Recs(Cache); pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList()); srcpkgname = Parse.SourcePkg(); -- cgit v1.2.3 From c771f6d9c30f94e37050af49e887f20767822dbb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Oct 2007 21:08:06 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - fix resource leak (LP: #148806) --- apt-pkg/deb/dpkgpm.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 466d3628b..ff0a3c443 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -867,8 +867,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); - if(master >= 0 && slave >= 0) + if(master >= 0) + { tcsetattr(0, TCSAFLUSH, &tt); + close(master); + } // Check for an error code. if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0) -- cgit v1.2.3 From 1fc825bf7be1e9842a0560261d684264c565589e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 24 Oct 2007 15:08:08 +0200 Subject: * apt-pkg/deb/dpkgpm.{cc,h}: - give up timeslice on EIO error in read from master terminal * apt-pkg/deb/dpkgpm.{cc,h}: - rewrite dpkgpm.cc to use pselect() instead of select() to block signals during select() (LP: #134858) --- apt-pkg/deb/dpkgpm.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ff0a3c443..7a6b222f6 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -358,7 +358,15 @@ void pkgDPkgPM::DoTerminalPty(int master) char term_buf[1024] = {0,}; int len=read(master, term_buf, sizeof(term_buf)); - if(len <= 0) + if(len == -1 && errno == EIO) + { + // this happens when the child is about to exit, we + // give it time to actually exit, otherwise we run + // into a race + usleep(500000); + return; + } + if(len <= 0) return; write(1, term_buf, len); if(term_out) @@ -819,7 +827,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) // setups fds fd_set rfds; - struct timeval tv; + struct timespec tv; + sigset_t sigmask; + sigset_t original_sigmask; + sigemptyset(&sigmask); + sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); + int select_ret; while ((res=waitpid(Child,&Status, WNOHANG)) != Child) { if(res < 0) { @@ -842,8 +855,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) if(master >= 0) FD_SET(master, &rfds); tv.tv_sec = 1; - tv.tv_usec = 0; - select_ret = select(max(master, _dpkgin)+1, &rfds, NULL, NULL, &tv); + tv.tv_nsec = 0; + select_ret = pselect(max(master, _dpkgin)+1, &rfds, NULL, NULL, + &tv, &original_sigmask); if (select_ret == 0) continue; else if (select_ret < 0 && errno == EINTR) -- cgit v1.2.3 From 5273f1bf4da222c54e7abe9f3c6482496f8e09fd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 1 Feb 2008 15:46:07 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - add APT::Apport::MaxReports to limit the maximum number of reports generated in a single run (default to 3) --- apt-pkg/deb/dpkgpm.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8123a7aba..5ed6482fa 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -906,9 +906,8 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) 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) + // only report the first error + if(pkgFailures > _config->FindI("APT::Apport::MaxReports", 3)) return; // get the pkgname and reportfile -- cgit v1.2.3 From ff38d63b19c0be1fb4be9a692fed2702d935d5e5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 5 Aug 2008 10:09:42 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - fix uninitialized variable that caused no apport reports to be written sometimes (thanks to Matt Zimmerman) --- apt-pkg/deb/dpkgpm.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 74f672dd9..ede1673bc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -47,7 +47,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) { } /*}}}*/ @@ -946,11 +946,17 @@ 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 if(pkgFailures > _config->FindI("APT::Apport::MaxReports", 3)) + { + std::clog << _("No apport report written because MaxReports is reached already") << std::endl; return; + } // get the pkgname and reportfile pkgname = flNotDir(pkgpath); -- cgit v1.2.3 From d6a4afcb1b937e07aaf186346f064833f65acfbd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 11 Aug 2008 18:21:37 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - improve the filtering for duplicated apport reports (thanks to seb128 for pointing that problem out) --- apt-pkg/deb/dpkgpm.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e1b3c6bc0..08291854f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -387,6 +387,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[4][-1] = ':'; + status << "pmerror:" << list[1] << ":" << (PackagesDone/float(PackagesTotal)*100.0) << ":" << list[3] @@ -954,13 +962,20 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) 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; + } + // get the pkgname and reportfile pkgname = flNotDir(pkgpath); pos = pkgname.find('_'); -- cgit v1.2.3 From 5279f566ec5bba9f5003440ecc575dc4d32b756b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 11 Aug 2008 19:40:57 +0200 Subject: support a ":" in the dpkg error output --- apt-pkg/deb/dpkgpm.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 08291854f..8c353a9d9 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -341,7 +341,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 @@ -390,10 +390,10 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line) // 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 ... + // "failed in buffer_write(fd) (10, ret=-1): backend dpkg-deb ..." // concat them again - if( list[4] != NULL) - list[4][-1] = ':'; + if( list[4] != NULL ) + list[3][strlen(list[3])] = ':'; status << "pmerror:" << list[1] << ":" << (PackagesDone/float(PackagesTotal)*100.0) -- cgit v1.2.3 From 2f0d5deabcd1d75400d302bdbb330184d4fe97ba Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 11 Aug 2008 19:44:23 +0200 Subject: do not report disk full errors from dpkg via apport --- apt-pkg/deb/dpkgpm.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8c353a9d9..2e9dedefa 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -976,6 +977,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) 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); pos = pkgname.find('_'); -- cgit v1.2.3 From 07dd557b6fd80ce2df235f1697189b6a8f190ff4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 24 Nov 2008 10:44:46 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - fix potential hang when in a backgroud process group --- apt-pkg/deb/dpkgpm.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 2e9dedefa..a88e23081 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -563,6 +563,11 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, */ bool pkgDPkgPM::Go(int OutStatusFd) { + fd_set rfds; + struct timespec tv; + sigset_t sigmask; + sigset_t original_sigmask; + 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); @@ -777,7 +782,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) rtt = tt; cfmakeraw(&rtt); rtt.c_lflag &= ~ECHO; + // block SIGTTOU during tcsetattr to prevent a hang if + // the process is a member of the background process group + // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGTTOU); + sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask); tcsetattr(0, TCSAFLUSH, &rtt); + sigprocmask(SIG_SETMASK, &original_sigmask, 0); } // Fork dpkg @@ -844,10 +856,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) close(slave); // setups fds - fd_set rfds; - struct timespec tv; - sigset_t sigmask; - sigset_t original_sigmask; sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); -- cgit v1.2.3 From 3024a85e0ce1b732338cdb23c86a2111a9846c38 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Nov 2008 11:19:11 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - filter "ENOMEM" errors when creating apport reports --- apt-pkg/deb/dpkgpm.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ae99e4324..a54c20330 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1027,6 +1027,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) return; } + // do not report out-of-memory failures + if(strstr(errormsg, strerror(ENOMEM)) != NULL) { + std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl; + return; + } + // get the pkgname and reportfile pkgname = flNotDir(pkgpath); pos = pkgname.find('_'); -- cgit v1.2.3 From ed3524975b9e07d3555509294ba13b81bff3c187 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Nov 2008 17:38:31 +0100 Subject: * /apt-pkg/deb/debsystem.cc: - add 'sudo' to the error message to "run 'dpkg --configure -a'" (LP: #52697) --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 11a84f1c6..7fa98f29d 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -79,7 +79,7 @@ bool debSystem::Lock() close(LockFD); LockFD = -1; return _error->Error("dpkg was interrupted, you must manually " - "run 'dpkg --configure -a' to correct the problem. "); + "run 'sudo dpkg --configure -a' to correct the problem. "); } LockCount++; -- cgit v1.2.3 From 12ede3486283262ee8c50506cf96dd2b266d713c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Nov 2008 19:50:49 +0100 Subject: make dpkg string translatable --- apt-pkg/deb/debsystem.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 7fa98f29d..f2340a4ad 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -78,8 +78,8 @@ bool debSystem::Lock() { close(LockFD); LockFD = -1; - return _error->Error("dpkg was interrupted, you must manually " - "run 'sudo dpkg --configure -a' to correct the problem. "); + return _error->Error(_("dpkg was interrupted, you must manually " + "run 'sudo dpkg --configure -a' to correct the problem. ")); } LockCount++; -- cgit v1.2.3 From bb3ac2f648764e7ee2a8cdc7739d56de6311c88f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Dec 2008 10:50:59 -0800 Subject: apt-pkg/deb/debsystem.cc: add missing apti18n.h header --- apt-pkg/deb/debsystem.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index f2340a4ad..e1aacdbdb 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 236527f0fffe30fc8988e17d926778c23ac1f902 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Jan 2009 17:39:37 +0100 Subject: LP: #263089 --- apt-pkg/deb/debsystem.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index e1aacdbdb..ee2039c75 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -18,7 +18,7 @@ #include #include #include - + #include #include #include @@ -67,11 +67,11 @@ bool debSystem::Lock() if (LockFD == -1) { if (errno == EACCES || errno == EAGAIN) - return _error->Error("Unable to lock the administration directory (%s), " - "is another process using it?",AdminDir.c_str()); + return _error->Error(_("Unable to lock the administration directory (%s), " + "is another process using it?"),AdminDir.c_str()); else - return _error->Error("Unable to lock the administration directory (%s), " - "are you root?",AdminDir.c_str()); + return _error->Error(_("Unable to lock the administration directory (%s), " + "are you root?"),AdminDir.c_str()); } // See if we need to abort with a dirty journal -- cgit v1.2.3 From d043faa8dfcfa4c432558f3f1b4ec149e33f9d8e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Jan 2009 17:40:42 +0100 Subject: merged from the mvo branch --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index ee2039c75..186918d25 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -97,7 +97,7 @@ bool debSystem::UnLock(bool NoErrors) return false; if (LockCount < 1) - return _error->Error("Not locked"); + return _error->Error(_("Not locked")); if (--LockCount == 0) { close(LockFD); -- cgit v1.2.3 From 494c293c524e66bdbed117954db9d0bff38c82b4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 6 Mar 2009 10:15:28 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - revert termios patch (LP: #338514) --- apt-pkg/deb/dpkgpm.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index a54c20330..d8c38427f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -793,16 +793,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); struct termios tt; - struct termios tt_out; struct winsize win; int master; int slave; // FIXME: setup sensible signal handling (*ick*) tcgetattr(0, &tt); - tcgetattr(1, &tt_out); ioctl(0, TIOCGWINSZ, (char *)&win); - if (openpty(&master, &slave, NULL, &tt_out, &win) < 0) + if (openpty(&master, &slave, NULL, &tt, &win) < 0) { const char *s = _("Can not write log, openpty() " "failed (/dev/pts not mounted?)\n"); -- cgit v1.2.3 From 76dbdfc7f02096758f63bcb6d306b54d5a2d0d02 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Apr 2009 19:53:19 +0200 Subject: * fix problematic use of tolower() when calculating the version hash by using locale independant tolower_ascii() function. Thanks to M. Vefa Bicakci (LP: #80248) * build fixes for g++-4.4 * include dmesg output in apport package failures --- apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 896d4d6d8..55ba1f8c4 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -213,7 +213,7 @@ unsigned short debListParser::VersionHash() for (; Start != End; Start++) { if (isspace(*Start) == 0) - *I++ = tolower(*Start); + *I++ = tolower_ascii(*Start); if (*Start == '<' && Start[1] != '<' && Start[1] != '=') *I++ = '='; if (*Start == '>' && Start[1] != '>' && Start[1] != '=') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d8c38427f..f57bff32c 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1123,6 +1123,23 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) fclose(log); } } + + // attach dmesg log (to learn about segfaults) + if (FileExists("/bin/dmesg")) + { + FILE *log = NULL; + char buf[1024]; + + fprintf(report, "Dmesg:\n"); + log = popen("/bin/dmesg","r"); + if(log != NULL) + { + while( fgets(buf, sizeof(buf), log) != NULL) + fprintf(report, " %s", buf); + fclose(log); + } + } fclose(report); + } /*}}}*/ -- cgit v1.2.3 From 5c8a2aa8d5fa2f5e3342e9abd2b750f1615a226a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 28 Apr 2009 16:55:10 +0200 Subject: include apt ordering into apport package failures --- apt-pkg/deb/dpkgpm.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index f57bff32c..b41b38bd5 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1124,6 +1124,12 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) } } + // log the ordering + const char *ops_str[] = {"Install", "Configure","Remove","Purge"}; + fprintf(report, "AptOrdering:\n"); + for (vector::iterator I = List.begin(); I != List.end(); I++) + fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]); + // attach dmesg log (to learn about segfaults) if (FileExists("/bin/dmesg")) { -- cgit v1.2.3 From 076c46e5fe4a0ec150952017650c4cc778dc2fd2 Mon Sep 17 00:00:00 2001 From: Matt Zimmerman Date: Thu, 6 Aug 2009 17:44:51 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - Suppress apport reports on dpkg short reads (these I/O errors are not generally indicative of a bug in the packaging) --- apt-pkg/deb/dpkgpm.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 4403eaefe..3e23720e0 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1078,6 +1078,13 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) 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; + } + // get the pkgname and reportfile pkgname = flNotDir(pkgpath); pos = pkgname.find('_'); -- cgit v1.2.3 From 2183a0862311cf2fbb82f61ecdcdf3816ce90040 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Dec 2009 10:40:37 +0100 Subject: * apt-pkg/deb/dpkgpm.cc: - include df -l output in the apport log as well (thanks to tjaalton) --- apt-pkg/deb/dpkgpm.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 7daa55a58..500d4a260 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1243,6 +1243,23 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) fclose(log); } } + + // attach df -l log (to learn about filesystem status) + if (FileExists("/bin/df")) + { + FILE *log = NULL; + char buf[1024]; + + fprintf(report, "Df:\n"); + log = popen("/bin/df -l","r"); + if(log != NULL) + { + while( fgets(buf, sizeof(buf), log) != NULL) + fprintf(report, " %s", buf); + fclose(log); + } + } + fclose(report); } -- cgit v1.2.3 From a29b2c0b9c4e7b1c36433c9c6dd5d24697f9c4b6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jan 2010 11:57:29 +0100 Subject: Change history branch so that it does not break the apt ABI for the pkgPackageManager interface (can be reverted on the next ABI break) --- apt-pkg/deb/dpkgpm.cc | 34 +++++++++++++++++++++++----------- apt-pkg/deb/dpkgpm.h | 4 +--- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 2f84a5a87..e928776af 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -562,7 +562,7 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd) } /*}}}*/ // DPkgPM::WriteHistoryTag /*{{{*/ -void pkgDPkgPM::WriteHistoryTag(string tag, string value) +void pkgDPkgPM::WriteHistoryTag(FILE *history_out, string tag, string value) { if (value.size() > 0) { @@ -602,7 +602,7 @@ bool pkgDPkgPM::OpenLog() _config->Find("Dir::Log::History")); if (!history_name.empty()) { - history_out = fopen(history_name.c_str(),"a"); + FILE *history_out = fopen(history_name.c_str(),"a"); chmod(history_name.c_str(), 0644); fprintf(history_out, "\nStart-Date: %s\n", timestr); string remove, purge, install, upgrade, downgrade; @@ -622,12 +622,12 @@ bool pkgDPkgPM::OpenLog() remove += I.Name() + string(" (") + Cache[I].CurVersion + string("), "); } } - WriteHistoryTag("Install", install); - WriteHistoryTag("Upgrade", upgrade); - WriteHistoryTag("Downgrade",downgrade); - WriteHistoryTag("Remove",remove); - WriteHistoryTag("Purge",purge); - fflush(history_out); + WriteHistoryTag(history_out, "Install", install); + WriteHistoryTag(history_out, "Upgrade", upgrade); + WriteHistoryTag(history_out, "Downgrade",downgrade); + WriteHistoryTag(history_out, "Remove",remove); + WriteHistoryTag(history_out, "Purge",purge); + fclose(history_out); } return true; @@ -650,10 +650,11 @@ bool pkgDPkgPM::CloseLog() } term_out = NULL; - if(history_out) + string history_name = flCombine(_config->FindDir("Dir::Log"), + _config->Find("Dir::Log::History")); + if (!history_name.empty()) { - if (dpkg_error.size() > 0) - fprintf(history_out, "Error: %s\n", dpkg_error.c_str()); + FILE *history_out = fopen(history_name.c_str(),"a"); fprintf(history_out, "End-Date: %s\n", timestr); fclose(history_out); } @@ -1125,6 +1126,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) if(stopOnError) RunScripts("DPkg::Post-Invoke"); + string dpkg_error; if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) strprintf(dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]); else if (WIFEXITED(Status) != 0) @@ -1133,7 +1135,17 @@ bool pkgDPkgPM::Go(int OutStatusFd) strprintf(dpkg_error, "Sub-process %s exited unexpectedly",Args[0]); if(dpkg_error.size() > 0) + { _error->Error(dpkg_error.c_str()); + string history_name = flCombine(_config->FindDir("Dir::Log"), + _config->Find("Dir::Log::History")); + if (!history_name.empty()) + { + FILE *history_out = fopen(history_name.c_str(),"a"); + fprintf(history_out, "Error: %s\n", dpkg_error.c_str()); + fclose(history_out); + } + } if(stopOnError) { diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index ce3e20f2e..160486bf9 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -29,8 +29,6 @@ class pkgDPkgPM : public pkgPackageManager char dpkgbuf[1024]; int dpkgbuf_pos; FILE *term_out; - FILE *history_out; - string dpkg_error; protected: int pkgFailures; @@ -70,7 +68,7 @@ class pkgDPkgPM : public pkgPackageManager // Helpers bool RunScriptsWithPkgs(const char *Cnf); bool SendV2Pkgs(FILE *F); - void WriteHistoryTag(string tag, string value); + void WriteHistoryTag(FILE* history_out, string tag, string value); // apport integration void WriteApportReport(const char *pkgpath, const char *errormsg); -- cgit v1.2.3 From 1c56c17a3c5548a3bb86c0d7967c0f790c7c2cca Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Mar 2010 17:02:27 +0100 Subject: cherry pick -r 1956..1957 lp:~donkult/apt/sid --- apt-pkg/deb/debversion.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index ad45e9a44..755ffbe96 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -190,8 +190,22 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, dlhs++; if (drhs != rhs) drhs++; - - return CmpFragment(dlhs,AEnd,drhs,BEnd); + + // no debian revision need to be treated like -0 + if (*(dlhs-1) == '-' && *(drhs-1) == '-') + return CmpFragment(dlhs,AEnd,drhs,BEnd); + else if (*(dlhs-1) == '-') + { + const char* null = "0"; + return CmpFragment(dlhs,AEnd,null, null+1); + } + else if (*(drhs-1) == '-') + { + const char* null = "0"; + return CmpFragment(null, null+1, drhs, BEnd); + } + else + return 0; } /*}}}*/ // debVS::CheckDep - Check a single dependency /*{{{*/ -- cgit v1.2.3 From c5a4be87d94e3f48aad955107bbaf17b0a7c93cc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Mar 2010 17:27:47 +0100 Subject: cherry pick -r 1954..1955 lp:~donkult/apt/sid --- apt-pkg/deb/dpkgpm.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8ecb683d4..18c731788 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -575,35 +575,37 @@ void pkgDPkgPM::WriteHistoryTag(FILE *history_out, string tag, string value) // DPkgPM::OpenLog /*{{{*/ bool pkgDPkgPM::OpenLog() { - string logdir = _config->FindDir("Dir::Log"); + string const logdir = _config->FindDir("Dir::Log"); if(not FileExists(logdir)) return _error->Error(_("Directory '%s' missing"), logdir.c_str()); // get current time char timestr[200]; - time_t t = time(NULL); - struct tm *tmp = localtime(&t); + time_t const t = time(NULL); + struct tm const * const tmp = localtime(&t); strftime(timestr, sizeof(timestr), "%F %T", tmp); // open terminal log - string logfile_name = flCombine(logdir, + string const logfile_name = flCombine(logdir, _config->Find("Dir::Log::Terminal")); if (!logfile_name.empty()) { term_out = fopen(logfile_name.c_str(),"a"); if (term_out == NULL) - return _error->WarningE(_("Could not open file '%s'"), logfile_name.c_str()); + return _error->WarningE("OpenLog", _("Could not open file '%s'"), logfile_name.c_str()); chmod(logfile_name.c_str(), 0600); fprintf(term_out, "\nLog started: %s\n", timestr); } - // write - string history_name = flCombine(logdir, + // write your history + string const history_name = flCombine(logdir, _config->Find("Dir::Log::History")); if (!history_name.empty()) { FILE *history_out = fopen(history_name.c_str(),"a"); + if (history_out == NULL) + return _error->WarningE("OpenLog", _("Could not open file '%s'"), history_name.c_str()); chmod(history_name.c_str(), 0644); fprintf(history_out, "\nStart-Date: %s\n", timestr); string remove, purge, install, upgrade, downgrade; -- cgit v1.2.3 From eea96cc7c1092f96c5929876608d09d9af292954 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 May 2010 09:58:23 +0200 Subject: * apt-pkg/deb/debrecords.cc: - fix max tag buffer size (LP: #545336, closes: #578959) --- apt-pkg/deb/debrecords.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 8ed0bb7eb..57d30dc62 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -19,7 +19,8 @@ /* */ debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : File(FileName,FileFd::ReadOnly), - Tags(&File,Cache.Head().MaxVerFileSize + 200) + Tags(&File, std::max(Cache.Head().MaxVerFileSize, + Cache.Head().MaxDescFileSize) + 200) { } /*}}}*/ -- cgit v1.2.3