]> git.saurik.com Git - apt.git/commitdiff
apt-pkg/deb/dpkgpm.{cc,h}: refactor writing of the history tag, add ","
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 18 Dec 2009 14:43:49 +0000 (15:43 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 18 Dec 2009 14:43:49 +0000 (15:43 +0100)
apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h

index 8162405c77dee8e88ba07792b1a38b7724623dec..4b118bc1422f244a9602624e0b6c6094ae5c3350 100644 (file)
@@ -550,6 +550,17 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
    dpkgbuf_pos = dpkgbuf+dpkgbuf_pos-p;
 }
                                                                        /*}}}*/
    dpkgbuf_pos = dpkgbuf+dpkgbuf_pos-p;
 }
                                                                        /*}}}*/
+// DPkgPM::WriteHistoryTag                                             /*{{{*/
+void pkgDPkgPM::WriteHistoryTag(string 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());
+   }
+}                                                                      /*}}}*/
 // DPkgPM::OpenLog                                                     /*{{{*/
 bool pkgDPkgPM::OpenLog()
 {
 // DPkgPM::OpenLog                                                     /*{{{*/
 bool pkgDPkgPM::OpenLog()
 {
@@ -586,30 +597,25 @@ bool pkgDPkgPM::OpenLog()
       string remove, purge, install, upgrade, downgrade;
       for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       {
       string remove, purge, install, upgrade, downgrade;
       for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       {
-        if (Cache[I].Upgrade())
-           upgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string(") ");
+        if (Cache[I].NewInstall())
+           install += I.Name() + string(" (") + Cache[I].CandVersion + string("), ");
+        else if (Cache[I].Upgrade())
+           upgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
         else if (Cache[I].Downgrade())
         else if (Cache[I].Downgrade())
-           downgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string(") ");
-        else if (Cache[I].Install())
-           install += I.Name() + string(" (") + Cache[I].CandVersion + string(") ");
+           downgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
         else if (Cache[I].Delete())
         {
            if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge)
         else if (Cache[I].Delete())
         {
            if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge)
-              purge += I.Name() + string(" (") + Cache[I].CurVersion + string(") ");       
+              purge += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");      
            else
            else
-              remove += I.Name() + string(" (") + Cache[I].CurVersion + string(") ");      
+              remove += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");     
         }
       }
         }
       }
-      if (install.size() > 0)
-        fprintf(history_out, "Install: %s\n", install.c_str());
-      if (upgrade.size() > 0)
-        fprintf(history_out, "Upgrade: %s\n", upgrade.c_str());
-      if (downgrade.size() > 0)
-        fprintf(history_out, "Downgrade: %s\n", downgrade.c_str());
-      if (remove.size() > 0)
-        fprintf(history_out, "Remove: %s\n", remove.c_str());
-      if (purge.size() > 0)
-        fprintf(history_out, "Purge: %s\n", purge.c_str());
+      WriteHistoryTag("Install", install);
+      WriteHistoryTag("Upgrade", upgrade);
+      WriteHistoryTag("Downgrade",downgrade);
+      WriteHistoryTag("Remove",remove);
+      WriteHistoryTag("Purge",purge);
       fflush(history_out);
    }
    
       fflush(history_out);
    }
    
index 67f1430be5467bfb4e7c1771ffa8c2c60b0cf766..330c788a25319fc74e5cea393946bebfe49b893f 100644 (file)
@@ -68,6 +68,7 @@ class pkgDPkgPM : public pkgPackageManager
    // Helpers
    bool RunScriptsWithPkgs(const char *Cnf);
    bool SendV2Pkgs(FILE *F);
    // Helpers
    bool RunScriptsWithPkgs(const char *Cnf);
    bool SendV2Pkgs(FILE *F);
+   void WriteHistoryTag(string tag, string value);
 
    // dpkg log
    bool OpenLog();
 
    // dpkg log
    bool OpenLog();