summaryrefslogtreecommitdiffstats
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/acqprogress.cc5
-rw-r--r--apt-private/private-cmndline.cc18
-rw-r--r--apt-private/private-install.cc29
-rw-r--r--apt-private/private-main.cc2
-rw-r--r--apt-private/private-moo.cc2
-rw-r--r--apt-private/private-output.cc35
-rw-r--r--apt-private/private-output.h11
-rw-r--r--apt-private/private-show.cc10
-rw-r--r--apt-private/private-update.cc6
9 files changed, 75 insertions, 43 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index 1f5acdd..b4b16e6 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -9,6 +9,7 @@
// Include files /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
#include <apt-pkg/acquire.h>
@@ -281,14 +282,14 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
// Draw the current status
if (_config->FindB("Apt::Color", false) == true)
- out << _config->Find("APT::Color::Yellow");
+ out << APT::Configuration::color("Yellow");
if (LastLineLength > Line.length())
clearLastLine();
else
out << '\r';
out << Line << std::flush;
if (_config->FindB("Apt::Color", false) == true)
- out << _config->Find("APT::Color::Neutral") << std::flush;
+ out << APT::Configuration::color("Neutral") << std::flush;
LastLineLength = Line.length();
Update = false;
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 3d6816d..b05ec89 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -246,10 +246,8 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
}
else if (CmdMatches("clean", "autoclean", "auto-clean", "distclean", "dist-clean", "check", "download", "changelog") ||
CmdMatches("markauto", "unmarkauto")) // deprecated commands
- ;
- else if (CmdMatches("moo"))
- addArg(0, "color", "APT::Moo::Color", 0);
-
+ {
+ }
if (CmdMatches("install", "reinstall", "remove", "purge", "upgrade", "dist-upgrade",
"dselect-upgrade", "autoremove", "auto-remove", "autopurge", "check",
"clean", "autoclean", "auto-clean", "distclean", "dist-clean",
@@ -409,7 +407,9 @@ std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const
addArg('h', "help", "help", 0);
addArg('v', "version", "version", 0);
// general options
+ addArg(0, "color", "APT::Color", 0);
addArg('q', "quiet", "quiet", CommandLine::IntLevel);
+ addArg(0, "audit", "APT::Audit", 0);
addArg('q', "silent", "quiet", CommandLine::IntLevel);
addArg('c', "config-file", 0, CommandLine::ConfigFile);
addArg('o', "option", 0, CommandLine::ArbItem);
@@ -487,8 +487,8 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/
}
if (binary == "apt" || binary == "apt-config")
{
- if (getenv("NO_COLOR") == nullptr)
- _config->CndSet("Binary::apt::APT::Color", true);
+ if (getenv("NO_COLOR") == nullptr && getenv("APT_NO_COLOR") == nullptr)
+ _config->CndSet("Binary::apt::APT::Color", true);
_config->CndSet("Binary::apt::APT::Output-Version", 30);
_config->CndSet("Binary::apt::APT::Cache::Show::Version", 2);
_config->CndSet("Binary::apt::APT::Cache::AllVersions", false);
@@ -602,10 +602,12 @@ unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::D
// Print any errors or warnings found during parsing
bool const Errors = _error->PendingError();
- if (_config->FindI("quiet",0) > 0)
+ if (_config->FindB("APT::Audit"))
+ _error->DumpErrors(GlobalError::AUDIT);
+ else if (_config->FindI("quiet",0) > 0)
_error->DumpErrors();
else
- _error->DumpErrors(GlobalError::DEBUG);
+ _error->DumpErrors(GlobalError::NOTICE);
if (returned == false)
return 100;
return Errors == true ? 100 : 0;
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index ecbd703..9a2ed0b 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -227,11 +227,11 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo
// Show all the various warning indicators
if (_config->FindI("APT::Output-Version") < 30)
ShowDel(c1out,Cache);
+ if (_config->FindI("APT::Output-Version") >= 30 && _config->FindB("APT::Get::Show-Upgraded",true) == true)
+ ShowUpgraded(c1out,Cache);
ShowNew(c1out,Cache);
if (_config->FindI("APT::Output-Version") >= 30)
ShowWeakDependencies(Cache);
- if (_config->FindI("APT::Output-Version") >= 30 && _config->FindB("APT::Get::Show-Upgraded",true) == true)
- ShowUpgraded(c1out,Cache);
if (ShwKept == true)
{
ShowPhasing(c1out, Cache, PhasingPackages);
@@ -684,6 +684,16 @@ bool DoAutomaticRemove(CacheFile &Cache)
// if we don't remove them, we should show them!
if (doAutoRemove == false && autoRemoveCount != 0)
{
+ std::string note;
+ std::string autocmd = "apt autoremove";
+ if (getenv("SUDO_USER") != nullptr)
+ {
+ auto const envsudocmd = getenv("SUDO_COMMAND");
+ auto const envshell = getenv("SHELL");
+ if (envsudocmd == nullptr || envshell == nullptr || strcmp(envsudocmd, envshell) != 0)
+ autocmd = "sudo " + autocmd;
+ }
+ strprintf(note, P_("Use '%s' to remove it.", "Use '%s' to remove them.", autoRemoveCount), autocmd.c_str());
if (smallList == false)
{
// trigger marking now so that the package list is correct
@@ -693,21 +703,14 @@ bool DoAutomaticRemove(CacheFile &Cache)
"The following packages were automatically installed and are no longer required:",
autoRemoveCount), Universe,
[&Cache](pkgCache::PkgIterator const &Pkg) { return (*Cache)[Pkg].Garbage == true && (*Cache)[Pkg].Delete() == false; },
- &PrettyFullName, CandidateVersion(&Cache));
+ &PrettyFullName, CandidateVersion(&Cache), "", note);
}
else
+ {
ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n",
"%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount);
- std::string autocmd = "apt autoremove";
- if (getenv("SUDO_USER") != nullptr)
- {
- auto const envsudocmd = getenv("SUDO_COMMAND");
- auto const envshell = getenv("SHELL");
- if (envsudocmd == nullptr || envshell == nullptr || strcmp(envsudocmd, envshell) != 0)
- autocmd = "sudo " + autocmd;
+ c1out << note << std::endl;
}
- ioprintf(c1out, P_("Use '%s' to remove it.", "Use '%s' to remove them.", autoRemoveCount), autocmd.c_str());
- c1out << std::endl;
}
return true;
}
@@ -1104,7 +1107,7 @@ bool DoInstall(CommandLine &CmdL)
if (_config->FindI("APT::Output-Version") < 30 && Cache->InstCount() != verset[MOD_INSTALL].size())
ShowList(c1out, _("The following additional packages will be installed:"), Universe,
PkgIsExtraInstalled(&Cache, &verset[MOD_INSTALL]),
- &PrettyFullName, CandidateVersion(&Cache), "APT::Color::Green");
+ &PrettyFullName, CandidateVersion(&Cache), "action::install-dependencies");
/* Print out a list of suggested and recommended packages */
if (_config->FindI("APT::Output-Version") < 30)
diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc
index a80f03c..f28f5cb 100644
--- a/apt-private/private-main.cc
+++ b/apt-private/private-main.cc
@@ -68,6 +68,8 @@ void CheckIfSimulateMode(CommandLine &CmdL) /*{{{*/
" Keep also in mind that locking is deactivated,\n"
" so don't depend on the relevance to the real current situation!\n"),
_config->Find("Binary").c_str());
+ if (_config->FindI("APT::Output-Version") >= 30)
+ std::cout << std::endl;
_config->Set("Debug::NoLocking",true);
}
}
diff --git a/apt-private/private-moo.cc b/apt-private/private-moo.cc
index 2a9ed93..5eb6db5 100644
--- a/apt-private/private-moo.cc
+++ b/apt-private/private-moo.cc
@@ -96,7 +96,7 @@ static bool DoMoo2(time_t const timenow) /*{{{*/
return printMooLine(timenow);
std::string const moo = getMooLine(timenow);
size_t const depth = moo.length()/4;
- if (_config->FindB("APT::Moo::Color", false) == false)
+ if (_config->FindB("APT::Color", false) == false)
c1out <<
OutputInDepth(depth, " ") << " (__) \n" <<
OutputInDepth(depth, " ") << " _______~(..)~ \n" <<
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 95dc740..09d03d3 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -1,6 +1,7 @@
// Include files /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
@@ -30,6 +31,7 @@
/*}}}*/
using namespace std;
+using APT::Configuration::color;
std::ostream c0out(0);
std::ostream c1out(0);
@@ -86,7 +88,7 @@ bool InitOutput(std::basic_streambuf<char> * const out) /*{{{*/
SigWinch(0);
}
- if (isatty(STDOUT_FILENO) == 0 || not _config->FindB("APT::Color", true) || getenv("NO_COLOR") != nullptr)
+ if (isatty(STDOUT_FILENO) == 0 || not _config->FindB("APT::Color", true) || getenv("NO_COLOR") != nullptr || getenv("APT_NO_COLOR") != nullptr)
{
_config->Set("APT::Color", false);
_config->Set("APT::Color::Highlight", "");
@@ -94,6 +96,7 @@ bool InitOutput(std::basic_streambuf<char> * const out) /*{{{*/
} else {
// Colors
_config->CndSet("APT::Color::Highlight", "\x1B[32m");
+ _config->CndSet("APT::Color::Bold", "\x1B[1m");
_config->CndSet("APT::Color::Neutral", "\x1B[0m");
_config->CndSet("APT::Color::Red", "\x1B[31m");
@@ -103,6 +106,14 @@ bool InitOutput(std::basic_streambuf<char> * const out) /*{{{*/
_config->CndSet("APT::Color::Magenta", "\x1B[35m");
_config->CndSet("APT::Color::Cyan", "\x1B[36m");
_config->CndSet("APT::Color::White", "\x1B[37m");
+
+ _config->CndSet("APT::Color::Action::Upgrade", "green");
+ _config->CndSet("APT::Color::Action::Install", "green");
+ _config->CndSet("APT::Color::Action::Install-Dependencies", "green");
+ _config->CndSet("APT::Color::Action::Downgrade", "yellow");
+ _config->CndSet("APT::Color::Action::Remove", "red");
+ _config->CndSet("APT::Color::Show::Field", "\x1B[1m");
+ _config->CndSet("APT::Color::Show::Package", "\x1B[32m");
}
return true;
@@ -302,8 +313,8 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
else if (V.ParentPkg()->CurrentState == pkgCache::State::ConfigFiles)
StatusStr = _("[residual-config]");
output = SubstVar(output, "${apt:Status}", StatusStr);
- output = SubstVar(output, "${color:highlight}", _config->Find("APT::Color::Highlight", ""));
- output = SubstVar(output, "${color:neutral}", _config->Find("APT::Color::Neutral", ""));
+ output = SubstVar(output, "${color:highlight}", color("Highlight"));
+ output = SubstVar(output, "${color:neutral}", color("Neutral"));
output = SubstVar(output, "${Description}", GetShortDescription(CacheFile, records, P));
if (output.find("${LongDescription}") != string::npos)
output = SubstVar(output, "${LongDescription}", GetLongDescription(CacheFile, records, P));
@@ -555,7 +566,7 @@ void ShowNew(ostream &out,CacheFile &Cache)
[&Cache](pkgCache::PkgIterator const &Pkg) { return Cache[Pkg].NewInstall(); },
&PrettyFullName,
CandidateVersion(&Cache),
- "APT::Color::Green");
+ "action::install");
return;
}
@@ -563,12 +574,12 @@ void ShowNew(ostream &out,CacheFile &Cache)
[&Cache](pkgCache::PkgIterator const &Pkg) { return Cache[Pkg].NewInstall() && (Cache[Pkg].Flags & pkgCache::Flag::Auto) == 0; },
&PrettyFullName,
CandidateVersion(&Cache),
- "APT::Color::Green");
+ "action::install");
ShowList(out,_("Installing dependencies:"), Universe,
[&Cache](pkgCache::PkgIterator const &Pkg) { return Cache[Pkg].NewInstall() && Cache[Pkg].Flags & pkgCache::Flag::Auto;},
&PrettyFullName,
CandidateVersion(&Cache),
- "APT::Color::Green");
+ "action::install-dependencies");
}
/*}}}*/
// ShowDel - Show packages to delete /*{{{*/
@@ -586,7 +597,7 @@ void ShowDel(ostream &out,CacheFile &Cache)
return str;
},
CandidateVersion(&Cache),
- "APT::Color::Red");
+ "action::remove");
}
/*}}}*/
// ShowPhasing - Show packages kept due to phasing /*{{{*/
@@ -625,7 +636,7 @@ void ShowUpgraded(ostream &out,CacheFile &Cache)
},
&PrettyFullName,
CurrentToCandidateVersion(&Cache),
- "APT::Color::Green");
+ "action::upgrade");
}
/*}}}*/
// ShowDowngraded - Show downgraded packages /*{{{*/
@@ -642,7 +653,7 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache)
},
&PrettyFullName,
CurrentToCandidateVersion(&Cache),
- "APT::Color::Yellow");
+ "action::downgrade");
}
/*}}}*/
// ShowHold - Show held but changed packages /*{{{*/
@@ -791,10 +802,12 @@ bool YnPrompt(char const * const Question, bool const Default, bool const ShowGl
// if we ask interactively, show warnings/notices before the question
if (ShowGlobalErrors == true && AssumeYes == false && AssumeNo == false)
{
- if (_config->FindI("quiet",0) > 0)
+ if (_config->FindB("APT::Audit"))
+ _error->DumpErrors(c2o, GlobalError::AUDIT);
+ else if (_config->FindI("quiet",0) > 0)
_error->DumpErrors(c2o);
else
- _error->DumpErrors(c2o, GlobalError::DEBUG);
+ _error->DumpErrors(c2o, GlobalError::NOTICE);
}
c2o << Question << std::flush;
diff --git a/apt-private/private-output.h b/apt-private/private-output.h
index 4cc7c01..0eba6f4 100644
--- a/apt-private/private-output.h
+++ b/apt-private/private-output.h
@@ -1,6 +1,7 @@
#ifndef APT_PRIVATE_OUTPUT_H
#define APT_PRIVATE_OUTPUT_H
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/macros.h>
@@ -18,7 +19,6 @@ class CacheFile;
class pkgDepCache;
class pkgRecords;
-
APT_PUBLIC extern std::ostream c0out;
APT_PUBLIC extern std::ostream c1out;
APT_PUBLIC extern std::ostream c2out;
@@ -43,7 +43,8 @@ template<class Container, class PredicateC, class DisplayP, class DisplayV> bool
PredicateC Predicate,
DisplayP PkgDisplay,
DisplayV VerboseDisplay,
- std::string colorName = "APT::Color::Neutral")
+ std::string colorName = "",
+ std::string Note = "")
{
size_t const ScreenWidth = (::ScreenWidth > 3) ? ::ScreenWidth - 3 : 0;
int ScreenUsed = 0;
@@ -52,8 +53,8 @@ template<class Container, class PredicateC, class DisplayP, class DisplayV> bool
bool printedTitle = false;
std::vector<std::string> PackageList;
- auto setColor = _config->FindI("APT::Output-Version") >= 30 ? _config->Find(colorName) : "";
- auto resetColor = _config->FindI("APT::Output-Version") >= 30 ? _config->Find("APT::Color::Neutral") : "";
+ auto setColor = APT::Configuration::color(colorName);
+ auto resetColor = not setColor.empty() ? APT::Configuration::color("neutral") : "";
for (auto const &Pkg: cont)
{
@@ -105,6 +106,8 @@ template<class Container, class PredicateC, class DisplayP, class DisplayV> bool
ShowWithColumns(out, PackageList, 2, ScreenWidth);
out << resetColor;
}
+ if (not Note.empty())
+ out << Note << std::endl;
if (_config->FindI("APT::Output-Version") >= 30)
out << std::endl;
return false;
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index cefbd9b..4ae0430 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -1,6 +1,7 @@
// Includes /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/cmndline.h>
@@ -33,6 +34,8 @@
#include <apti18n.h>
/*}}}*/
+using APT::Configuration::color;
+
pkgRecords::Parser &LookupParser(pkgRecords &Recs, pkgCache::VerIterator const &V, pkgCache::VerFileIterator &Vf) /*{{{*/
{
Vf = V.FileList();
@@ -271,7 +274,8 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
RW.push_back(pkgTagSection::Tag::Remove("Description"));
RW.push_back(pkgTagSection::Tag::Remove("Description-md5"));
// improve
- RW.push_back(pkgTagSection::Tag::Rewrite("Package", V.ParentPkg().FullName(true)));
+ RW.push_back(pkgTagSection::Tag::Rewrite("Package", color("Show::Package", V.ParentPkg().FullName(true))));
+
RW.push_back(pkgTagSection::Tag::Rewrite("Installed-Size", installed_size));
RW.push_back(pkgTagSection::Tag::Remove("Size"));
RW.push_back(pkgTagSection::Tag::Rewrite("Download-Size", package_size));
@@ -282,7 +286,7 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
FileFd stdoutfd;
if (stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false) == false ||
- Tags.Write(stdoutfd, TFRewritePackageOrder, RW) == false || stdoutfd.Close() == false)
+ Tags.Write(stdoutfd, pkgTagSection::WRITE_HUMAN, TFRewritePackageOrder, RW) == false || stdoutfd.Close() == false)
return _error->Error("Internal Error, Unable to parse a package record");
// write the description
@@ -291,7 +295,7 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
if (Desc.end() == false)
{
pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- out << "Description: " << P.LongDesc();
+ out << color("Show::Field", "Description: ") << P.LongDesc();
}
// write a final newline (after the description)
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index cc0753c..6edde05 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -266,7 +266,11 @@ bool DoUpdate()
if (upgradable == 0)
c1out << _("All packages are up to date.") << std::endl;
else
- ioprintf(c1out, msg, upgradable);
+ {
+ c1out << _config->Find("APT::Color::Bold");
+ ioprintf(c1out, msg, upgradable);
+ c1out << _config->Find("APT::Color::Neutral");
+ }
RunScripts("APT::Update::Post-Invoke-Stats");
}