]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/packagemanager.cc
edsp: if logging is requested, do it for internal, too
[apt.git] / apt-pkg / packagemanager.cc
index dcae0112614911ae276dc8e0c8fec0bd4a8ec4fc..77a6b0e57547a84c8584e17614b403ae5dcad12c 100644 (file)
@@ -6,7 +6,7 @@
    Package Manager - Abstacts the package manager
 
    More work is needed in the area of transitioning provides, ie exim
    Package Manager - Abstacts the package manager
 
    More work is needed in the area of transitioning provides, ie exim
-   replacing smail. This can cause interesing side effects.
+   replacing smail. This can cause interesting side effects.
 
    Other cases involving conflicts+replaces should be tested. 
    
 
    Other cases involving conflicts+replaces should be tested. 
    
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/sptr.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/install-progress.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/install-progress.h>
+#include <apt-pkg/prettyprinters.h>
 
 #include <stddef.h>
 #include <list>
 
 #include <stddef.h>
 #include <list>
@@ -137,7 +137,7 @@ bool pkgPackageManager::FixMissing()
 // PM::ImmediateAdd - Add the immediate flag recursivly                        /*{{{*/
 // ---------------------------------------------------------------------
 /* This adds the immediate flag to the pkg and recursively to the
 // PM::ImmediateAdd - Add the immediate flag recursivly                        /*{{{*/
 // ---------------------------------------------------------------------
 /* This adds the immediate flag to the pkg and recursively to the
-   dependendies 
+   dependencies
  */
 void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned const int &Depth)
 {
  */
 void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned const int &Depth)
 {
@@ -160,7 +160,7 @@ void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned
         if(!List->IsFlag(D.TargetPkg(), pkgOrderList::Immediate))
         {
            if(Debug)
         if(!List->IsFlag(D.TargetPkg(), pkgOrderList::Immediate))
         {
            if(Debug)
-              clog << OutputInDepth(Depth) << "ImmediateAdd(): Adding Immediate flag to " << D.TargetPkg() << " cause of " << D.DepType() << " " << I.FullName() << endl;
+              clog << OutputInDepth(Depth) << "ImmediateAdd(): Adding Immediate flag to " << APT::PrettyPkg(&Cache, D.TargetPkg()) << " cause of " << D.DepType() << " " << I.FullName() << endl;
            List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
            ImmediateAdd(D.TargetPkg(), UseInstallVer, Depth + 1);
         }
            List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
            ImmediateAdd(D.TargetPkg(), UseInstallVer, Depth + 1);
         }
@@ -190,7 +190,7 @@ bool pkgPackageManager::CreateOrderList()
       if (I->VersionList == 0)
         continue;
       
       if (I->VersionList == 0)
         continue;
       
-      // Mark the package and its dependends for immediate configuration
+      // Mark the package and its dependents for immediate configuration
       if ((((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) &&
          NoImmConfigure == false) || ImmConfigureAll)
       {
       if ((((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) &&
          NoImmConfigure == false) || ImmConfigureAll)
       {
@@ -269,6 +269,33 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
+// PM::CheckRBreaks - Look for reverse breaks                          /*{{{*/
+bool pkgPackageManager::CheckRBreaks(PkgIterator const &Pkg, DepIterator D,
+                                    const char * const Ver)
+{
+   for (;D.end() == false; ++D)
+   {
+      if (D->Type != pkgCache::Dep::DpkgBreaks)
+        continue;
+
+      PkgIterator const DP = D.ParentPkg();
+      if (Cache[DP].Delete() == false)
+        continue;
+
+      // Ignore self conflicts, ignore conflicts from irrelevant versions
+      if (D.IsIgnorable(Pkg) || D.ParentVer() != DP.CurrentVer())
+        continue;
+
+      if (Cache.VS().CheckDep(Ver, D->CompareOp, D.TargetVer()) == false)
+        continue;
+
+      // no earlyremove() here as user has already agreed to the permanent removal
+      if (SmartRemove(DP) == false)
+        return _error->Error("Internal Error, Could not early remove %s (%d)",DP.FullName().c_str(), 4);
+   }
+   return true;
+}
+                                                                       /*}}}*/
 // PM::ConfigureAll - Run the all out configuration                    /*{{{*/
 // ---------------------------------------------------------------------
 /* This configures every package. It is assumed they are all unpacked and
 // PM::ConfigureAll - Run the all out configuration                    /*{{{*/
 // ---------------------------------------------------------------------
 /* This configures every package. It is assumed they are all unpacked and
@@ -382,7 +409,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
         pkgCache::DepIterator Start, End;
         D.GlobOr(Start,End);
 
         pkgCache::DepIterator Start, End;
         D.GlobOr(Start,End);
 
-        if (End->Type != pkgCache::Dep::Depends)
+        if (End->Type != pkgCache::Dep::Depends && End->Type != pkgCache::Dep::PreDepends)
            continue;
         Bad = true;
 
            continue;
         Bad = true;
 
@@ -390,7 +417,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
          // to do anything at all
         for (DepIterator Cur = Start; true; ++Cur)
         {
          // to do anything at all
         for (DepIterator Cur = Start; true; ++Cur)
         {
-           std::unique_ptr<Version *> VList(Cur.AllTargets());
+           std::unique_ptr<Version *[]> VList(Cur.AllTargets());
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
@@ -414,7 +441,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
               if (PkgLoop == true)
               {
                  if (Debug)
               if (PkgLoop == true)
               {
                  if (Debug)
-                    std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure";
+                    std::clog << OutputInDepth(Depth) << "Package " << APT::PrettyPkg(&Cache, Pkg) << " loops in SmartConfigure";
                  if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
                     Bad = false;
                  else if (Debug)
                  if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
                     Bad = false;
                  else if (Debug)
@@ -432,7 +459,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
          if (Bad == false)
          {
             if (Debug)
          if (Bad == false)
          {
             if (Debug)
-               std::clog << OutputInDepth(Depth) << "Found ok dep " << Start.TargetPkg() << std::endl;
+               std::clog << OutputInDepth(Depth) << "Found ok dep " << APT::PrettyPkg(&Cache, Start.TargetPkg()) << std::endl;
             continue;
          }
 
             continue;
          }
 
@@ -440,7 +467,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
          // probably due to loops.
         for (DepIterator Cur = Start; true; ++Cur)
         {
          // probably due to loops.
         for (DepIterator Cur = Start; true; ++Cur)
         {
-           std::unique_ptr<Version *> VList(Cur.AllTargets());
+           std::unique_ptr<Version *[]> VList(Cur.AllTargets());
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
@@ -461,7 +488,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
               if (PkgLoop == true)
               {
                  if (Debug)
               if (PkgLoop == true)
               {
                  if (Debug)
-                    std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure";
+                    std::clog << OutputInDepth(Depth) << "Package " << APT::PrettyPkg(&Cache, Pkg) << " loops in SmartConfigure";
                  if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
                     Bad = false;
                  else if (Debug)
                  if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
                     Bad = false;
                  else if (Debug)
@@ -472,7 +499,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
               else
               {
                  if (Debug)
               else
               {
                  if (Debug)
-                    clog << OutputInDepth(Depth) << "Unpacking " << DepPkg.FullName() << " to avoid loop " << Cur << endl;
+                    clog << OutputInDepth(Depth) << "Unpacking " << DepPkg.FullName() << " to avoid loop " << APT::PrettyDep(&Cache, Cur) << endl;
                  if (NonLoopingSmart(UNPACK_IMMEDIATE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
                     return false;
               }
                  if (NonLoopingSmart(UNPACK_IMMEDIATE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
                     return false;
               }
@@ -508,14 +535,14 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
            Discard.GlobOr(Start,End);
         }
 
            Discard.GlobOr(Start,End);
         }
 
-        if (End->Type != pkgCache::Dep::Depends)
+        if (End->Type != pkgCache::Dep::Depends && End->Type != pkgCache::Dep::PreDepends)
            continue;
         Bad = true;
 
         // Search for dependencies which are unpacked but aren't configured yet (maybe loops)
         for (DepIterator Cur = Start; true; ++Cur)
         {
            continue;
         Bad = true;
 
         // Search for dependencies which are unpacked but aren't configured yet (maybe loops)
         for (DepIterator Cur = Start; true; ++Cur)
         {
-           std::unique_ptr<Version *> VList(Cur.AllTargets());
+           std::unique_ptr<Version *[]> VList(Cur.AllTargets());
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
 
            for (Version **I = VList.get(); *I != 0; ++I)
            {
@@ -535,7 +562,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
                    break;
                  }
                  if (Debug)
                    break;
                  }
                  if (Debug)
-                    std::clog << OutputInDepth(Depth) << "Configure already unpacked " << DepPkg << std::endl;
+                    std::clog << OutputInDepth(Depth) << "Configure already unpacked " << APT::PrettyPkg(&Cache, DepPkg) << std::endl;
                  if (NonLoopingSmart(CONFIGURE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
                     return false;
                  break;
                  if (NonLoopingSmart(CONFIGURE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
                     return false;
                  break;
@@ -553,7 +580,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
 
 
         if (Bad == true && Changed == false && Debug == true)
 
 
         if (Bad == true && Changed == false && Debug == true)
-           std::clog << OutputInDepth(Depth) << "Could not satisfy " << *D << std::endl;
+           std::clog << OutputInDepth(Depth) << "Could not satisfy " << APT::PrettyDep(&Cache, *D) << std::endl;
       }
       if (i++ > max_loops)
          return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack (2) for %s, aborting", Pkg.FullName().c_str());
       }
       if (i++ > max_loops)
          return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack (2) for %s, aborting", Pkg.FullName().c_str());
@@ -562,6 +589,14 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
    if (Bad == true)
       return _error->Error(_("Could not configure '%s'. "),Pkg.FullName().c_str());
 
    if (Bad == true)
       return _error->Error(_("Could not configure '%s'. "),Pkg.FullName().c_str());
 
+   // Check for reverse conflicts.
+   if (CheckRBreaks(Pkg,Pkg.RevDependsList(), instVer.VerStr()) == false)
+      return false;
+
+   for (PrvIterator P = instVer.ProvidesList(); P.end() == false; ++P)
+      if (Pkg->Group != P.OwnerPkg()->Group)
+        CheckRBreaks(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
+
    if (PkgLoop) return true;
 
    static std::string const conf = _config->Find("PackageManager::Configure","all");
    if (PkgLoop) return true;
 
    static std::string const conf = _config->Find("PackageManager::Configure","all");
@@ -726,7 +761,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
            // Look for easy targets: packages that are already okay
            for (DepIterator Cur = Start; Bad == true; ++Cur)
            {
            // Look for easy targets: packages that are already okay
            for (DepIterator Cur = Start; Bad == true; ++Cur)
            {
-              std::unique_ptr<Version *> VList(Cur.AllTargets());
+              std::unique_ptr<Version *[]> VList(Cur.AllTargets());
               for (Version **I = VList.get(); *I != 0; ++I)
               {
                  VerIterator Ver(Cache,*I);
               for (Version **I = VList.get(); *I != 0; ++I)
               {
                  VerIterator Ver(Cache,*I);
@@ -814,21 +849,21 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
               if (ConflictPkg.CurrentVer() != Ver)
               {
                  if (Debug)
               if (ConflictPkg.CurrentVer() != Ver)
               {
                  if (Debug)
-                    std::clog << OutputInDepth(Depth) << "Ignore not-installed version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << End << std::endl;
+                    std::clog << OutputInDepth(Depth) << "Ignore not-installed version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << APT::PrettyDep(&Cache, End) << std::endl;
                  continue;
               }
 
               if (List->IsNow(ConflictPkg) == false)
               {
                  if (Debug)
                  continue;
               }
 
               if (List->IsNow(ConflictPkg) == false)
               {
                  if (Debug)
-                    std::clog << OutputInDepth(Depth) << "Ignore already dealt-with version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << End << std::endl;
+                    std::clog << OutputInDepth(Depth) << "Ignore already dealt-with version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << APT::PrettyDep(&Cache, End) << std::endl;
                  continue;
               }
 
               if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
               {
                  if (Debug)
                  continue;
               }
 
               if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
               {
                  if (Debug)
-                    clog << OutputInDepth(Depth) << "Ignoring " << End << " as " << ConflictPkg.FullName() << "was temporarily removed" << endl;
+                    clog << OutputInDepth(Depth) << "Ignoring " << APT::PrettyDep(&Cache, End) << " as " << ConflictPkg.FullName() << "was temporarily removed" << endl;
                  continue;
               }
 
                  continue;
               }
 
@@ -837,7 +872,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
                  if (End->Type == pkgCache::Dep::DpkgBreaks && End.IsMultiArchImplicit() == true)
                  {
                     if (Debug)
                  if (End->Type == pkgCache::Dep::DpkgBreaks && End.IsMultiArchImplicit() == true)
                  {
                     if (Debug)
-                       clog << OutputInDepth(Depth) << "Because dependency is MultiArchImplicit we ignored looping on: " << ConflictPkg << endl;
+                       clog << OutputInDepth(Depth) << "Because dependency is MultiArchImplicit we ignored looping on: " << APT::PrettyPkg(&Cache, ConflictPkg) << endl;
                     continue;
                  }
                  if (Debug)
                     continue;
                  }
                  if (Debug)
@@ -848,7 +883,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
                        clog << OutputInDepth(Depth) << "Because of conflict knot, removing " << ConflictPkg.FullName() << " temporarily" << endl;
                  }
                  if (EarlyRemove(ConflictPkg, &End) == false)
                        clog << OutputInDepth(Depth) << "Because of conflict knot, removing " << ConflictPkg.FullName() << " temporarily" << endl;
                  }
                  if (EarlyRemove(ConflictPkg, &End) == false)
-                    return _error->Error("Internal Error, Could not early remove %s (2)",ConflictPkg.FullName().c_str());
+                    return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 3);
                  SomethingBad = true;
                  continue;
               }
                  SomethingBad = true;
                  continue;
               }
@@ -857,7 +892,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
               {
                  if (Debug)
                  {
               {
                  if (Debug)
                  {
-                    clog << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.FullName() << " to avoid " << End;
+                    clog << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.FullName() << " to avoid " << APT::PrettyDep(&Cache, End);
                     if (PkgLoop == true)
                        clog << " (Looping)";
                     clog << std::endl;
                     if (PkgLoop == true)
                        clog << " (Looping)";
                     clog << std::endl;
@@ -869,28 +904,28 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
                     // but if it fails ignore this failure and look for alternative ways of solving
                     if (Debug)
                     {
                     // but if it fails ignore this failure and look for alternative ways of solving
                     if (Debug)
                     {
-                       clog << OutputInDepth(Depth) << "Avoidance unpack of " << ConflictPkg.FullName() << " failed for " << End << " ignoring:" << std::endl;
-                       _error->DumpErrors(std::clog);
+                       clog << OutputInDepth(Depth) << "Avoidance unpack of " << ConflictPkg.FullName() << " failed for " << APT::PrettyDep(&Cache, End) << " ignoring:" << std::endl;
+                       _error->DumpErrors(std::clog, GlobalError::DEBUG, false);
                     }
                     _error->RevertToStack();
                     // ignorance can only happen if a) one of the offenders is already gone
                     if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
                     {
                        if (Debug)
                     }
                     _error->RevertToStack();
                     // ignorance can only happen if a) one of the offenders is already gone
                     if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
                     {
                        if (Debug)
-                          clog << OutputInDepth(Depth) << "But " << ConflictPkg.FullName() << " was temporarily removed in the meantime to satisfy " << End << endl;
+                          clog << OutputInDepth(Depth) << "But " << ConflictPkg.FullName() << " was temporarily removed in the meantime to satisfy " << APT::PrettyDep(&Cache, End) << endl;
                     }
                     else if (List->IsFlag(Pkg,pkgOrderList::Removed) == true)
                     {
                        if (Debug)
                     }
                     else if (List->IsFlag(Pkg,pkgOrderList::Removed) == true)
                     {
                        if (Debug)
-                          clog << OutputInDepth(Depth) << "But " << Pkg.FullName() << " was temporarily removed in the meantime to satisfy " << End << endl;
+                          clog << OutputInDepth(Depth) << "But " << Pkg.FullName() << " was temporarily removed in the meantime to satisfy " <<  APT::PrettyDep(&Cache, End) << endl;
                     }
                     // or b) we can make one go (removal or dpkg auto-deconfigure)
                     else
                     {
                        if (Debug)
                     }
                     // or b) we can make one go (removal or dpkg auto-deconfigure)
                     else
                     {
                        if (Debug)
-                          clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << End << endl;
+                          clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " <<  APT::PrettyDep(&Cache, End) << endl;
                        if (EarlyRemove(ConflictPkg, &End) == false)
                        if (EarlyRemove(ConflictPkg, &End) == false)
-                          return _error->Error("Internal Error, Could not early remove %s (2)",ConflictPkg.FullName().c_str());
+                          return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 2);
                     }
                  }
                  else
                     }
                  }
                  else
@@ -899,10 +934,10 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
               else
               {
                  if (Debug)
               else
               {
                  if (Debug)
-                    clog << OutputInDepth(Depth) << "Removing " << ConflictPkg.FullName() << " now to avoid " << End << endl;
+                    clog << OutputInDepth(Depth) << "Removing " << ConflictPkg.FullName() << " now to avoid " << APT::PrettyDep(&Cache, End) << endl;
                  // no earlyremove() here as user has already agreed to the permanent removal
                  if (SmartRemove(Pkg) == false)
                  // no earlyremove() here as user has already agreed to the permanent removal
                  if (SmartRemove(Pkg) == false)
-                    return _error->Error("Internal Error, Could not early remove %s (1)",ConflictPkg.FullName().c_str());
+                    return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 1);
               }
            }
         }
               }
            }
         }
@@ -917,7 +952,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
    if (couldBeTemporaryRemoved == true && List->IsFlag(Pkg,pkgOrderList::Removed) == true)
    {
       if (Debug)
    if (couldBeTemporaryRemoved == true && List->IsFlag(Pkg,pkgOrderList::Removed) == true)
    {
       if (Debug)
-        std::clog << OutputInDepth(Depth) << "Prevent unpack as " << Pkg << " is currently temporarily removed" << std::endl;
+        std::clog << OutputInDepth(Depth) << "Prevent unpack as " << APT::PrettyPkg(&Cache, Pkg) << " is currently temporarily removed" << std::endl;
       return true;
    }
 
       return true;
    }