summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/makefile12
-rw-r--r--apt-private/private-cacheset.cc8
-rw-r--r--apt-private/private-cmndline.cc4
-rw-r--r--apt-private/private-download.cc5
-rw-r--r--apt-private/private-download.h6
-rw-r--r--apt-private/private-install.cc144
-rw-r--r--apt-private/private-install.h156
-rw-r--r--apt-private/private-list.cc15
-rw-r--r--apt-private/private-main.cc9
-rw-r--r--apt-private/private-main.h1
-rw-r--r--apt-private/private-output.cc26
11 files changed, 222 insertions, 164 deletions
diff --git a/apt-private/makefile b/apt-private/makefile
index 09736c6d3..9a3fbdb29 100644
--- a/apt-private/makefile
+++ b/apt-private/makefile
@@ -8,9 +8,6 @@ HEADER_TARGETDIRS = apt-private
# Bring in the default rules
include ../buildlib/defaults.mak
-# The library name and version (indirectly used from init.h)
-include ../buildlib/libversion.mak
-
# The library name
LIBRARY=apt-private
MAJOR=0.0
@@ -18,12 +15,7 @@ MINOR=0
SLIBS=$(PTHREADLIB) -lapt-pkg
CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
-PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main utils sources
-SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc)
-HEADERS += $(foreach private, $(PRIVATES), private-$(private).h)
-
-SOURCE+= acqprogress.cc
-HEADERS+= acqprogress.h private-cacheset.h
+SOURCE = $(wildcard *.cc)
+HEADERS = $(addprefix apt-private/,$(wildcard *.h))
-HEADERS := $(addprefix apt-private/,$(HEADERS))
include $(LIBRARY_H)
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 4a63c7e81..e37e7b227 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -73,7 +73,13 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
else
{
pkgPolicy *policy = CacheFile.GetPolicy();
- output_set.insert(policy->GetCandidateVer(P));
+ if (policy->GetCandidateVer(P).IsGood())
+ output_set.insert(policy->GetCandidateVer(P));
+ else
+ // no candidate, this may happen for packages in
+ // dpkg "deinstall ok config-file" state - we pick the first ver
+ // (which should be the only one)
+ output_set.insert(P.VersionList());
}
}
progress.Done();
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 682be0a19..a21a9dc8c 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -116,7 +116,7 @@ static bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char con
static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
- "dselect-upgrade", "autoremove"))
+ "dselect-upgrade", "autoremove", "full-upgrade"))
{
addArg(0, "show-progress", "DpkgPM::Progress", 0);
addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
@@ -163,7 +163,7 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
"deselect-upgrade", "autoremove", "clean", "autoclean", "check",
- "build-dep"))
+ "build-dep", "full-upgrade"))
{
addArg('s', "simulate", "APT::Get::Simulate", 0);
addArg('s', "just-print", "APT::Get::Simulate", 0);
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc
index a095f0c67..be7d23c31 100644
--- a/apt-private/private-download.cc
+++ b/apt-private/private-download.cc
@@ -28,6 +28,11 @@ bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
if (UntrustedList == "")
return true;
+ return AuthPrompt(UntrustedList, PromptUser);
+}
+
+bool AuthPrompt(std::string UntrustedList, bool const PromptUser)
+{
ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
diff --git a/apt-private/private-download.h b/apt-private/private-download.h
index a108aa531..a90ac7eaa 100644
--- a/apt-private/private-download.h
+++ b/apt-private/private-download.h
@@ -5,7 +5,13 @@
class pkgAcquire;
+// Check if all files in the fetcher are authenticated
APT_PUBLIC bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
+
+// show a authentication warning prompt and return true if the system
+// should continue
+APT_PUBLIC bool AuthPrompt(std::string UntrustedList, bool const PromptUser);
+
APT_PUBLIC bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
#endif
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 107ed398e..a365d4294 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -617,7 +617,8 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
if (Fix != NULL)
{
// Call the scored problem resolver
- Fix->Resolve(true);
+ if (Fix->Resolve(true) == false && Cache->BrokenCount() == 0)
+ return false;
}
// Now we check the state of the packages,
@@ -801,3 +802,144 @@ bool DoInstall(CommandLine &CmdL)
return InstallPackages(Cache,false);
}
/*}}}*/
+
+// TryToInstall - Mark a package for installation /*{{{*/
+void TryToInstall::operator() (pkgCache::VerIterator const &Ver) {
+ pkgCache::PkgIterator Pkg = Ver.ParentPkg();
+
+ Cache->GetDepCache()->SetCandidateVersion(Ver);
+ pkgDepCache::StateCache &State = (*Cache)[Pkg];
+
+ // Handle the no-upgrade case
+ if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0)
+ ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"),
+ Pkg.FullName(true).c_str());
+ // Ignore request for install if package would be new
+ else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0)
+ ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"),
+ Pkg.FullName(true).c_str());
+ else {
+ if (Fix != NULL) {
+ Fix->Clear(Pkg);
+ Fix->Protect(Pkg);
+ }
+ Cache->GetDepCache()->MarkInstall(Pkg,false);
+
+ if (State.Install() == false) {
+ if (_config->FindB("APT::Get::ReInstall",false) == true) {
+ if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false)
+ ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"),
+ Pkg.FullName(true).c_str());
+ else
+ Cache->GetDepCache()->SetReInstall(Pkg, true);
+ } else
+ ioprintf(c1out,_("%s is already the newest version.\n"),
+ Pkg.FullName(true).c_str());
+ }
+
+ // Install it with autoinstalling enabled (if we not respect the minial
+ // required deps or the policy)
+ if (FixBroken == false)
+ doAutoInstallLater.insert(Pkg);
+ }
+
+ // see if we need to fix the auto-mark flag
+ // e.g. apt-get install foo
+ // where foo is marked automatic
+ if (State.Install() == false &&
+ (State.Flags & pkgCache::Flag::Auto) &&
+ _config->FindB("APT::Get::ReInstall",false) == false &&
+ _config->FindB("APT::Get::Only-Upgrade",false) == false &&
+ _config->FindB("APT::Get::Download-Only",false) == false)
+ {
+ ioprintf(c1out,_("%s set to manually installed.\n"),
+ Pkg.FullName(true).c_str());
+ Cache->GetDepCache()->MarkAuto(Pkg,false);
+ AutoMarkChanged++;
+ }
+}
+ /*}}}*/
+bool TryToInstall::propergateReleaseCandiateSwitching(std::list<std::pair<pkgCache::VerIterator, std::string> > const &start, std::ostream &out)/*{{{*/
+{
+ for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
+ s != start.end(); ++s)
+ Cache->GetDepCache()->SetCandidateVersion(s->first);
+
+ bool Success = true;
+ // the Changed list contains:
+ // first: "new version"
+ // second: "what-caused the change"
+ std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> > Changed;
+ for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
+ s != start.end(); ++s)
+ {
+ Changed.push_back(std::make_pair(s->first, pkgCache::VerIterator(*Cache)));
+ // We continue here even if it failed to enhance the ShowBroken output
+ Success &= Cache->GetDepCache()->SetCandidateRelease(s->first, s->second, Changed);
+ }
+ for (std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> >::const_iterator c = Changed.begin();
+ c != Changed.end(); ++c)
+ {
+ if (c->second.end() == true)
+ ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"),
+ c->first.VerStr(), c->first.RelStr().c_str(), c->first.ParentPkg().FullName(true).c_str());
+ else if (c->first.ParentPkg()->Group != c->second.ParentPkg()->Group)
+ {
+ pkgCache::VerIterator V = (*Cache)[c->first.ParentPkg()].CandidateVerIter(*Cache);
+ ioprintf(out, _("Selected version '%s' (%s) for '%s' because of '%s'\n"), V.VerStr(),
+ V.RelStr().c_str(), V.ParentPkg().FullName(true).c_str(), c->second.ParentPkg().FullName(true).c_str());
+ }
+ }
+ return Success;
+}
+ /*}}}*/
+void TryToInstall::doAutoInstall() { /*{{{*/
+ for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin();
+ P != doAutoInstallLater.end(); ++P) {
+ pkgDepCache::StateCache &State = (*Cache)[P];
+ if (State.InstBroken() == false && State.InstPolicyBroken() == false)
+ continue;
+ Cache->GetDepCache()->MarkInstall(P, true);
+ }
+ doAutoInstallLater.clear();
+}
+ /*}}}*/
+// TryToRemove - Mark a package for removal /*{{{*/
+void TryToRemove::operator() (pkgCache::VerIterator const &Ver)
+{
+ pkgCache::PkgIterator Pkg = Ver.ParentPkg();
+
+ if (Fix != NULL)
+ {
+ Fix->Clear(Pkg);
+ Fix->Protect(Pkg);
+ Fix->Remove(Pkg);
+ }
+
+ if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
+ (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
+ {
+ pkgCache::GrpIterator Grp = Pkg.Group();
+ pkgCache::PkgIterator P = Grp.PackageList();
+ for (; P.end() != true; P = Grp.NextPkg(P))
+ {
+ if (P == Pkg)
+ continue;
+ if (P->CurrentVer != 0 || (PurgePkgs == true && P->CurrentState != pkgCache::State::NotInstalled))
+ {
+ // TRANSLATORS: Note, this is not an interactive question
+ ioprintf(c1out,_("Package '%s' is not installed, so not removed. Did you mean '%s'?\n"),
+ Pkg.FullName(true).c_str(), P.FullName(true).c_str());
+ break;
+ }
+ }
+ if (P.end() == true)
+ ioprintf(c1out,_("Package '%s' is not installed, so not removed\n"),Pkg.FullName(true).c_str());
+
+ // MarkInstall refuses to install packages on hold
+ Pkg->SelectedState = pkgCache::State::Hold;
+ }
+ else
+ Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs);
+}
+ /*}}}*/
diff --git a/apt-private/private-install.h b/apt-private/private-install.h
index 5e18560c5..828163e40 100644
--- a/apt-private/private-install.h
+++ b/apt-private/private-install.h
@@ -3,28 +3,18 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/depcache.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/algorithms.h>
#include <apt-pkg/macros.h>
-#include <apt-private/private-output.h>
-
-#include <stddef.h>
-#include <iosfwd>
#include <list>
-#include <map>
#include <string>
#include <utility>
-
-#include <apti18n.h>
-
class CacheFile;
class CommandLine;
+class pkgProblemResolver;
#define RAMFS_MAGIC 0x858458f6
@@ -39,7 +29,7 @@ APT_PUBLIC bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
// TryToInstall - Mark a package for installation /*{{{*/
-struct TryToInstall {
+struct APT_PUBLIC TryToInstall {
pkgCacheFile* Cache;
pkgProblemResolver* Fix;
bool FixBroken;
@@ -49,109 +39,13 @@ struct TryToInstall {
TryToInstall(pkgCacheFile &Cache, pkgProblemResolver *PM, bool const FixBroken) : Cache(&Cache), Fix(PM),
FixBroken(FixBroken), AutoMarkChanged(0) {};
- void operator() (pkgCache::VerIterator const &Ver) {
- pkgCache::PkgIterator Pkg = Ver.ParentPkg();
-
- Cache->GetDepCache()->SetCandidateVersion(Ver);
- pkgDepCache::StateCache &State = (*Cache)[Pkg];
-
- // Handle the no-upgrade case
- if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0)
- ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"),
- Pkg.FullName(true).c_str());
- // Ignore request for install if package would be new
- else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0)
- ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"),
- Pkg.FullName(true).c_str());
- else {
- if (Fix != NULL) {
- Fix->Clear(Pkg);
- Fix->Protect(Pkg);
- }
- Cache->GetDepCache()->MarkInstall(Pkg,false);
-
- if (State.Install() == false) {
- if (_config->FindB("APT::Get::ReInstall",false) == true) {
- if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false)
- ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"),
- Pkg.FullName(true).c_str());
- else
- Cache->GetDepCache()->SetReInstall(Pkg, true);
- } else
- ioprintf(c1out,_("%s is already the newest version.\n"),
- Pkg.FullName(true).c_str());
- }
-
- // Install it with autoinstalling enabled (if we not respect the minial
- // required deps or the policy)
- if (FixBroken == false)
- doAutoInstallLater.insert(Pkg);
- }
-
- // see if we need to fix the auto-mark flag
- // e.g. apt-get install foo
- // where foo is marked automatic
- if (State.Install() == false &&
- (State.Flags & pkgCache::Flag::Auto) &&
- _config->FindB("APT::Get::ReInstall",false) == false &&
- _config->FindB("APT::Get::Only-Upgrade",false) == false &&
- _config->FindB("APT::Get::Download-Only",false) == false)
- {
- ioprintf(c1out,_("%s set to manually installed.\n"),
- Pkg.FullName(true).c_str());
- Cache->GetDepCache()->MarkAuto(Pkg,false);
- AutoMarkChanged++;
- }
- }
-
- bool propergateReleaseCandiateSwitching(std::list<std::pair<pkgCache::VerIterator, std::string> > start, std::ostream &out)
- {
- for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
- s != start.end(); ++s)
- Cache->GetDepCache()->SetCandidateVersion(s->first);
-
- bool Success = true;
- // the Changed list contains:
- // first: "new version"
- // second: "what-caused the change"
- std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> > Changed;
- for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
- s != start.end(); ++s)
- {
- Changed.push_back(std::make_pair(s->first, pkgCache::VerIterator(*Cache)));
- // We continue here even if it failed to enhance the ShowBroken output
- Success &= Cache->GetDepCache()->SetCandidateRelease(s->first, s->second, Changed);
- }
- for (std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> >::const_iterator c = Changed.begin();
- c != Changed.end(); ++c)
- {
- if (c->second.end() == true)
- ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"),
- c->first.VerStr(), c->first.RelStr().c_str(), c->first.ParentPkg().FullName(true).c_str());
- else if (c->first.ParentPkg()->Group != c->second.ParentPkg()->Group)
- {
- pkgCache::VerIterator V = (*Cache)[c->first.ParentPkg()].CandidateVerIter(*Cache);
- ioprintf(out, _("Selected version '%s' (%s) for '%s' because of '%s'\n"), V.VerStr(),
- V.RelStr().c_str(), V.ParentPkg().FullName(true).c_str(), c->second.ParentPkg().FullName(true).c_str());
- }
- }
- return Success;
- }
-
- void doAutoInstall() {
- for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin();
- P != doAutoInstallLater.end(); ++P) {
- pkgDepCache::StateCache &State = (*Cache)[P];
- if (State.InstBroken() == false && State.InstPolicyBroken() == false)
- continue;
- Cache->GetDepCache()->MarkInstall(P, true);
- }
- doAutoInstallLater.clear();
- }
+ void operator() (pkgCache::VerIterator const &Ver);
+ bool propergateReleaseCandiateSwitching(std::list<std::pair<pkgCache::VerIterator, std::string> > const &start, std::ostream &out);
+ void doAutoInstall();
};
/*}}}*/
// TryToRemove - Mark a package for removal /*{{{*/
-struct TryToRemove {
+struct APT_PUBLIC TryToRemove {
pkgCacheFile* Cache;
pkgProblemResolver* Fix;
bool PurgePkgs;
@@ -159,43 +53,7 @@ struct TryToRemove {
TryToRemove(pkgCacheFile &Cache, pkgProblemResolver *PM) : Cache(&Cache), Fix(PM),
PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
- void operator() (pkgCache::VerIterator const &Ver)
- {
- pkgCache::PkgIterator Pkg = Ver.ParentPkg();
-
- if (Fix != NULL)
- {
- Fix->Clear(Pkg);
- Fix->Protect(Pkg);
- Fix->Remove(Pkg);
- }
-
- if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
- (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
- {
- pkgCache::GrpIterator Grp = Pkg.Group();
- pkgCache::PkgIterator P = Grp.PackageList();
- for (; P.end() != true; P = Grp.NextPkg(P))
- {
- if (P == Pkg)
- continue;
- if (P->CurrentVer != 0 || (PurgePkgs == true && P->CurrentState != pkgCache::State::NotInstalled))
- {
- // TRANSLATORS: Note, this is not an interactive question
- ioprintf(c1out,_("Package '%s' is not installed, so not removed. Did you mean '%s'?\n"),
- Pkg.FullName(true).c_str(), P.FullName(true).c_str());
- break;
- }
- }
- if (P.end() == true)
- ioprintf(c1out,_("Package '%s' is not installed, so not removed\n"),Pkg.FullName(true).c_str());
-
- // MarkInstall refuses to install packages on hold
- Pkg->SelectedState = pkgCache::State::Hold;
- }
- else
- Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs);
- }
+ void operator() (pkgCache::VerIterator const &Ver);
};
/*}}}*/
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index b053cbcbe..b69002103 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -130,10 +130,11 @@ bool DoList(CommandLine &Cmd)
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
+ bool ShowAllVersions = _config->FindB("APT::Cmd::All-Versions", false);
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
- if(_config->FindB("APT::Cmd::All-Versions", false) == true)
+ if(ShowAllVersions == true)
{
ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
@@ -151,6 +152,18 @@ bool DoList(CommandLine &Cmd)
std::cout << (*K).second << std::endl;
+ // be nice and tell the user if there is more to see
+ if (bag.size() == 1 && ShowAllVersions == false)
+ {
+ // start with -1 as we already displayed one version
+ int versions = -1;
+ pkgCache::VerIterator Ver = *bag.begin();
+ for ( ; Ver.end() == false; Ver++)
+ versions++;
+ if (versions > 0)
+ _error->Notice(P_("There is %i additional version. Please use the '-a' switch to see it", "There are %i additional versions. Please use the '-a' switch to see them.", versions), versions);
+ }
+
return true;
}
diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc
index 2d3965172..668b1733a 100644
--- a/apt-private/private-main.cc
+++ b/apt-private/private-main.cc
@@ -8,9 +8,18 @@
#include <iostream>
#include <string.h>
#include <unistd.h>
+#include <signal.h>
#include <apti18n.h>
+
+void InitSignals()
+{
+ // Setup the signals
+ signal(SIGPIPE,SIG_IGN);
+}
+
+
void CheckSimulateMode(CommandLine &CmdL)
{
// simulate user-friendly if apt-get has no root privileges
diff --git a/apt-private/private-main.h b/apt-private/private-main.h
index 23d4aca68..a03bf4441 100644
--- a/apt-private/private-main.h
+++ b/apt-private/private-main.h
@@ -6,5 +6,6 @@
class CommandLine;
APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL);
+APT_PUBLIC void InitSignals();
#endif
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index bbd8545ad..32f27a3dd 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -22,6 +22,8 @@
#include <iostream>
#include <langinfo.h>
#include <unistd.h>
+#include <signal.h>
+#include <sys/ioctl.h>
#include <apti18n.h>
/*}}}*/
@@ -32,8 +34,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 +65,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 +168,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();
}
/*}}}*/