]> git.saurik.com Git - apt.git/commitdiff
new quiet level -qq for apt to hide progress output
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 25 Oct 2015 11:35:00 +0000 (12:35 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Wed, 4 Nov 2015 17:04:03 +0000 (18:04 +0100)
-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…

12 files changed:
apt-pkg/contrib/progress.cc
apt-private/acqprogress.cc
apt-private/private-download.cc
apt-private/private-download.h
apt-private/private-install.cc
apt-private/private-update.cc
cmdline/apt-get.cc
cmdline/apt-helper.cc
cmdline/apt.cc
test/integration/test-apt-cli-update
test/integration/test-apt-update-nofallback
test/integration/test-apt-update-rollback

index 4ff4f181d0cb547b8591e1fcf426e6e92d2d35b9..b9301815495d053650da7b9206b2e21be972a975 100644 (file)
@@ -132,7 +132,7 @@ OpTextProgress::OpTextProgress(Configuration &Config) :
 {
    if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
       NoUpdate = true;
 {
    if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
       NoUpdate = true;
-   if (Config.FindI("quiet",0) >= 2)
+   if (Config.FindI("quiet",0) >= 2 || Config.FindB("quiet::NoProgress", false) == true)
       NoDisplay = true;
 }
                                                                        /*}}}*/
       NoDisplay = true;
 }
                                                                        /*}}}*/
index 62b2c13d0b55628df13be66db665ad72a46f9739..dcc538a3969b4eb168b14244827c178b668df4fc 100644 (file)
@@ -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;
    // 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                      /*{{{*/
 }
                                                                        /*}}}*/
 // AcqTextStatus::Start - Downloading has started                      /*{{{*/
index 8a57ccc869d2d21470d75c5d657f6d6fc9b56f05..96d44b1c5c88a9bad53d84458e893570301d6a10 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <apt-private/private-output.h>
 #include <apt-private/private-download.h>
 
 #include <apt-private/private-output.h>
 #include <apt-private/private-download.h>
+#include <apt-private/acqprogress.h>
 
 #include <fstream>
 #include <string>
 
 #include <fstream>
 #include <string>
@@ -39,8 +40,8 @@ bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
 
    return AuthPrompt(UntrustedList, PromptUser);
 }
 
    return AuthPrompt(UntrustedList, PromptUser);
 }
-
-bool AuthPrompt(std::vector<std::string> const &UntrustedList, bool const PromptUser)
+                                                                       /*}}}*/
+bool AuthPrompt(std::vector<std::string> const &UntrustedList, bool const PromptUser)/*{{{*/
 {
    ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"), UntrustedList,
         [](std::string const&) { return true; },
 {
    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;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
+
+aptAcquireWithTextStatus::aptAcquireWithTextStatus() : pkgAcquire::pkgAcquire(),
+   Stat(std::cout, ScreenWidth, _config->FindI("quiet",0))
+{
+   SetLog(&Stat);
+}
index 80643e0f2e846522f943cf65b0458fca1e021d0a..7df8f284a1803d46de35e01bea517dc639dbe27b 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef APT_PRIVATE_DOWNLOAD_H
 #define APT_PRIVATE_DOWNLOAD_H
 
 #ifndef APT_PRIVATE_DOWNLOAD_H
 #define APT_PRIVATE_DOWNLOAD_H
 
+#include <apt-pkg/acquire.h>
 #include <apt-pkg/macros.h>
 
 #include <apt-pkg/macros.h>
 
+#include <apt-private/acqprogress.h>
+
 #include <string>
 #include <vector>
 
 #include <string>
 #include <vector>
 
-class pkgAcquire;
-
 // Check if all files in the fetcher are authenticated
 APT_PUBLIC bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
 
 // 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);
 
 
 APT_PUBLIC bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long FetchBytes);
 
+class APT_PUBLIC aptAcquireWithTextStatus : public pkgAcquire
+{
+   AcqTextStatus Stat;
+public:
+   aptAcquireWithTextStatus();
+};
+
 #endif
 #endif
index dda5b50bec6bba31347e80c6d0002714ca3c9247..52572ed8029db8eaef28fc05e3f8e0167cc2c3c2 100644 (file)
@@ -134,8 +134,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
       return false;
 
    // Create the download object
       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
    if (_config->FindB("APT::Get::Print-URIs", false) == true)
    {
       // force a hashsum for compatibility reasons
index 1323771f0b8747417f23739f38070b51249965b5..1e5d695126827ed5d83669e74f945cc14853f876 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-cachefile.h>
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-cachefile.h>
+#include <apt-private/private-download.h>
 #include <apt-private/private-output.h>
 #include <apt-private/private-update.h>
 
 #include <apt-private/private-output.h>
 #include <apt-private/private-update.h>
 
@@ -37,20 +38,15 @@ bool DoUpdate(CommandLine &CmdL)
       return false;
    pkgSourceList *List = Cache.GetSourceList();
 
       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");
 
    // 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)
       // (GetAll=true)
+      aptAcquireWithTextStatus Fetcher;
       if (List->GetIndexes(&Fetcher,true) == false)
         return false;
 
       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)
 
    // 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)
 
    // Rebuild the cache.
    if (_config->FindB("pkgCacheFile::Generate", true) == true)
index 1379c607ed064c6398d3c60d0ca85c514fb93599..2a19360c8b6b74db81ca7b9829abb17211dfc5e3 100644 (file)
@@ -595,14 +595,12 @@ static bool DoDownload(CommandLine &CmdL)
    if (verset.empty() == true)
       return false;
 
    if (verset.empty() == true)
       return false;
 
-   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
-   pkgAcquire Fetcher(&Stat);
-
    pkgRecords Recs(Cache);
    pkgSourceList *SrcList = Cache.GetSourceList();
 
    // reuse the usual acquire methods for deb files, but don't drop them into
    // the usual directories - keep everything in the current directory
    pkgRecords Recs(Cache);
    pkgSourceList *SrcList = Cache.GetSourceList();
 
    // reuse the usual acquire methods for deb files, but don't drop them into
    // the usual directories - keep everything in the current directory
+   aptAcquireWithTextStatus Fetcher;
    std::vector<std::string> storefile(verset.size());
    std::string const cwd = SafeGetCWD();
    _config->Set("Dir::Cache::Archives", cwd);
    std::vector<std::string> storefile(verset.size());
    std::string const cwd = SafeGetCWD();
    _config->Set("Dir::Cache::Archives", cwd);
@@ -693,10 +691,6 @@ static bool DoSource(CommandLine &CmdL)
    if (_error->PendingError() == true)
       return false;
 
    if (_error->PendingError() == true)
       return false;
 
-   // Create the download object
-   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
-   pkgAcquire Fetcher(&Stat);
-
    std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
    
    // insert all downloaded uris into this set to avoid downloading them
    std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
    
    // insert all downloaded uris into this set to avoid downloading them
@@ -711,6 +705,7 @@ static bool DoSource(CommandLine &CmdL)
    bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
 
    // Load the requestd sources into the fetcher
    bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
 
    // Load the requestd sources into the fetcher
+   aptAcquireWithTextStatus Fetcher;
    unsigned J = 0;
    std::vector<std::string> UntrustedList;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
    unsigned J = 0;
    std::vector<std::string> UntrustedList;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
@@ -1368,13 +1363,11 @@ static bool DoChangelog(CommandLine &CmdL)
                CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
    if (verset.empty() == true)
       return false;
                CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
    if (verset.empty() == true)
       return false;
-   pkgAcquire Fetcher;
-   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
-   Fetcher.SetLog(&Stat);
 
    bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
    bool const printOnly = _config->FindB("APT::Get::Print-URIs", false);
 
 
    bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
    bool const printOnly = _config->FindB("APT::Get::Print-URIs", false);
 
+   aptAcquireWithTextStatus Fetcher;
    for (APT::VersionList::const_iterator Ver = verset.begin();
         Ver != verset.end();
         ++Ver)
    for (APT::VersionList::const_iterator Ver = verset.begin();
         Ver != verset.end();
         ++Ver)
index ff9061dc79c3cafee4f365bb179528320b6f224d..186fded17b82ac2d26b2e2d88f16a6ac8c38cc11 100644 (file)
@@ -50,9 +50,7 @@ static bool DoDownloadFile(CommandLine &CmdL)
    if (CmdL.FileSize() <= 2)
       return _error->Error(_("Must specify at least one pair url/filename"));
 
    if (CmdL.FileSize() <= 2)
       return _error->Error(_("Must specify at least one pair url/filename"));
 
-   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
-   pkgAcquire Fetcher(&Stat);
-
+   aptAcquireWithTextStatus Fetcher;
    size_t fileind = 0;
    std::vector<std::string> targetfiles;
    while (fileind + 2 <= CmdL.FileSize())
    size_t fileind = 0;
    std::vector<std::string> targetfiles;
    while (fileind + 2 <= CmdL.FileSize())
index 98e715625f00eaddcd260cc547389c7792d096fc..eb16b561c36cd5cb79b14630712409d92227cbeb 100644 (file)
 
 static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
 {
 
 static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
 {
-   ioprintf(c1out, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
+   ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
 
    // FIXME: generate from CommandLine
 
    // FIXME: generate from CommandLine
-   c1out <<
+   std::cout <<
     _("Usage: apt [options] command\n"
       "\n"
       "CLI for apt.\n")
     _("Usage: apt [options] command\n"
       "\n"
       "CLI for apt.\n")
@@ -87,13 +87,19 @@ int main(int argc, const char *argv[])                                      /*{{{*/
       {nullptr, nullptr, nullptr}
    };
 
       {nullptr, nullptr, nullptr}
    };
 
-   // FIXME: Those ignore commandline configuration like -q
-   InitSignals();
-   InitOutput();
-
    CommandLine CmdL;
    ParseCommandLine(CmdL, Cmds, "apt", &_config, &_system, argc, argv, ShowHelp);
 
    CommandLine CmdL;
    ParseCommandLine(CmdL, Cmds, "apt", &_config, &_system, argc, argv, ShowHelp);
 
+   int const quiet = _config->FindI("quiet", 0);
+   if (quiet == 2)
+   {
+      _config->CndSet("quiet::NoProgress", true);
+      _config->Set("quiet", 1);
+   }
+
+   InitSignals();
+   InitOutput();
+
    CheckIfCalledByScript(argc, argv);
    CheckIfSimulateMode(CmdL);
 
    CheckIfCalledByScript(argc, argv);
    CheckIfSimulateMode(CmdL);
 
index dad365f7e918509cd22214a5fc0231bb906faf11..5d85034040e1aa42a0de924973ec440072002bdf 100755 (executable)
@@ -15,8 +15,8 @@ setupaptarchive --no-update
 
 testfailuremsg 'E: The update command takes no arguments' apt update arguments
 
 
 testfailuremsg 'E: The update command takes no arguments' apt update arguments
 
-testsuccessequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -q
+testsuccessequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -qq
 
 cp dpkg.status rootdir/var/lib/dpkg/status
 insertinstalledpackage 'foo' 'all' '2.0'
 
 cp dpkg.status rootdir/var/lib/dpkg/status
 insertinstalledpackage 'foo' 'all' '2.0'
-testsuccessequal 'All packages are up to date.' apt update -q
+testsuccessequal 'All packages are up to date.' apt update -qq
index 1b23d4f11cc09420817273f64dca1aec03e7ba0a..a12a08ab1cc38bc91f963ac725863e25f3bb9976 100755 (executable)
@@ -42,7 +42,7 @@ N: See apt-secure(8) manpage for repository creation and user configuration deta
 
 assert_repo_is_intact()
 {
 
 assert_repo_is_intact()
 {
-    testsuccessequal "foo/unstable 2.0 all" apt list -q
+    testsuccessequal "foo/unstable 2.0 all" apt list -qq
     testsuccess aptget install -y -s foo
     testfailure aptget install -y evil
     testsuccess aptget source foo --print-uris
     testsuccess aptget install -y -s foo
     testfailure aptget install -y evil
     testsuccess aptget source foo --print-uris
index 12d541055fc94f7eef8d59dddde8ab24c933684b..e19240206669ef4c23e3b42fc438851662e3f5ea 100755 (executable)
@@ -38,7 +38,7 @@ start_with_good_inrelease() {
     create_fresh_archive
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
     create_fresh_archive
     testsuccess aptget update
     listcurrentlistsdirectory > lists.before
-    testsuccessequal 'old/unstable 1.0 all' apt list -q
+    testsuccessequal 'old/unstable 1.0 all' apt list -qq
 }
 
 test_inrelease_to_new_inrelease() {
 }
 
 test_inrelease_to_new_inrelease() {
@@ -48,7 +48,7 @@ test_inrelease_to_new_inrelease() {
     add_new_package '+1hour'
     testsuccess aptget update -o Debug::Acquire::Transaction=1
     testsuccessequal 'new/unstable 1.0 all
     add_new_package '+1hour'
     testsuccess aptget update -o Debug::Acquire::Transaction=1
     testsuccessequal 'new/unstable 1.0 all
-old/unstable 1.0 all' apt list -q
+old/unstable 1.0 all' apt list -qq
 }
 
 test_inrelease_to_broken_hash_reverts_all() {
 }
 
 test_inrelease_to_broken_hash_reverts_all() {