summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-02-18 21:20:57 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-02-18 21:20:57 +0100
commitca5e41fdced7a5566b07dfc2d6adc67d74fa2d93 (patch)
tree03a16086dcfb3447189c6577cd0606ce412fed93
parent0c73b84b001028338c0862c045c0cc4e6b191fcb (diff)
improve 'error' message for packages which are only referenced
e.g. in a Depends line and are now requested for removal
-rw-r--r--cmdline/apt-get.cc31
-rw-r--r--debian/changelog4
-rwxr-xr-xtest/integration/test-suggest-installed-multiarch-silbing14
3 files changed, 43 insertions, 6 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 42a3929d6..f4ad75d1c 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -713,11 +713,32 @@ public:
}
virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
- APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST);
- if (verset.empty() == false)
- return *(verset.begin());
- if (ShowError == true)
- ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str());
+ if (Pkg->ProvidesList != 0)
+ {
+ APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST);
+ if (verset.empty() == false)
+ return *(verset.begin());
+ if (ShowError == true)
+ ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str());
+ }
+ else
+ {
+ pkgCache::GrpIterator Grp = Pkg.Group();
+ pkgCache::PkgIterator P = Grp.PackageList();
+ for (; P.end() != true; P = Grp.NextPkg(P))
+ {
+ if (P == Pkg)
+ continue;
+ if (P->CurrentVer != 0) {
+ // TRANSLATORS: Note, this is not an interactive question
+ ioprintf(c1out,_("Package '%s' is not installed, so not removed. Did you mean '%s'?\n"),
+ Pkg.FullName(true).c_str(), P.FullName(true).c_str());
+ break;
+ }
+ }
+ if (P.end() == true)
+ ioprintf(c1out,_("Package '%s' is not installed, so not removed\n"),Pkg.FullName(true).c_str());
+ }
return pkgCache::VerIterator(Cache, 0);
}
diff --git a/debian/changelog b/debian/changelog
index d06e48dbb..b62bd3aef 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -36,6 +36,8 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
* cmdline/apt-get.cc:
- if a package can't be removed as it is not installed, suggest to
the user an (installed) multiarch silbing with 'Did you mean?'
+ - improve 'error' message for packages which are only referenced
+ e.g. in a Depends line and are now requested for removal
[ Steve Langasek ]
* cmdline/apt-get.cc:
@@ -58,7 +60,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
* apt-pkg/contrib/fileutl.h:
- fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode
- -- David Kalnischkies <kalnischkies@gmail.com> Sat, 18 Feb 2012 20:41:32 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com> Sat, 18 Feb 2012 21:19:25 +0100
apt (0.8.16~exp12) experimental; urgency=low
diff --git a/test/integration/test-suggest-installed-multiarch-silbing b/test/integration/test-suggest-installed-multiarch-silbing
index ca6d7bd2e..d55d250aa 100755
--- a/test/integration/test-suggest-installed-multiarch-silbing
+++ b/test/integration/test-suggest-installed-multiarch-silbing
@@ -21,6 +21,10 @@ insertpackage 'unstable' 'samefoo' 'amd64,i386,armel' '1' 'Multi-Arch: same'
insertinstalledpackage 'samefoo2' 'i386' '1' 'Multi-Arch: same'
insertpackage 'unstable' 'samefoo2' 'amd64,i386,armel' '1' 'Multi-Arch: same'
+insertinstalledpackage 'mozplugger' 'i386' '1' 'Depends: iceweasel | fireweasel'
+insertinstalledpackage 'fireweasel' 'i386' '1'
+insertpackage 'unstable' 'mozplugger' 'i386,amd64' '1' 'Depends: iceweasel | fireweasel'
+
setupaptarchive
testequal "Reading package lists...
@@ -64,3 +68,13 @@ testequal "Reading package lists...
Building dependency tree...
Package 'samefoo2:armel' is not installed, so not removed. Did you mean 'samefoo2:i386'?
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove samefoo2:armel -s
+
+testequal "Reading package lists...
+Building dependency tree...
+Package 'iceweasel' is not installed, so not removed
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove iceweasel -s
+
+testequal "Reading package lists...
+Building dependency tree...
+Package 'fireweasel' is not installed, so not removed. Did you mean 'fireweasel:i386'?
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove fireweasel:amd64 -s