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

merged from donkult and fix dashish

Michael Vogt лет назад: 15
Родитель
Сommit
47f9af4f25

+ 43 - 0
cmdline/apt-get.cc

@@ -1659,6 +1659,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
 
 
    string autoremovelist, autoremoveversions;
    string autoremovelist, autoremoveversions;
    unsigned long autoRemoveCount = 0;
    unsigned long autoRemoveCount = 0;
+   APT::PackageSet tooMuch;
    // look over the cache to see what can be removed
    // look over the cache to see what can be removed
    for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
    for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
    {
    {
@@ -1681,7 +1682,10 @@ bool DoAutomaticRemove(CacheFile &Cache)
 	    // if the package is a new install and already garbage we don't need to
 	    // if the package is a new install and already garbage we don't need to
 	    // install it in the first place, so nuke it instead of show it
 	    // install it in the first place, so nuke it instead of show it
 	    if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0)
 	    if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0)
+	    {
 	       Cache->MarkDelete(Pkg, false);
 	       Cache->MarkDelete(Pkg, false);
+	       tooMuch.insert(Pkg);
+	    }
 	    // only show stuff in the list that is not yet marked for removal
 	    // only show stuff in the list that is not yet marked for removal
 	    else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) 
 	    else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) 
 	    {
 	    {
@@ -1697,6 +1701,45 @@ bool DoAutomaticRemove(CacheFile &Cache)
       }
       }
    }
    }
 
 
+   // we could have removed a new dependency of a garbage package,
+   // so check if a reverse depends is broken and if so install it again.
+   if (tooMuch.empty() == false && Cache->BrokenCount() != 0)
+   {
+      bool Changed;
+      do {
+	 Changed = false;
+	 for (APT::PackageSet::const_iterator P = tooMuch.begin();
+	      P != tooMuch.end() && Changed == false; ++P)
+	 {
+	    for (pkgCache::DepIterator R = P.RevDependsList();
+		 R.end() == false; ++R)
+	    {
+	       if (R->Type != pkgCache::Dep::Depends &&
+		   R->Type != pkgCache::Dep::PreDepends)
+		  continue;
+	       pkgCache::PkgIterator N = R.ParentPkg();
+	       if (N.end() == true || N->CurrentVer == 0)
+		  continue;
+	       if (Debug == true)
+		  std::clog << "Save " << P << " as another installed garbage package depends on it" << std::endl;
+	       Cache->MarkInstall(P, false);
+	       if(hideAutoRemove == false)
+	       {
+		  ++autoRemoveCount;
+		  if (smallList == false)
+		  {
+		     autoremovelist += P.FullName(true) + " ";
+		     autoremoveversions += string(Cache[P].CandVersion) + "\n";
+		  }
+	       }
+	       tooMuch.erase(P);
+	       Changed = true;
+	       break;
+	    }
+	 }
+      } while (Changed == true);
+   }
+
    // Now see if we had destroyed anything (if we had done anything)
    // Now see if we had destroyed anything (if we had done anything)
    if (Cache->BrokenCount() != 0)
    if (Cache->BrokenCount() != 0)
    {
    {

+ 7 - 1
debian/changelog

@@ -3,8 +3,14 @@ apt (0.8.11.4) UNRELEASED; urgency=low
   [ David Kalnischkies ]
   [ David Kalnischkies ]
   * apt-pkg/contrib/error.cc:
   * apt-pkg/contrib/error.cc:
     - ensure that va_list is not invalid in second try
     - ensure that va_list is not invalid in second try
+  * cmdline/apt-get.cc:
+    - don't remove new dependencies of garbage packages (Closes: #613420)
+  
+  [ Michael Vogt ]
+  * test/integration/*
+    - fix dashish in the integration tests
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Tue, 15 Feb 2011 13:09:57 +0100
+ -- Michael Vogt <mvo@debian.org>  Wed, 16 Feb 2011 14:36:03 +0100
 
 
 apt (0.8.11.3) unstable; urgency=low
 apt (0.8.11.3) unstable; urgency=low
 
 

+ 22 - 0
test/integration/status-bug-613420-new-garbage-dependency

@@ -0,0 +1,22 @@
+Package: openoffice.org-officebean
+Status: install ok installed
+Priority: optional
+Section: java
+Installed-Size: 1656
+Maintainer: Debian OpenOffice Team <debian-openoffice@lists.debian.org>
+Architecture: i386
+Source: openoffice.org
+Version: 1:3.2.1-11+squeeze2
+Depends: openoffice.org-core (= 1:3.2.1-11+squeeze2)
+Description: office productivity suite -- Java bean
+
+Package: openoffice.org-core
+Status: install ok installed
+Priority: optional
+Section: editors
+Installed-Size: 121724
+Maintainer: Debian OpenOffice Team <debian-openoffice@lists.debian.org>
+Architecture: i386
+Source: openoffice.org
+Version: 1:3.2.1-11+squeeze2
+Description: office productivity suite -- arch-dependent files

+ 37 - 0
test/integration/test-bug-613420-new-garbage-dependency

@@ -0,0 +1,37 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'libreoffice' 'all' '1:3.3.1~rc1-2' 'Depends: libreoffice-core'
+insertpackage 'unstable' 'libreoffice-core' 'all' '1:3.3.1~rc1-2' 'Conflicts: openoffice.org-core'
+insertpackage 'unstable' 'libreoffice-officebean' 'all' '1:3.3.1~rc1-2' 'Depends: libreoffice-core'
+insertpackage 'unstable' 'openoffice.org-officebean' 'all' '1:3.3.0-5' 'Depends: libreoffice-officebean'
+
+
+setupaptarchive
+
+touch rootdir/var/lib/apt/extended_states
+aptmark markauto openoffice.org-officebean
+testmarkedauto openoffice.org-officebean
+
+testequal "Reading package lists...
+Building dependency tree...
+Reading state information...
+The following packages were automatically installed and are no longer required:
+  openoffice.org-officebean libreoffice-officebean
+Use 'apt-get autoremove' to remove them.
+The following extra packages will be installed:
+  libreoffice-core libreoffice-officebean openoffice.org-officebean
+The following packages will be REMOVED:
+  openoffice.org-core
+The following NEW packages will be installed:
+  libreoffice libreoffice-core libreoffice-officebean
+The following packages will be upgraded:
+  openoffice.org-officebean
+1 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.
+After this operation, 126 MB disk space will be freed.
+E: Trivial Only specified but this is not a trivial operation." aptget install libreoffice --trivial-only

+ 1 - 1
test/libapt/run-tests

@@ -1,7 +1,7 @@
 #!/bin/sh
 #!/bin/sh
 set -e
 set -e
 
 
-local DIR=$(readlink -f $(dirname $0))
+DIR=$(readlink -f $(dirname $0))
 echo "Compiling the tests …"
 echo "Compiling the tests …"
 test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
 test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
 (cd $DIR && make)
 (cd $DIR && make)