Преглед изворни кода

Fixed espy's bug with experimental
Author: jgg
Date: 1999-04-12 04:21:20 GMT
Fixed espy's bug with experimental

Arch Librarian пре 22 година
родитељ
комит
1fcbfcb8ba
6 измењених фајлова са 54 додато и 52 уклоњено
  1. 6 18
      apt-pkg/depcache.cc
  2. 2 2
      apt-pkg/depcache.h
  3. 2 2
      apt-pkg/makefile
  4. 38 1
      apt-pkg/pkgcache.cc
  5. 2 1
      apt-pkg/pkgcache.h
  6. 4 28
      cmdline/apt-cache.cc

+ 6 - 18
apt-pkg/depcache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: depcache.cc,v 1.15 1999/03/26 07:38:43 jgg Exp $
+// $Id: depcache.cc,v 1.16 1999/04/12 04:21:20 jgg Exp $
 /* ######################################################################
 
    Dependency Cache - Caches Dependency information.
@@ -99,25 +99,13 @@ bool pkgDepCache::Init(OpProgress *Prog)
 // ---------------------------------------------------------------------
 /* The default just returns the target version if it exists or the
    highest version. */
-pkgDepCache::VerIterator pkgDepCache::GetCandidateVer(PkgIterator Pkg)
+pkgDepCache::VerIterator pkgDepCache::GetCandidateVer(PkgIterator Pkg,
+						      bool AllowCurrent)
 {
    // Try to use an explicit target
-   if (Pkg->TargetVer == 0)
-   {
-      /* Not source/not automatic versions cannot be a candidate version 
-         unless they are already installed */
-      for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
-      {
-	 if (Pkg.CurrentVer() == I)
-	    return I;
-	 for (VerFileIterator J = I.FileList(); J.end() == false; J++)
-	    if ((J.File()->Flags & Flag::NotSource) == 0 &&
-		(J.File()->Flags & Flag::NotAutomatic) == 0)
-		return I;
-      }
-	 
-      return VerIterator(*this,0);
-   }
+   if (Pkg->TargetVer == 0 || 
+       (AllowCurrent == false && Pkg.TargetVer() == Pkg.CurrentVer()))
+      return pkgCache::GetCandidateVer(Pkg,AllowCurrent);
    else
       return Pkg.TargetVer(); 
 }

+ 2 - 2
apt-pkg/depcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: depcache.h,v 1.8 1998/12/08 01:34:10 jgg Exp $
+// $Id: depcache.h,v 1.9 1999/04/12 04:21:20 jgg Exp $
 /* ######################################################################
 
    DepCache - Dependency Extension data for the cache
@@ -153,7 +153,7 @@ class pkgDepCache : public pkgCache
    public:
 
    // Policy implementation
-   virtual VerIterator GetCandidateVer(PkgIterator Pkg);
+   virtual VerIterator GetCandidateVer(PkgIterator Pkg,bool AllowCurrent = true);
    virtual bool IsImportantDep(DepIterator Dep);
          
    // Accessors

+ 2 - 2
apt-pkg/makefile

@@ -11,8 +11,8 @@ include ../buildlib/defaults.mak
 
 # The library name
 LIBRARY=apt-pkg
-MAJOR=2.2
-MINOR=1
+MAJOR=2.3
+MINOR=0
 SLIBS=$(PTHREADLIB)
 
 # Source code for the contributed non-core things

+ 38 - 1
apt-pkg/pkgcache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: pkgcache.cc,v 1.23 1999/02/23 06:46:24 jgg Exp $
+// $Id: pkgcache.cc,v 1.24 1999/04/12 04:21:20 jgg Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
@@ -177,6 +177,43 @@ const char *pkgCache::Priority(unsigned char Prio)
    return 0;
 }
 									/*}}}*/
+// Cache::GetCandidateVer - Returns the Candidate install version	/*{{{*/
+// ---------------------------------------------------------------------
+/* The default just returns the highest available version that is not
+   a source and automatic */
+pkgCache::VerIterator pkgCache::GetCandidateVer(PkgIterator Pkg,
+						bool AllowCurrent)
+{
+   /* Not source/not automatic versions cannot be a candidate version 
+      unless they are already installed */
+   VerIterator Last(*this,0);
+   
+   for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
+   {
+      if (Pkg.CurrentVer() == I && AllowCurrent == true)
+	 return I;
+      
+      for (VerFileIterator J = I.FileList(); J.end() == false; J++)
+      {
+	 if ((J.File()->Flags & Flag::NotSource) != 0)
+	    continue;
+
+	 /* Stash the highest version of a not-automatic source, we use it
+	    if there is nothing better */
+	 if ((J.File()->Flags & Flag::NotAutomatic) != 0)
+	 {
+	    if (Last.end() == true)
+	       Last = I;
+	    continue;
+	 }
+	 
+	 return I;
+      }   
+   }
+   
+   return Last;
+}
+									/*}}}*/
 
 // Bases for iterator classes						/*{{{*/
 void pkgCache::VerIterator::_dummy() {}

+ 2 - 1
apt-pkg/pkgcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: pkgcache.h,v 1.18 1999/02/23 06:46:24 jgg Exp $
+// $Id: pkgcache.h,v 1.19 1999/04/12 04:21:20 jgg Exp $
 /* ######################################################################
    
    Cache - Structure definitions for the cache file
@@ -124,6 +124,7 @@ class pkgCache
    inline PkgIterator PkgEnd();
    inline PkgFileIterator FileBegin();
    inline PkgFileIterator FileEnd();
+   VerIterator GetCandidateVer(PkgIterator Pkg,bool AllowCurrent = true);
    
    pkgCache(MMap &Map);
    virtual ~pkgCache() {};

+ 4 - 28
cmdline/apt-cache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: apt-cache.cc,v 1.32 1999/03/29 19:28:52 jgg Exp $
+// $Id: apt-cache.cc,v 1.33 1999/04/12 04:21:20 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -331,30 +331,6 @@ bool Dump(CommandLine &Cmd)
    return true;
 }
 									/*}}}*/
-// GetCandidateVer - Returns the Candidate install version		/*{{{*/
-// ---------------------------------------------------------------------
-/* This should really use the DepCache or something.. Copied from there. 
-   Allow current is required to filter out the status file when emitting
-   an available file. */
-static pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg,
-					     bool AllowCurrent = true)
-{
-   /* Not source/not automatic versions cannot be a candidate version 
-    unless they are already installed */
-   for (pkgCache::VerIterator I = Pkg.VersionList(); I.end() == false; I++)
-   {
-      if (Pkg.CurrentVer() == I && AllowCurrent == true)
-	 return I;
-      
-      for (pkgCache::VerFileIterator J = I.FileList(); J.end() == false; J++)
-	 if ((J.File()->Flags & pkgCache::Flag::NotSource) == 0 &&
-	     (J.File()->Flags & pkgCache::Flag::NotAutomatic) == 0)
-	    return I;
-   }
-   
-   return pkgCache::VerIterator(*GCache,0);
-}
-									/*}}}*/
 // DumpAvail - Print out the available list				/*{{{*/
 // ---------------------------------------------------------------------
 /* This is needed to make dpkg --merge happy */
@@ -386,7 +362,7 @@ bool DumpAvail(CommandLine &Cmd)
       for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
       {
 	 // Find the proper version to use. We should probably use the DepCache.
-	 pkgCache::VerIterator V = GetCandidateVer(P,false);
+	 pkgCache::VerIterator V = Cache.GetCandidateVer(P,false);
 
 	 if (V.end() == true || V.FileList().File() != I)
 	    continue;
@@ -521,7 +497,7 @@ bool Search(CommandLine &CmdL)
    for (;I.end() != true; I++)
    {
       // We search against the install version as that makes the most sense..
-      pkgCache::VerIterator V = GetCandidateVer(I);
+      pkgCache::VerIterator V = Cache.GetCandidateVer(I);
       if (V.end() == true)
 	 continue;
 
@@ -558,7 +534,7 @@ bool ShowPackage(CommandLine &CmdL)
       }
       
       // Find the proper version to use. We should probably use the DepCache.
-      pkgCache::VerIterator V = GetCandidateVer(Pkg);
+      pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg);
       if (V.end() == true || V.FileList().end() == true)
 	 continue;
       if (DisplayRecord(V) == false)