From 2b0660b537581e9e65180e4cf1a94d763fd66847 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Oct 2015 12:35:00 +0100 Subject: new quiet level -qq for apt to hide progress output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -q is for logging and -qqq (old -qq) basically kills every output expect errors, so there should be a way of declaring a middleground in which the output of e.g. 'update' isn't as verbose, but still shows some things. The test framework was actually making use of by accident as it ignored the quiet level in output setup for apt before. Eventually we should figure out some better quiet levels for all tools… --- apt-private/acqprogress.cc | 2 ++ apt-private/private-download.cc | 11 +++++++++-- apt-private/private-download.h | 12 ++++++++++-- apt-private/private-install.cc | 3 +-- apt-private/private-update.cc | 15 +++++++-------- 5 files changed, 29 insertions(+), 14 deletions(-) (limited to 'apt-private') diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index 62b2c13d0..dcc538a39 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -37,6 +37,8 @@ AcqTextStatus::AcqTextStatus(std::ostream &out, unsigned int &ScreenWidth,unsign // testcases use it to disable pulses without disabling other user messages if (Quiet == 0 && _config->FindB("quiet::NoUpdate", false) == true) this->Quiet = 1; + if (Quiet < 2 && _config->FindB("quiet::NoProgress", false) == true) + this->Quiet = 2; } /*}}}*/ // AcqTextStatus::Start - Downloading has started /*{{{*/ diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 8a57ccc86..96d44b1c5 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -39,8 +40,8 @@ bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser) return AuthPrompt(UntrustedList, PromptUser); } - -bool AuthPrompt(std::vector const &UntrustedList, bool const PromptUser) + /*}}}*/ +bool AuthPrompt(std::vector const &UntrustedList, bool const PromptUser)/*{{{*/ { ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"), UntrustedList, [](std::string const&) { return true; }, @@ -148,3 +149,9 @@ bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long Fet return true; } /*}}}*/ + +aptAcquireWithTextStatus::aptAcquireWithTextStatus() : pkgAcquire::pkgAcquire(), + Stat(std::cout, ScreenWidth, _config->FindI("quiet",0)) +{ + SetLog(&Stat); +} diff --git a/apt-private/private-download.h b/apt-private/private-download.h index 80643e0f2..7df8f284a 100644 --- a/apt-private/private-download.h +++ b/apt-private/private-download.h @@ -1,13 +1,14 @@ #ifndef APT_PRIVATE_DOWNLOAD_H #define APT_PRIVATE_DOWNLOAD_H +#include #include +#include + #include #include -class pkgAcquire; - // Check if all files in the fetcher are authenticated APT_PUBLIC bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser); @@ -19,4 +20,11 @@ APT_PUBLIC bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * APT_PUBLIC bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long FetchBytes); +class APT_PUBLIC aptAcquireWithTextStatus : public pkgAcquire +{ + AcqTextStatus Stat; +public: + aptAcquireWithTextStatus(); +}; + #endif diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index dda5b50be..52572ed80 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -134,8 +134,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety) return false; // Create the download object - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); + aptAcquireWithTextStatus Fetcher; if (_config->FindB("APT::Get::Print-URIs", false) == true) { // force a hashsum for compatibility reasons diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc index 1323771f0..1e5d69512 100644 --- a/apt-private/private-update.cc +++ b/apt-private/private-update.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -37,20 +38,15 @@ bool DoUpdate(CommandLine &CmdL) return false; pkgSourceList *List = Cache.GetSourceList(); - // Create the progress - AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); - // Just print out the uris an exit if the --print-uris flag was used if (_config->FindB("APT::Get::Print-URIs") == true) { // force a hashsum for compatibility reasons _config->CndSet("Acquire::ForceHash", "md5sum"); - // get a fetcher - pkgAcquire Fetcher(&Stat); - - // Populate it with the source selection and get all Indexes + // Populate it with the source selection and get all Indexes // (GetAll=true) + aptAcquireWithTextStatus Fetcher; if (List->GetIndexes(&Fetcher,true) == false) return false; @@ -70,7 +66,10 @@ bool DoUpdate(CommandLine &CmdL) // do the work if (_config->FindB("APT::Get::Download",true) == true) - ListUpdate(Stat, *List); + { + AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0)); + ListUpdate(Stat, *List); + } // Rebuild the cache. if (_config->FindB("pkgCacheFile::Generate", true) == true) -- cgit v1.2.3