]> git.saurik.com Git - apt.git/commitdiff
show upgradable packages after apt update
authorMichael Vogt <mvo@debian.org>
Tue, 22 Apr 2014 14:07:32 +0000 (16:07 +0200)
committerMichael Vogt <mvo@debian.org>
Thu, 22 May 2014 06:39:44 +0000 (08:39 +0200)
Closes: 748389
apt-private/private-update.cc
cmdline/apt.cc
test/integration/test-apt-cli-update [new file with mode: 0755]

index da83d7741e6cdcc33af0086c8ec10de522f94437..fa827dea4216bd3689fa8d8ec15bb77c22d40897 100644 (file)
@@ -75,6 +75,24 @@ bool DoUpdate(CommandLine &CmdL)
         return false;
    }
 
         return false;
    }
 
+   // show basic stats (if the user whishes)
+   if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true)
+   {
+      int upgradable = 0;
+      Cache.Open();
+      for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
+      {
+         pkgDepCache::StateCache &state = Cache[I];
+         if (I->CurrentVer != 0 && state.Upgradable())
+            upgradable++;
+      }
+      const char *msg = ngettext(
+         "%i package can be upgraded. Run 'apt list --upgradable' to see it.\n",
+         "%i packages can be upgraded. Run 'apt list --upgradable' to see them.\n",
+         upgradable);
+      ioprintf(c1out, msg, upgradable);
+   }
+
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
index 4813861a441a61d88cc8c93758a535d2fc07a8e8..8a6f96aea8229e8933e1cb9a9c18a1d1535d17bf 100644 (file)
@@ -112,6 +112,7 @@ int main(int argc, const char *argv[])                                      /*{{{*/
    _config->CndSet("DPkg::Progress-Fancy", "1");
    _config->CndSet("Apt::Color", "1");
    _config->CndSet("APT::Get::Upgrade-Allow-New", true);
    _config->CndSet("DPkg::Progress-Fancy", "1");
    _config->CndSet("Apt::Color", "1");
    _config->CndSet("APT::Get::Upgrade-Allow-New", true);
+   _config->CndSet("APT::Cmd::Show-Update-Stats", true);
 
    // Parse the command line and initialize the package library
    CommandLine CmdL(Args.data(), _config);
 
    // Parse the command line and initialize the package library
    CommandLine CmdL(Args.data(), _config);
diff --git a/test/integration/test-apt-cli-update b/test/integration/test-apt-cli-update
new file mode 100755 (executable)
index 0000000..8237bf0
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'foo' 'all' '2.0'
+insertinstalledpackage 'foo' 'all' '1.0'
+
+setupaptarchive
+
+APTARCHIVE=$(readlink -f ./aptarchive)
+
+testequal "1 package can be upgraded. Run 'apt list --upgradable' to see it." apt update -q