Add DPkgPM::Progress for terminal install progress
authorMichael Vogt <mvo@debian.org>
Thu, 11 Jul 2013 21:09:47 +0000 (23:09 +0200)
committerMichael Vogt <mvo@debian.org>
Thu, 11 Jul 2013 21:09:47 +0000 (23:09 +0200)
apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h

index fb04735..3fb80d1 100644 (file)
@@ -620,6 +620,9 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
             << ":"  << (PackagesDone/float(PackagesTotal)*100.0) 
             << ":" << s
             << endl;
+      if(_config->FindB("DPkgPM::Progress", false) == true)
+         SendTerminalProgress(PackagesDone/float(PackagesTotal)*100.0);
+
       if(OutStatusFd > 0)
         FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
       if (Debug == true)
@@ -860,6 +863,18 @@ bool pkgDPkgPM::CloseLog()
    return true;
 }
                                                                        /*}}}*/
+// DPkgPM::SendTerminalProgress                                        /*{{{*/
+// ---------------------------------------------------------------------
+/* Send progress info to the terminal
+ */
+void pkgDPkgPM::SendTerminalProgress(float percentage)
+{
+   // FIXME: use colors too
+   std::cout << "\r\n"
+             << "Progress: [" << percentage << "%]"
+             << "\r\n";
+}
+                                                                       /*}}}*/
 /*{{{*/
 // This implements a racy version of pselect for those architectures
 // that don't have a working implementation.
@@ -1274,7 +1289,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
         FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
       }
       Child = ExecFork();
-            
+      
       // This is the child
       if (Child == 0)
       {
index c31d56f..29901a2 100644 (file)
@@ -84,6 +84,8 @@ class pkgDPkgPM : public pkgPackageManager
    bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
    void WriteHistoryTag(std::string const &tag, std::string value);
 
+   void SendTerminalProgress(float percentage);
+
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);