Просмотр исходного кода

improve 'error' message for packages which are only referenced
e.g. in a Depends line and are now requested for removal

David Kalnischkies лет назад: 14
Родитель
Сommit
ca5e41fdce
3 измененных файлов с 43 добавлено и 6 удалено
  1. 26 5
      cmdline/apt-get.cc
  2. 3 1
      debian/changelog
  3. 14 0
      test/integration/test-suggest-installed-multiarch-silbing

+ 26 - 5
cmdline/apt-get.cc

@@ -713,11 +713,32 @@ public:
 	}
 	}
 
 
 	virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
 	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);
 		return pkgCache::VerIterator(Cache, 0);
 	}
 	}
 
 

+ 3 - 1
debian/changelog

@@ -36,6 +36,8 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
   * cmdline/apt-get.cc:
   * cmdline/apt-get.cc:
     - if a package can't be removed as it is not installed, suggest to
     - if a package can't be removed as it is not installed, suggest to
       the user an (installed) multiarch silbing with 'Did you mean?'
       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 ]
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
   * cmdline/apt-get.cc:
@@ -58,7 +60,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
   * apt-pkg/contrib/fileutl.h:
   * apt-pkg/contrib/fileutl.h:
     - fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode
     - 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
 apt (0.8.16~exp12) experimental; urgency=low
 
 

+ 14 - 0
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'
 insertinstalledpackage 'samefoo2' 'i386' '1' 'Multi-Arch: same'
 insertpackage 'unstable' 'samefoo2' 'amd64,i386,armel' '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
 setupaptarchive
 
 
 testequal "Reading package lists...
 testequal "Reading package lists...
@@ -64,3 +68,13 @@ testequal "Reading package lists...
 Building dependency tree...
 Building dependency tree...
 Package 'samefoo2:armel' is not installed, so not removed. Did you mean 'samefoo2:i386'?
 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
 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