summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-04-22 15:19:17 +0200
committerMichael Vogt <mvo@debian.org>2014-04-22 15:19:17 +0200
commit9607aab538b07f1bb60f9b0d84ea445589638998 (patch)
treebdd459aac462fc0dc93b7a0eb319dc218ecc16e4 /apt-pkg
parentc6e00b107318e32284437f02285197154bee59bf (diff)
parentebe24b7ad56550f21f467b86ceab7f7209a876f6 (diff)
Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc7
-rw-r--r--apt-pkg/install-progress.cc35
-rw-r--r--apt-pkg/install-progress.h3
3 files changed, 32 insertions, 13 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index c9d419fc4..de73a7fd8 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1360,7 +1360,10 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
Args.push_back(a->c_str());
if (Comp == false && FileName.empty() == false)
{
- Args.push_back("--stdout");
+ // commands not needing arguments, do not need to be told about using standard output
+ // in reality, only testcases with tools like cat, rev, rot13, … are able to trigger this
+ if (compressor.CompressArgs.empty() == false && compressor.UncompressArgs.empty() == false)
+ Args.push_back("--stdout");
if (TemporaryFileName.empty() == false)
Args.push_back(TemporaryFileName.c_str());
else
@@ -1653,6 +1656,8 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
/* */
bool FileFd::Seek(unsigned long long To)
{
+ Flags &= ~HitEof;
+
if (d != NULL && (d->pipe == true || d->InternalStream() == true))
{
// Our poor man seeking in pipes is costly, so try to avoid it
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 8bb587f67..cf6c85912 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -256,14 +256,14 @@ PackageManagerFancy::TermSize
PackageManagerFancy::GetTerminalSize()
{
struct winsize win;
- PackageManagerFancy::TermSize s;
+ PackageManagerFancy::TermSize s = { 0, 0 };
// FIXME: get from "child_pty" instead?
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0)
return s;
if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
- std::cerr << "GetTerminalSize: " << win.ws_row << std::endl;
+ std::cerr << "GetTerminalSize: " << win.ws_row << " x " << win.ws_col << std::endl;
s.rows = win.ws_row;
s.columns = win.ws_col;
@@ -275,6 +275,9 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows)
if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
std::cerr << "SetupTerminalScrollArea: " << nr_rows << std::endl;
+ if (unlikely(nr_rows <= 1))
+ return;
+
// scroll down a bit to avoid visual glitch when the screen
// area shrinks by one row
std::cout << "\n";
@@ -296,28 +299,30 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows)
// setup tty size to ensure xterm/linux console are working properly too
// see bug #731738
struct winsize win;
- ioctl(child_pty, TIOCGWINSZ, (char *)&win);
- win.ws_row = nr_rows - 1;
- ioctl(child_pty, TIOCSWINSZ, (char *)&win);
+ if (ioctl(child_pty, TIOCGWINSZ, (char *)&win) != -1)
+ {
+ win.ws_row = nr_rows - 1;
+ ioctl(child_pty, TIOCSWINSZ, (char *)&win);
+ }
}
void PackageManagerFancy::HandleSIGWINCH(int)
{
- int nr_terminal_rows = GetTerminalSize().rows;
+ int const nr_terminal_rows = GetTerminalSize().rows;
SetupTerminalScrollArea(nr_terminal_rows);
+ DrawStatusLine();
}
void PackageManagerFancy::Start(int a_child_pty)
{
child_pty = a_child_pty;
- int nr_terminal_rows = GetTerminalSize().rows;
- if (nr_terminal_rows > 0)
- SetupTerminalScrollArea(nr_terminal_rows);
+ int const nr_terminal_rows = GetTerminalSize().rows;
+ SetupTerminalScrollArea(nr_terminal_rows);
}
void PackageManagerFancy::Stop()
{
- int nr_terminal_rows = GetTerminalSize().rows;
+ int const nr_terminal_rows = GetTerminalSize().rows;
if (nr_terminal_rows > 0)
{
SetupTerminalScrollArea(nr_terminal_rows + 1);
@@ -358,7 +363,13 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName,
HumanReadableAction))
return false;
- PackageManagerFancy::TermSize size = GetTerminalSize();
+ return DrawStatusLine();
+}
+bool PackageManagerFancy::DrawStatusLine()
+{
+ PackageManagerFancy::TermSize const size = GetTerminalSize();
+ if (unlikely(size.rows < 1 || size.columns < 1))
+ return false;
static std::string save_cursor = "\033[s";
static std::string restore_cursor = "\033[u";
@@ -388,7 +399,7 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName,
{
int padding = 4;
float progressbar_size = size.columns - padding - progress_str.size();
- float current_percent = (float)StepsDone/(float)TotalSteps;
+ float current_percent = percentage / 100.0;
std::cout << " "
<< GetTextProgressStr(current_percent, progressbar_size)
<< " ";
diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h
index 112b034fb..5d1a20e9b 100644
--- a/apt-pkg/install-progress.h
+++ b/apt-pkg/install-progress.h
@@ -1,6 +1,8 @@
#ifndef PKGLIB_IPROGRESS_H
#define PKGLIB_IPROGRESS_H
+#include <apt-pkg/macros.h>
+
#include <string>
#include <unistd.h>
#include <signal.h>
@@ -120,6 +122,7 @@ namespace Progress {
private:
static void staticSIGWINCH(int);
static std::vector<PackageManagerFancy*> instances;
+ APT_HIDDEN bool DrawStatusLine();
protected:
void SetupTerminalScrollArea(int nr_rows);