]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/packagemanager.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 3 Mar 2012 10:43:21 +0000 (11:43 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 3 Mar 2012 10:43:21 +0000 (11:43 +0100)
  - do not try to a void a breaks if the broken package pre-depends
    on the breaker, but let dpkg auto-deconfigure it

apt-pkg/packagemanager.cc
debian/changelog
test/integration/skip-avoid-avoiding-breaks-predepends [new file with mode: 0755]

index 2738a8a6b7479c4a293aea28b277a1f1d0455385..05eb1a06b755e2e6a202c22cad72ab168f43f54d 100644 (file)
@@ -680,7 +680,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
         {
            VerIterator Ver(Cache,*I);
            PkgIterator BrokenPkg = Ver.ParentPkg();
         {
            VerIterator Ver(Cache,*I);
            PkgIterator BrokenPkg = Ver.ParentPkg();
-           VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer);
            if (BrokenPkg.CurrentVer() != Ver)
            {
               if (Debug)
            if (BrokenPkg.CurrentVer() != Ver)
            {
               if (Debug)
@@ -695,20 +694,49 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
                  // This dependancy has already been dealt with by another SmartUnPack on Pkg
                  break;
               } else {
                  // This dependancy has already been dealt with by another SmartUnPack on Pkg
                  break;
               } else {
-                 // Found a break, so unpack the package,
+                 // Found a break, so see if we can unpack the package to avoid it
                  // but do not set loop if another SmartUnPack already deals with it
                  // but do not set loop if another SmartUnPack already deals with it
-                 if (Debug)
+                 VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer);
+                 bool circle = false;
+                 for (pkgCache::DepIterator D = InstallVer.DependsList(); D.end() == false; ++D)
+                 {
+                    if (D->Type != pkgCache::Dep::PreDepends)
+                       continue;
+                    SPtrArray<Version *> VL = D.AllTargets();
+                    for (Version **I = VL; *I != 0; ++I)
+                    {
+                       VerIterator V(Cache,*I);
+                       PkgIterator P = V.ParentPkg();
+                       // we are checking for installation as an easy 'protection' against or-groups and (unchosen) providers
+                       if (P->CurrentVer == 0 || P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V))
+                          continue;
+                       circle = true;
+                       break;
+                    }
+                    if (circle == true)
+                       break;
+                 }
+                 if (circle == true)
+                 {
+                    if (Debug)
+                       cout << OutputInDepth(Depth) << "  Avoiding " << End << " avoided as " << BrokenPkg.FullName() << " has a pre-depends on " << Pkg.FullName() << std::endl;
+                    continue;
+                 }
+                 else
                  {
                  {
-                    cout << OutputInDepth(Depth) << "  Unpacking " << BrokenPkg.Name() << " to avoid " << End;
-                    if (PkgLoop == true)
-                       cout << " (Looping)";
-                    cout << std::endl;
+                    if (Debug)
+                    {
+                       cout << OutputInDepth(Depth) << "  Unpacking " << BrokenPkg.FullName() << " to avoid " << End;
+                       if (PkgLoop == true)
+                          cout << " (Looping)";
+                       cout << std::endl;
+                    }
+                    if (PkgLoop == false)
+                       List->Flag(Pkg,pkgOrderList::Loop);
+                    SmartUnPack(BrokenPkg, false, Depth + 1);
+                    if (PkgLoop == false)
+                       List->RmFlag(Pkg,pkgOrderList::Loop);
                  }
                  }
-                 if (PkgLoop == false)
-                    List->Flag(Pkg,pkgOrderList::Loop);
-                 SmartUnPack(BrokenPkg, false, Depth + 1);
-                 if (PkgLoop == false)
-                    List->RmFlag(Pkg,pkgOrderList::Loop);
               }
            } else {
               // Check if a package needs to be removed
               }
            } else {
               // Check if a package needs to be removed
index 07878af36776f8e58d79cd0843ced42e03b34e6a..6cd2e70a766c8f92df07bea6a5e3f92f21733f56 100644 (file)
@@ -40,6 +40,9 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
       e.g. in a Depends line and are now requested for removal
   * cmdline/apt-cache.cc:
     - correct --pre-depends option by using dash consistently (LP: #940837)
       e.g. in a Depends line and are now requested for removal
   * cmdline/apt-cache.cc:
     - correct --pre-depends option by using dash consistently (LP: #940837)
+  * apt-pkg/packagemanager.cc:
+    - do not try to a void a breaks if the broken package pre-depends
+      on the breaker, but let dpkg auto-deconfigure it
 
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
 
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
@@ -62,7 +65,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
   * apt-pkg/contrib/fileutl.h:
     - fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode
 
   * apt-pkg/contrib/fileutl.h:
     - fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 25 Feb 2012 19:43:04 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 03 Mar 2012 11:03:58 +0100
 
 apt (0.8.16~exp12) experimental; urgency=low
 
 
 apt (0.8.16~exp12) experimental; urgency=low
 
diff --git a/test/integration/skip-avoid-avoiding-breaks-predepends b/test/integration/skip-avoid-avoiding-breaks-predepends
new file mode 100755 (executable)
index 0000000..a47e8bc
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'native'
+
+insertinstalledpackage 'looping' 'native' '1'
+insertinstalledpackage 'loop1' 'native' '1' 'Depends: loop2 (= 1)'
+insertinstalledpackage 'loop2' 'native' '1' 'Depends: loop1 (= 1)'
+
+buildsimplenativepackage 'looping' 'native' '1.15.7.2' 'stable' 'Breaks: loop2 (<= 1)'
+buildsimplenativepackage 'loop1' 'native' '2' 'stable' 'Depends: loop2 (= 2)'
+buildsimplenativepackage 'loop2' 'native' '2' 'stable' 'Depends: loop1 (= 2)
+Pre-Depends: looping (>= 1.15)'
+
+setupaptarchive
+
+aptget dist-upgrade -y -o Debug::pkgOrderList=1 #-qq 2>&1 > /dev/null
+testdpkginstalled looping loop1 loop2