]> git.saurik.com Git - apt.git/commitdiff
fix broken clean when apt was finished and ensure that terminal progress is updated...
authorMichael Vogt <mvo@debian.org>
Thu, 17 Oct 2013 05:47:15 +0000 (07:47 +0200)
committerMichael Vogt <mvo@debian.org>
Thu, 17 Oct 2013 05:47:15 +0000 (07:47 +0200)
apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h

index fe38bf69798f66a628a3813d39cec76fd4855196..f870fab936f7139c7b04cb726b0090e599aeb3aa 100644 (file)
@@ -993,6 +993,20 @@ void pkgDPkgPM::SetupTerminalScrollArea(int nr_rows)
      std::flush(std::cout);
 }
 
      std::flush(std::cout);
 }
 
+void pkgDPkgPM::CleanupTerminal()
+{
+   // reset scroll area
+   SetupTerminalScrollArea(d->nr_terminal_rows + 1);
+   if(d->fancy_progress_output)
+   {
+      // override the progress line (sledgehammer)
+      static const char* clear_screen_below_cursor = "\033[J";
+      std::cout << clear_screen_below_cursor;
+      std::flush(std::cout);
+   }
+}
+
+
 // DPkgPM::Go - Run the sequence                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* This globs the operations and calls dpkg 
 // DPkgPM::Go - Run the sequence                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* This globs the operations and calls dpkg 
@@ -1430,7 +1444,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
            if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0)
               _exit(100);
         }
            if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0)
               _exit(100);
         }
+         // setup terminal
          SetupTerminalScrollArea(d->nr_terminal_rows);
          SetupTerminalScrollArea(d->nr_terminal_rows);
+         SendTerminalProgress(PackagesDone/float(PackagesTotal)*100.0);
 
         /* No Job Control Stop Env is a magic dpkg var that prevents it
            from using sigstop */
 
         /* No Job Control Stop Env is a magic dpkg var that prevents it
            from using sigstop */
@@ -1525,15 +1541,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       
       signal(SIGHUP,old_SIGHUP);
 
       
       signal(SIGHUP,old_SIGHUP);
 
-      // reset scroll area
-      SetupTerminalScrollArea(d->nr_terminal_rows + 1);
-      if(d->fancy_progress_output)
-      {
-         // override the progress line (sledgehammer)
-         static const char* clear_screen_below_cursor = "\033[J";
-         std::cout << clear_screen_below_cursor;
-      }
-
       if(master >= 0) 
       {
         tcsetattr(0, TCSAFLUSH, &tt);
       if(master >= 0) 
       {
         tcsetattr(0, TCSAFLUSH, &tt);
@@ -1564,6 +1571,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
         if(stopOnError) 
         {
            CloseLog();
         if(stopOnError) 
         {
            CloseLog();
+            CleanupTerminal();
            return false;
         }
       }      
            return false;
         }
       }      
@@ -1574,6 +1582,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    if(_config->FindB("DPkgPM::Progress", false) == true)
       SendTerminalProgress(100);
 
    if(_config->FindB("DPkgPM::Progress", false) == true)
       SendTerminalProgress(100);
 
+   CleanupTerminal();
+
    if (pkgPackageManager::SigINTStop)
        _error->Warning(_("Operation was interrupted before it could finish"));
 
    if (pkgPackageManager::SigINTStop)
        _error->Warning(_("Operation was interrupted before it could finish"));
 
index 3b8d3662315c29416021ef4e48ef231f7b29508f..1a58e1af5959fb07e515cb45aa020d227ba9e00f 100644 (file)
@@ -87,6 +87,7 @@ class pkgDPkgPM : public pkgPackageManager
    // Terminal progress 
    void SetupTerminalScrollArea(int nr_scrolled_rows);
    void SendTerminalProgress(float percentage);
    // Terminal progress 
    void SetupTerminalScrollArea(int nr_scrolled_rows);
    void SendTerminalProgress(float percentage);
+   void CleanupTerminal();
 
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);
 
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);