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

Added a RmFlag function to remvoe the loop flag, this should prevent any errors or wierd behaviour because of the loop flag being used
at mutiple stages in both SmartUnpack and SmartConfigure.

Christopher Baines лет назад: 15
Родитель
Сommit
cbea057898
2 измененных файлов с 13 добавлено и 4 удалено
  1. 2 0
      apt-pkg/orderlist.h
  2. 11 4
      apt-pkg/packagemanager.cc

+ 2 - 0
apt-pkg/orderlist.h

@@ -94,6 +94,8 @@ class pkgOrderList : protected pkgCache::Namespace
    void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;};
    void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;};
    inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
    inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
    inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
    inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
+   // RmFlag removes a flag from a package 
+   inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~F;};
    // IsNow will return true if the Pkg has been not been either configured or unpacked
    // IsNow will return true if the Pkg has been not been either configured or unpacked
    inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
    inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
    bool IsMissing(PkgIterator Pkg);
    bool IsMissing(PkgIterator Pkg);

+ 11 - 4
apt-pkg/packagemanager.cc

@@ -369,7 +369,9 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
 	          if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
 	          if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
 	             List->Flag(Pkg,pkgOrderList::Loop);
 	             List->Flag(Pkg,pkgOrderList::Loop);
 	             // If SmartConfigure was succesfull, Bad is false, so break
 	             // If SmartConfigure was succesfull, Bad is false, so break
-	             if (!(Bad = !SmartConfigure(DepPkg))) break;
+	             Bad = !SmartConfigure(DepPkg);
+	             List->RmFlag(Pkg,pkgOrderList::Loop);
+	             if (!Bad) break;
 	          }
 	          }
 	       } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) {
 	       } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) {
 	          Bad = false;
 	          Bad = false;
@@ -381,11 +383,12 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
 	 /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */
 	 /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */
 	 if (InstallVer != 0 && Bad) {
 	 if (InstallVer != 0 && Bad) {
 	    Bad = false;
 	    Bad = false;
-	    List->Flag(Pkg,pkgOrderList::Loop);
 	    if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
 	    if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
+	       List->Flag(Pkg,pkgOrderList::Loop);
 	       if (Debug) 
 	       if (Debug) 
 	          cout << "  Unpacking " << DepPkg.Name() << " to avoid loop" << endl;
 	          cout << "  Unpacking " << DepPkg.Name() << " to avoid loop" << endl;
 	       SmartUnPack(DepPkg, true);
 	       SmartUnPack(DepPkg, true);
+	       //List->Flag(Pkg,~pkgOrderList::Loop);
 	    }
 	    }
 	 }
 	 }
 	 
 	 
@@ -616,15 +619,18 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate)
 	    
 	    
 	    // See if the current version is conflicting
 	    // See if the current version is conflicting
 	    if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg))
 	    if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg))
-	    {   
+	    { 
+	       cout << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl;
 	       /* If a loop is not present or has not yet been detected, attempt to unpack packages 
 	       /* If a loop is not present or has not yet been detected, attempt to unpack packages 
 	          to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */
 	          to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */
 	       if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) {
 	       if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) {
 	          if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) {
 	          if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) {
 	              if (Debug)
 	              if (Debug)
                         cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl;
                         cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl;
-	              List->Flag(Pkg,pkgOrderList::Loop);
+                      List->Flag(Pkg,pkgOrderList::Loop);
 	              SmartUnPack(ConflictPkg,false);
 	              SmartUnPack(ConflictPkg,false);
+	              // Remove loop to allow it to be used later if needed
+	              List->RmFlag(Pkg,pkgOrderList::Loop);
                   } else {
                   } else {
                       if (EarlyRemove(ConflictPkg) == false)
                       if (EarlyRemove(ConflictPkg) == false)
                          return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name());
                          return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name());
@@ -659,6 +665,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate)
 	         cout << "  Unpacking " << BrokenPkg.Name() << " to avoid break" << endl;
 	         cout << "  Unpacking " << BrokenPkg.Name() << " to avoid break" << endl;
 	         
 	         
 	      SmartUnPack(BrokenPkg, false);
 	      SmartUnPack(BrokenPkg, false);
+	      List->RmFlag(Pkg,pkgOrderList::Loop);
 	    }
 	    }
 	    // Check if a package needs to be removed
 	    // Check if a package needs to be removed
 	    if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) {
 	    if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) {