summaryrefslogtreecommitdiff
path: root/apt-private/private-output.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-output.cc')
-rw-r--r--apt-private/private-output.cc112
1 files changed, 60 insertions, 52 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 659975476..420ca14d5 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -28,9 +28,11 @@ std::ostream c2out(0);
std::ofstream devnull("/dev/null");
unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
-
-bool InitOutput()
+bool InitOutput() /*{{{*/
{
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
+ _config->Set("quiet","1");
+
c0out.rdbuf(cout.rdbuf());
c1out.rdbuf(cout.rdbuf());
c2out.rdbuf(cout.rdbuf());
@@ -60,8 +62,8 @@ bool InitOutput()
return true;
}
-
-std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
+ /*}}}*/
+std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver) /*{{{*/
{
std::string suite = "";
if (ver && ver.FileList() && ver.FileList())
@@ -69,16 +71,18 @@ std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
pkgCache::VerFileIterator VF = ver.FileList();
for (; VF.end() == false ; ++VF)
{
- // XXX: how to figure out the relevant suite? if its in multiple ones?
- suite = suite + "," + VF.File().Archive();
+ if(VF.File() == NULL || VF.File().Archive() == NULL)
+ suite = suite + "," + _("unknown");
+ else
+ suite = suite + "," + VF.File().Archive();
//suite = VF.File().Archive();
}
suite = suite.erase(0, 1);
}
return suite;
}
-
-std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
@@ -94,32 +98,34 @@ std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
flags_str = "-";
return flags_str;
}
-
-std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator cand = policy->GetCandidateVer(P);
return cand ? cand.VerStr() : "(none)";
}
-
-std::string GetInstalledVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetInstalledVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgCache::VerIterator inst = P.CurrentVer();
return inst ? inst.VerStr() : "(none)";
}
-
-std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
+ /*}}}*/
+std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
{
pkgCache::PkgIterator P = V.ParentPkg();
if (V == P.CurrentVer())
{
+ std::string inst_str = DeNull(V.VerStr());
+#if 0 // FIXME: do we want this or something like this?
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
- std::string inst_str = DeNull(V.VerStr());
if (state.Upgradable())
return "**"+inst_str;
+#endif
return inst_str;
}
@@ -127,8 +133,8 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
return DeNull(V.VerStr());
return "(none)";
}
-
-std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator inst = P.CurrentVer();
@@ -136,8 +142,8 @@ std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)
return inst ? inst.Arch() : cand.Arch();
}
-
-std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)
+ /*}}}*/
+std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
@@ -157,9 +163,10 @@ std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pk
}
return ShortDescription;
}
-
-void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
- pkgCache::VerIterator V, std::ostream &out)
+ /*}}}*/
+void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
+ pkgCache::VerIterator V, std::ostream &out,
+ bool include_summary)
{
pkgCache::PkgIterator P = V.ParentPkg();
@@ -186,52 +193,53 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
// raring/linux-kernel version [upradable: new-version]
// description
pkgPolicy *policy = CacheFile.GetPolicy();
- out << std::setiosflags(std::ios::left)
- << _config->Find("APT::Color::Highlight", "")
- << name_str
- << _config->Find("APT::Color::Neutral", "")
- << "/" << suite
- << " ";
+ std::string VersionStr = GetVersion(CacheFile, V);
+ std::string CandidateVerStr = GetCandidateVersion(CacheFile, P);
+ std::string InstalledVerStr = GetInstalledVersion(CacheFile, P);
+ std::string StatusStr;
if(P.CurrentVer() == V && state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << "[" << _("installed,upgradable to: ")
- << GetCandidateVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[installed,upgradable to: %s]"),
+ CandidateVerStr.c_str());
} else if (P.CurrentVer() == V) {
- out << GetVersion(CacheFile, V)
- << " ";
if(!V.Downloadable())
- out << _("[installed,local]");
+ StatusStr = _("[installed,local]");
else
if(V.Automatic() && state.Garbage)
- out << _("[installed,auto-removable]");
+ StatusStr = _("[installed,auto-removable]");
else if (state.Flags & pkgCache::Flag::Auto)
- out << _("[installed,automatic]");
+ StatusStr = _("[installed,automatic]");
else
- out << _("[installed]");
+ StatusStr = _("[installed]");
} else if (P.CurrentVer() &&
policy->GetCandidateVer(P) == V &&
state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << _("[upgradable from: ")
- << GetInstalledVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[upgradable from: %s]"),
+ InstalledVerStr.c_str());
} else {
if (V.ParentPkg()->CurrentState == pkgCache::State::ConfigFiles)
- out << GetVersion(CacheFile, V)
- << " "
- << _("[residual-config]");
+ StatusStr = _("[residual-config]");
else
- out << GetVersion(CacheFile, V);
+ StatusStr = "";
+ }
+ out << std::setiosflags(std::ios::left)
+ << _config->Find("APT::Color::Highlight", "")
+ << name_str
+ << _config->Find("APT::Color::Neutral", "")
+ << "/" << suite
+ << " "
+ << VersionStr << " "
+ << GetArchitecture(CacheFile, P);
+ if (StatusStr != "")
+ out << " " << StatusStr;
+ if (include_summary)
+ {
+ out << std::endl
+ << " " << GetShortDescription(CacheFile, records, P)
+ << std::endl;
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
- out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
- << std::endl;
}
}
-
-
+ /*}}}*/
// ShowList - Show a list /*{{{*/
// ---------------------------------------------------------------------
/* This prints out a string of space separated words with a title and