diff options
-rw-r--r-- | cmdline/apt-get.cc | 18 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rwxr-xr-x | test/integration/test-suggest-installed-multiarch-silbing | 66 |
3 files changed, 87 insertions, 2 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 32ee46980..42a3929d6 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -904,7 +904,23 @@ struct TryToRemove { if ((Pkg->CurrentVer == 0 && PurgePkgs == false) || (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled)) { - ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); + 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 || (PurgePkgs == true && P->CurrentState != pkgCache::State::NotInstalled)) + { + // 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()); + // MarkInstall refuses to install packages on hold Pkg->SelectedState = pkgCache::State::Hold; } diff --git a/debian/changelog b/debian/changelog index 9e23311b6..d06e48dbb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,9 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low - use pdiff for Translation-* files if available (Closes: #657902) * ftparchive/writer.cc: - add 'Translation-*' to the default patterns + * 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?' [ Steve Langasek ] * cmdline/apt-get.cc: @@ -55,7 +58,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 19:44:16 +0100 + -- David Kalnischkies <kalnischkies@gmail.com> Sat, 18 Feb 2012 20:41:32 +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 new file mode 100755 index 000000000..ca6d7bd2e --- /dev/null +++ b/test/integration/test-suggest-installed-multiarch-silbing @@ -0,0 +1,66 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' 'armel' + +insertinstalledpackage 'foo' 'i386' '1' +insertpackage 'unstable' 'foo' 'amd64,i386' '1' + +insertinstalledpackage 'foo2' 'i386' '1' +insertpackage 'unstable' 'foo2' 'i386' '1' + +insertinstalledpackage 'foo3' 'amd64' '1' +insertpackage 'unstable' 'foo3' 'amd64,i386' '1' + +insertinstalledpackage 'samefoo' 'i386,amd64' '1' 'Multi-Arch: same' +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' + +setupaptarchive + +testequal "Reading package lists... +Building dependency tree... +Package 'foo' is not installed, so not removed. Did you mean 'foo:i386'? +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove foo -s + +testequal "Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + foo2:i386 +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv foo2:i386 [1]" aptget remove foo2 -s + +testequal "Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + foo3 +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv foo3 [1]" aptget remove foo3 -s + +testequal "Reading package lists... +Building dependency tree... +Package 'foo3:i386' is not installed, so not removed. Did you mean 'foo3'? +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove foo3:i386 -s + +testequalor2 "Reading package lists... +Building dependency tree... +Package 'samefoo:armel' is not installed, so not removed. Did you mean 'samefoo'? +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." "Reading package lists... +Building dependency tree... +Package 'samefoo:armel' is not installed, so not removed. Did you mean 'samefoo:i386'? +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove samefoo:armel -s + +testequal "Reading package lists... +Building dependency tree... +Package 'samefoo2' 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 -s + +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 |