Просмотр исходного кода

fix broken clean when apt was finished and ensure that terminal progress is updated when a new dpkg-loop is entered in dpkgpm.cc

Michael Vogt лет назад: 12
Родитель
Сommit
c420fe0096
2 измененных файлов с 20 добавлено и 9 удалено
  1. 19 9
      apt-pkg/deb/dpkgpm.cc
  2. 1 0
      apt-pkg/deb/dpkgpm.h

+ 19 - 9
apt-pkg/deb/dpkgpm.cc

@@ -993,6 +993,20 @@ void pkgDPkgPM::SetupTerminalScrollArea(int nr_rows)
      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 
@@ -1430,7 +1444,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0)
 	       _exit(100);
 	 }
+         // setup terminal
          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 */
@@ -1525,15 +1541,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       
       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);
@@ -1564,6 +1571,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	 if(stopOnError) 
 	 {
 	    CloseLog();
+            CleanupTerminal();
 	    return false;
 	 }
       }      
@@ -1574,6 +1582,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
    if(_config->FindB("DPkgPM::Progress", false) == true)
       SendTerminalProgress(100);
 
+   CleanupTerminal();
+
    if (pkgPackageManager::SigINTStop)
        _error->Warning(_("Operation was interrupted before it could finish"));
 

+ 1 - 0
apt-pkg/deb/dpkgpm.h

@@ -87,6 +87,7 @@ class pkgDPkgPM : public pkgPackageManager
    // Terminal progress 
    void SetupTerminalScrollArea(int nr_scrolled_rows);
    void SendTerminalProgress(float percentage);
+   void CleanupTerminal();
 
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);