Bug#745130: apt should tell if updates are available
On Fri, Apr 18, 2014 at 05:13:46PM +0200, David Kalnischkies wrote:
> On Fri, Apr 18, 2014 at 02:44:06PM +0530, shirish शिरीष wrote:
> > I tried apt few days back and it's refreshing from aptitude in the
> > sense it doesn't take as many resources as aptitude to update the
> > index. There is one issue though, it doesn't tell if there are any
> > updates and I have to manually run aptitude safe-upgrade in order to
> > figure out if there are any updates or not.
> […]
> > Unlike aptitude, apt doesn't tell if there are any updates. Just
> > having that info. would make my life much easier.
>
> Could you perhaps mention what sort of info that might be and in which
> form? Also what 'updates' are in this context depends on which
> operation will be used to apply these updates (think: ugrade vs.
> dist-upgrade), so I would tend to say no at the moment as I don't know
> which info you ask for here and displaying potentially wrong info
> could be confusing at best and might even be dangerous.
> (a package manager confusing its users is never a good idea)
>
> (/me has never really used aptitude)
[..]
I like the idea, attached is a trivial patch that implements some very
simple information for "apt update". But I agree with Davids concerns,
that we need to be careful about the message displayed to avoid
confusing the users.
Cheers,
Michael
>From 72610548d2993e30fb5b8d633044c7f2af3fb392 Mon Sep 17 00:00:00 2001
From: Michael Vogt <mvo@debian.org>
Date: Tue, 22 Apr 2014 16:07:32 +0200
Subject: [PATCH] show upgradable packages after apt update
---
apt-private/private-update.cc | 18 ++++++++++++++++++
cmdline/apt.cc | 1 +
test/integration/test-apt-cli-update | 17 +++++++++++++++++
3 files changed, 36 insertions(+)
create mode 100755 test/integration/test-apt-cli-update
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index da83d77..fa827de 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -75,6 +75,24 @@ bool DoUpdate(CommandLine &CmdL)
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;
}
/*}}}*/
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 4813861..8a6f96a 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -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("APT::Cmd::Show-Update-Stats", true);
// 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
index 0000000..8237bf0
--- /dev/null
+++ b/test/integration/test-apt-cli-update
@@ -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
--
1.9.1
Reply to: