Bug#755088: please show removals *last* in dist-upgrade
On Thu, Jul 17, 2014 at 12:28:09PM -0400, Joey Hess wrote:
> Package: apt
> Version: 1.0.5
> Severity: wishlist
Thanks for your bugreport.
> Many of apt's users are human, and thus prone to making mistakes. A common
> mistake seems to be running apt-get dist-upgrade and not noticing that it wants
> to remove your backup system and/or terminal emulator and/or steam. Or not
> noticing that it wants to install horrible-enormous-thing and/or steam. It
> doesn't help that the message about this is buried in the middle of masses of
> other data that are liable to be skimmed at best, and scroll right off the
> terminal at worst.
[..]
> So, I suggest sorting the output with the most important items last,
> to go with the UPPERCASE highlighting apt already gives them.
This is a excellent idea!
Attached is a patch that implements it as the new default for
"apt". As for apt-get I am a little bit concerned that changing this
breaks some peoples workflow. So maybe switching the default for
apt-get in 1.2? Or am I too conservative here :) ?
Cheers,
Michael
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index e08cd80..58639b2 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -61,19 +61,33 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
bool Fail = false;
bool Essential = false;
- // Show all the various warning indicators
- ShowDel(c1out,Cache);
- ShowNew(c1out,Cache);
- if (ShwKept == true)
- ShowKept(c1out,Cache);
- Fail |= !ShowHold(c1out,Cache);
- if (_config->FindB("APT::Get::Show-Upgraded",true) == true)
- ShowUpgraded(c1out,Cache);
+ // Show all the various warning indicators in the users prefered way
+ std::vector<std::string> StatsOrder = _config->FindVector(
+ "APT::Cmd::Stats-Order", "remove,new,keep,hold,upgrade,stats");
+ for(std::vector<std::string>::const_iterator I = StatsOrder.begin();
+ I != StatsOrder.end(); ++I)
+ {
+ if(*I == "remove")
+ ShowDel(c1out,Cache);
+ else if (*I == "new")
+ ShowNew(c1out,Cache);
+ else if (*I == "keep")
+ {
+ if (ShwKept == true)
+ ShowKept(c1out,Cache);
+ } else if (*I == "hold")
+ Fail |= !ShowHold(c1out,Cache);
+ else if (*I == "upgrade")
+ {
+ if (_config->FindB("APT::Get::Show-Upgraded",true) == true)
+ ShowUpgraded(c1out,Cache);
+ } else if (*I == "stats")
+ Stats(c1out,Cache);
+ }
Fail |= !ShowDowngraded(c1out,Cache);
if (_config->FindB("APT::Get::Download-Only",false) == false)
- Essential = !ShowEssential(c1out,Cache);
+ Essential = !ShowEssential(c1out,Cache);
Fail |= Essential;
- Stats(c1out,Cache);
// Sanity check
if (Cache->BrokenCount() != 0)
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 2cfdf8e..329c33d 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -117,6 +117,8 @@ int main(int argc, const char *argv[]) /*{{{*/
_config->CndSet("Apt::Color", "1");
_config->CndSet("APT::Get::Upgrade-Allow-New", true);
_config->CndSet("APT::Cmd::Show-Update-Stats", true);
+ _config->CndSet("APT::Cmd::Stats-Order",
+ "keep,hold,upgrade,new,remove,stats");
// Parse the command line and initialize the package library
CommandLine CmdL(Args.data(), _config);
diff --git a/test/integration/test-apt-get-upgrade b/test/integration/test-apt-get-upgrade
index 2344629..44f6a80 100755
--- a/test/integration/test-apt-get-upgrade
+++ b/test/integration/test-apt-get-upgrade
@@ -76,3 +76,28 @@ Conf new-dep (1.0 stable [all])
Conf upgrade-simple (2.0 unstable [all])
Conf upgrade-with-new-dep (2.0 unstable [all])' aptget -s dist-upgrade
+# see if we can customize the order
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+ upgrade-simple upgrade-with-conflict upgrade-with-new-dep
+The following NEW packages will be installed:
+ new-dep
+The following packages will be REMOVED:
+ conflicting-dep
+3 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' aptget --trivial-only dist-upgrade -o Apt::Cmd::Stats-Order="keep,hold,upgrade,new,remove,stats"
+
+# the cmdline "apt" has a different default ordering
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+ upgrade-simple upgrade-with-conflict upgrade-with-new-dep
+The following NEW packages will be installed:
+ new-dep
+The following packages will be REMOVED:
+ conflicting-dep
+3 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' apt --trivial-only full-upgrade
Reply to: