From 6cb1060b58d8add6e04cc30241d3ef0f45ad226d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 May 2010 15:17:52 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - write Disappeared also to the history.log --- apt-pkg/deb/dpkgpm.cc | 33 ++++++++++++++++++++++++--------- apt-pkg/deb/dpkgpm.h | 2 +- debian/changelog | 8 ++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8318fe37f..35b10975f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -568,15 +568,15 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd) } /*}}}*/ // DPkgPM::WriteHistoryTag /*{{{*/ -void pkgDPkgPM::WriteHistoryTag(string tag, string value) +void pkgDPkgPM::WriteHistoryTag(string const &tag, string value) { - if (value.size() > 0) - { - // poor mans rstrip(", ") - if (value[value.size()-2] == ',' && value[value.size()-1] == ' ') - value.erase(value.size() - 2, 2); - fprintf(history_out, "%s: %s\n", tag.c_str(), value.c_str()); - } + size_t const length = value.length(); + if (length == 0) + return; + // poor mans rstrip(", ") + if (value[length-2] == ',' && value[length-1] == ' ') + value.erase(length - 2, 2); + fprintf(history_out, "%s: %s\n", tag.c_str(), value.c_str()); } /*}}}*/ // DPkgPM::OpenLog /*{{{*/ bool pkgDPkgPM::OpenLog() @@ -663,7 +663,22 @@ bool pkgDPkgPM::CloseLog() if(history_out) { - if (dpkg_error.size() > 0) + if (disappearedPkgs.empty() == false) + { + string disappear; + for (std::set::const_iterator d = disappearedPkgs.begin(); + d != disappearedPkgs.end(); ++d) + { + pkgCache::PkgIterator P = Cache.FindPkg(*d); + disappear.append(*d); + if (P.end() == true) + disappear.append(", "); + else + disappear.append(" (").append(Cache[P].CurVersion).append("), "); + } + WriteHistoryTag("Disappeared", disappear); + } + if (dpkg_error.empty() == false) fprintf(history_out, "Error: %s\n", dpkg_error.c_str()); fprintf(history_out, "End-Date: %s\n", timestr); fclose(history_out); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 330c788a2..b1459b1f6 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -68,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(string const &tag, string value); // dpkg log bool OpenLog(); diff --git a/debian/changelog b/debian/changelog index 3771ca415..ee571a537 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +apt (0.7.26~exp6) UNRELEASED; urgency=low + + [ David Kalnischkies ] + * apt-pkg/deb/dpkgpm.cc: + - write Disappeared also to the history.log + + -- David Kalnischkies Thu, 27 May 2010 15:12:02 +0200 + apt (0.7.26~exp5) experimental; urgency=low [ David Kalnischkies ] -- cgit v1.2.3-70-g09d2