summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-10-17 07:47:15 +0200
committerMichael Vogt <mvo@debian.org>2013-10-17 07:47:15 +0200
commitc420fe0096985234e861aaafc2b9908b6259a1bb (patch)
tree3f1a390ba272a3c16025b3b3a902f66a84d0ce7d /apt-pkg
parent3d22a7fddc53b1b76d8961b10e4151ada46c4658 (diff)
fix broken clean when apt was finished and ensure that terminal progress is updated when a new dpkg-loop is entered in dpkgpm.cc
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/dpkgpm.cc28
-rw-r--r--apt-pkg/deb/dpkgpm.h1
2 files changed, 20 insertions, 9 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index fe38bf697..f870fab93 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/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"));
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 3b8d36623..1a58e1af5 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/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);