summaryrefslogtreecommitdiff
path: root/apt-private/private-output.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-05-07 15:41:54 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-05-07 15:41:54 +0200
commitff94be47f5dbdcf99cea23fad8c9b992a8e5a67e (patch)
treedd57b80bf6ecd853fb3c6d5eab041630ecd1e75e /apt-private/private-output.cc
parente39698a485e332742b935292dc4329abf19cbb53 (diff)
parent98c934f2723d63d00908803ad47ab1359081ec2d (diff)
Merge branch 'debian/sid' into bugfix/update-progress-reporting
Diffstat (limited to 'apt-private/private-output.cc')
-rw-r--r--apt-private/private-output.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index bbd8545ad..7f3eef6c2 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -22,6 +22,7 @@
#include <iostream>
#include <langinfo.h>
#include <unistd.h>
+#include <signal.h>
#include <apti18n.h>
/*}}}*/
@@ -32,8 +33,24 @@ std::ostream c0out(0);
std::ostream c1out(0);
std::ostream c2out(0);
std::ofstream devnull("/dev/null");
+
+
unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
+// SigWinch - Window size change signal handler /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static void SigWinch(int)
+{
+ // Riped from GNU ls
+#ifdef TIOCGWINSZ
+ struct winsize ws;
+
+ if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
+ ScreenWidth = ws.ws_col - 1;
+#endif
+}
+ /*}}}*/
bool InitOutput() /*{{{*/
{
if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
@@ -47,6 +64,10 @@ bool InitOutput() /*{{{*/
if (_config->FindI("quiet",0) > 1)
c1out.rdbuf(devnull.rdbuf());
+ // deal with window size changes
+ signal(SIGWINCH,SigWinch);
+ SigWinch(0);
+
if(!isatty(1))
{
_config->Set("APT::Color", "false");
@@ -146,6 +167,10 @@ static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterato
pkgCache::VerIterator inst = P.CurrentVer();
pkgCache::VerIterator cand = policy->GetCandidateVer(P);
+ // this may happen for packages in dpkg "deinstall ok config-file" state
+ if (inst.IsGood() == false && cand.IsGood() == false)
+ return P.VersionList().Arch();
+
return inst ? inst.Arch() : cand.Arch();
}
/*}}}*/