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

Sync
Author: jgg
Date: 1998-07-12 01:25:59 GMT
Sync

Arch Librarian лет назад: 22
Родитель
Сommit
b518cca6bd
5 измененных файлов с 41 добавлено и 32 удалено
  1. 22 23
      apt-pkg/algorithms.cc
  2. 3 2
      apt-pkg/cacheiterators.h
  3. 1 4
      apt-pkg/depcache.h
  4. 2 2
      apt-pkg/packagemanager.cc
  5. 13 1
      apt-pkg/pkgcache.cc

+ 22 - 23
apt-pkg/algorithms.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: algorithms.cc,v 1.1 1998/07/07 04:17:00 jgg Exp $
+// $Id: algorithms.cc,v 1.2 1998/07/12 01:25:59 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Algorithms - A set of misc algorithms
    Algorithms - A set of misc algorithms
@@ -13,7 +13,6 @@
 #endif 
 #endif 
 #include <pkglib/algorithms.h>
 #include <pkglib/algorithms.h>
 #include <pkglib/error.h>
 #include <pkglib/error.h>
-#include <pkglib/pkgelement.h>
 #include <iostream.h>
 #include <iostream.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -23,7 +22,7 @@ pkgProblemResolver *pkgProblemResolver::This = 0;
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
 pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache), 
 pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache), 
-                            Sim(true,true)
+                            Sim(Cache)
 {
 {
    Flags = new unsigned char[Cache.HeaderP->PackageCount];
    Flags = new unsigned char[Cache.HeaderP->PackageCount];
    memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount);
    memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount);
@@ -48,12 +47,12 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
 	 continue;
 	 continue;
       
       
       for (DepIterator D = Sim[I].InstVerIter(Sim).DependsList(); D.end() == false; D++)
       for (DepIterator D = Sim[I].InstVerIter(Sim).DependsList(); D.end() == false; D++)
-	 if (D->Type == pkgDEP_Conflicts || D->Type == pkgDEP_PreDepends)
+	 if (D->Type == pkgCache::Dep::Conflicts || D->Type == pkgCache::Dep::PreDepends)
          {
          {
 	    if ((Sim[D] & pkgDepCache::DepInstall) == 0)
 	    if ((Sim[D] & pkgDepCache::DepInstall) == 0)
 	    {
 	    {
 	       cout << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']';
 	       cout << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']';
-	       if (D->Type == pkgDEP_Conflicts)
+	       if (D->Type == pkgCache::Dep::Conflicts)
 		  _error->Error("Fatal, conflicts violated %s",I.Name());
 		  _error->Error("Fatal, conflicts violated %s",I.Name());
 	    }	    
 	    }	    
 	 }      
 	 }      
@@ -91,7 +90,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
 	     (Sim[D] & pkgDepCache::DepInstall) != 0)
 	     (Sim[D] & pkgDepCache::DepInstall) != 0)
 	    continue;
 	    continue;
 	 
 	 
-	 if (D->Type == pkgDEP_Conflicts)
+	 if (D->Type == pkgCache::Dep::Conflicts)
 	    cout << " Conflicts:" << D.TargetPkg().Name();
 	    cout << " Conflicts:" << D.TargetPkg().Name();
 	 else
 	 else
 	    cout << " Depends:" << D.TargetPkg().Name();
 	    cout << " Depends:" << D.TargetPkg().Name();
@@ -162,18 +161,18 @@ bool pkgApplyStatus(pkgDepCache &Cache)
       switch (I->CurrentState)
       switch (I->CurrentState)
       {
       {
 	 // This means installation failed somehow
 	 // This means installation failed somehow
-	 case pkgSTATE_UnPacked:
-	 case pkgSTATE_HalfConfigured:
+	 case pkgCache::State::UnPacked:
+	 case pkgCache::State::HalfConfigured:
 	 Cache.MarkKeep(I);
 	 Cache.MarkKeep(I);
 	 break;
 	 break;
 
 
 	 // This means removal failed
 	 // This means removal failed
-	 case pkgSTATE_HalfInstalled:
+	 case pkgCache::State::HalfInstalled:
 	 Cache.MarkDelete(I);
 	 Cache.MarkDelete(I);
 	 break;
 	 break;
 	 
 	 
 	 default:
 	 default:
-	 if (I->InstState != pkgSTATE_Ok)
+	 if (I->InstState != pkgCache::State::Ok)
 	    return _error->Error("The package %s is not ok and I "
 	    return _error->Error("The package %s is not ok and I "
 				 "don't know how to fix it!",I.Name());
 				 "don't know how to fix it!",I.Name());
       }
       }
@@ -200,7 +199,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
 	  Cache[I].Delete() == true)
 	  Cache[I].Delete() == true)
 	 continue;
 	 continue;
       
       
-      if ((Cache[I].InstVerIter(Cache).File()->Flags & pkgFLAG_NotSource) == 0)
+      if (Cache[I].InstVerIter(Cache).Downloadable() == false)
 	 continue;
 	 continue;
 
 
       Cache.MarkInstall(I,true);
       Cache.MarkInstall(I,true);
@@ -229,7 +228,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    /* Now, auto upgrade all essential packages - this ensures that
    /* Now, auto upgrade all essential packages - this ensures that
       the essential packages are present and working */
       the essential packages are present and working */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
-      if ((I->Flags & pkgFLAG_Essential) == pkgFLAG_Essential)
+      if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
 	 Cache.MarkInstall(I,true);
 	 Cache.MarkInstall(I,true);
    
    
    /* We do it again over all previously installed packages to force 
    /* We do it again over all previously installed packages to force 
@@ -243,7 +242,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    // Hold back held packages.
    // Hold back held packages.
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
    {
-      if (I->SelectedState == pkgSTATE_Hold)
+      if (I->SelectedState == pkgCache::State::Hold)
       {
       {
 	 Fix.Protect(I);
 	 Fix.Protect(I);
 	 Cache.MarkKeep(I);
 	 Cache.MarkKeep(I);
@@ -303,7 +302,7 @@ void pkgProblemResolver::MakeScores()
          essantial package above most other packages but low enough
          essantial package above most other packages but low enough
 	 to allow an obsolete essential packages to be removed by
 	 to allow an obsolete essential packages to be removed by
 	 a conflicts on a powerfull normal package (ie libc6) */
 	 a conflicts on a powerfull normal package (ie libc6) */
-      if ((I->Flags & pkgFLAG_Essential) == pkgFLAG_Essential)
+      if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
 	 Score += 100;
 	 Score += 100;
 
 
       // We transform the priority
       // We transform the priority
@@ -326,7 +325,7 @@ void pkgProblemResolver::MakeScores()
       
       
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
       {
       {
-	 if (D->Type == pkgDEP_Depends || D->Type == pkgDEP_PreDepends)
+	 if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
 	    Scores[D.TargetPkg()->ID]++;
 	    Scores[D.TargetPkg()->ID]++;
       }
       }
    }   
    }   
@@ -347,7 +346,7 @@ void pkgProblemResolver::MakeScores()
       {
       {
 	 // Only do it for the install version
 	 // Only do it for the install version
 	 if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
 	 if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
-	     (D->Type != pkgDEP_Depends && D->Type != pkgDEP_PreDepends))
+	     (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends))
 	    continue;	 
 	    continue;	 
 	 
 	 
 	 Scores[I->ID] += abs(OldScores[D.ParentPkg()->ID]);
 	 Scores[I->ID] += abs(OldScores[D.ParentPkg()->ID]);
@@ -400,7 +399,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
       for (bool LastOR = true; D.end() == false && LastOR == true; D++)
       for (bool LastOR = true; D.end() == false && LastOR == true; D++)
       {
       {
 	 State |= Cache[D];
 	 State |= Cache[D];
-	 LastOR = (D->CompareOp & pkgOP_OR) == pkgOP_OR;
+	 LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
 	 if (LastOR == true)
 	 if (LastOR == true)
 	    End = D;
 	    End = D;
       }
       }
@@ -437,7 +436,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
       {
       {
 	 /* We let the algorithm deal with conflicts on its next iteration,
 	 /* We let the algorithm deal with conflicts on its next iteration,
 	    it is much smarter than us */
 	    it is much smarter than us */
-	 if (End->Type == pkgDEP_Conflicts)
+	 if (End->Type == pkgCache::Dep::Conflicts)
 	    continue;
 	    continue;
 	 
 	 
 	 if (Debug == true)
 	 if (Debug == true)
@@ -586,7 +585,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    for (bool LastOR = true; D.end() == false && LastOR == true; D++)
 	    for (bool LastOR = true; D.end() == false && LastOR == true; D++)
 	    {
 	    {
 	       State |= Cache[D];
 	       State |= Cache[D];
-	       LastOR = (D->CompareOp & pkgOP_OR) == pkgOP_OR;
+	       LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
 	       if (LastOR == true)
 	       if (LastOR == true)
 		  End = D;
 		  End = D;
 	    }
 	    }
@@ -624,7 +623,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		  " as a solution to " << I.Name() << ' ' << (int)Scores[I->ID] << endl;
 		  " as a solution to " << I.Name() << ' ' << (int)Scores[I->ID] << endl;
 	       if (Scores[I->ID] <= Scores[Pkg->ID] ||
 	       if (Scores[I->ID] <= Scores[Pkg->ID] ||
 		   ((Cache[End] & pkgDepCache::DepGNow) == 0 &&
 		   ((Cache[End] & pkgDepCache::DepGNow) == 0 &&
-		    End->Type != pkgDEP_Conflicts))
+		    End->Type != pkgCache::Dep::Conflicts))
 	       {
 	       {
 		  if ((Flags[I->ID] & Protected) != 0)
 		  if ((Flags[I->ID] & Protected) != 0)
 		     continue;
 		     continue;
@@ -661,13 +660,13 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 		  LEnd->Pkg = Pkg;
 		  LEnd->Pkg = Pkg;
 		  LEnd->Dep = End;
 		  LEnd->Dep = End;
 		  LEnd++;
 		  LEnd++;
-		  if (End->Type != pkgDEP_Conflicts)
+		  if (End->Type != pkgCache::Dep::Conflicts)
 		     break;
 		     break;
 	       }
 	       }
 	    }
 	    }
 
 
 	    // Hm, nothing can possibly satisify this dep. Nuke it.
 	    // Hm, nothing can possibly satisify this dep. Nuke it.
-	    if (VList[0] == 0 && End->Type != pkgDEP_Conflicts)
+	    if (VList[0] == 0 && End->Type != pkgCache::Dep::Conflicts)
 	    {
 	    {
 	       Cache.MarkKeep(I);
 	       Cache.MarkKeep(I);
 	       if (Cache[I].InstBroken() == false)
 	       if (Cache[I].InstBroken() == false)
@@ -698,7 +697,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    Change = true;
 	    Change = true;
 	    if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
 	    if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
 	    {
 	    {
-	       if (J->Dep->Type == pkgDEP_Conflicts)
+	       if (J->Dep->Type == pkgCache::Dep::Conflicts)
 	       {
 	       {
 		  if (Debug == true)
 		  if (Debug == true)
 		     cout << "  Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl;
 		     cout << "  Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl;

+ 3 - 2
apt-pkg/cacheiterators.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: cacheiterators.h,v 1.4 1998/07/07 04:17:00 jgg Exp $
+// $Id: cacheiterators.h,v 1.5 1998/07/12 01:26:00 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    Cache Iterators - Iterators for navigating the cache structure
    Cache Iterators - Iterators for navigating the cache structure
@@ -125,6 +125,7 @@ class pkgCache::VerIterator
    inline PrvIterator ProvidesList() const;
    inline PrvIterator ProvidesList() const;
    inline VerFileIterator FileList() const;
    inline VerFileIterator FileList() const;
    inline unsigned long Index() const {return Ver - Owner.VerP;};
    inline unsigned long Index() const {return Ver - Owner.VerP;};
+   bool Downloadable() const;
 
 
    inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg), Owner(Owner) 
    inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Ver(Trg), Owner(Owner) 
    { 
    { 
@@ -300,7 +301,7 @@ class pkgCache::VerFileIterator
   
   
    inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
    inline PkgFileIterator File() const {return PkgFileIterator(*Owner,FileP->File + Owner->PkgFileP);};
    inline unsigned long Index() const {return FileP - Owner->VerFileP;};
    inline unsigned long Index() const {return FileP - Owner->VerFileP;};
-
+      
    inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
    inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
 };
 };
 
 

+ 1 - 4
apt-pkg/depcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: depcache.h,v 1.1 1998/07/07 04:17:01 jgg Exp $
+// $Id: depcache.h,v 1.2 1998/07/12 01:26:01 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    DepCache - Dependency Extension data for the cache
    DepCache - Dependency Extension data for the cache
@@ -167,9 +167,6 @@ class pkgDepCache : public pkgCache
    // This is for debuging
    // This is for debuging
    void Update();
    void Update();
 
 
-   // Dep Processing for AutoKeep
-   void ResolveConflicts(unsigned char *Touched);
-   
    // Hook to keep the extra data in sync
    // Hook to keep the extra data in sync
    virtual bool ReMap();
    virtual bool ReMap();
    
    

+ 2 - 2
apt-pkg/packagemanager.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: packagemanager.cc,v 1.2 1998/07/09 05:41:12 jgg Exp $
+// $Id: packagemanager.cc,v 1.3 1998/07/12 01:26:02 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Package Manager - Abstacts the package manager
    Package Manager - Abstacts the package manager
@@ -64,7 +64,7 @@ bool pkgPackageManager::FixMissing()
    }
    }
    
    
    // Now downgrade everything that is broken
    // Now downgrade everything that is broken
-   Cache.ResolveConflicts(Touch);
+//   Cache.ResolveConflicts(Touch);
    delete [] Touch;
    delete [] Touch;
 
 
    return Cache.BrokenCount() == 0;
    return Cache.BrokenCount() == 0;

+ 13 - 1
apt-pkg/pkgcache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: pkgcache.cc,v 1.5 1998/07/07 04:17:02 jgg Exp $
+// $Id: pkgcache.cc,v 1.6 1998/07/12 01:26:04 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    Package Cache - Accessor code for the cache
    Package Cache - Accessor code for the cache
@@ -358,6 +358,18 @@ int pkgCache::VerIterator::CompareVer(const VerIterator &B) const
    return -1;
    return -1;
 }
 }
 									/*}}}*/
 									/*}}}*/
+// VerIterator::Downloadable - Checks if the version is downloadable	/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgCache::VerIterator::Downloadable() const
+{
+   VerFileIterator Files = FileList();
+   for (; Files.end() == false; Files++)
+      if ((Files.File()->Flags & Flag::NotSource) != Flag::NotSource)
+	 return true;
+   return false;
+}
+									/*}}}*/
 // PkgFileIterator::IsOk - Checks if the cache is in sync with the file	/*{{{*/
 // PkgFileIterator::IsOk - Checks if the cache is in sync with the file	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This stats the file and compares its stats with the ones that were
 /* This stats the file and compares its stats with the ones that were