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

Working cache generator
Author: jgg
Date: 1998-07-16 06:08:36 GMT
Working cache generator

Arch Librarian лет назад: 22
Родитель
Сommit
8efa2a3ba4
8 измененных файлов с 50 добавлено и 37 удалено
  1. 2 2
      apt-pkg/contrib/strutl.cc
  2. 7 4
      apt-pkg/deb/deblistparser.cc
  3. 3 3
      apt-pkg/init.cc
  4. 2 2
      apt-pkg/init.h
  5. 19 16
      apt-pkg/pkgcachegen.cc
  6. 1 2
      apt-pkg/tagfile.cc
  7. 2 2
      apt-pkg/tagfile.h
  8. 14 6
      cmdline/apt-cache.cc

+ 2 - 2
apt-pkg/contrib/strutl.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: strutl.cc,v 1.1 1998/07/07 04:17:16 jgg Exp $
+// $Id: strutl.cc,v 1.2 1998/07/16 06:08:41 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    String Util - Some usefull string functions.
    String Util - Some usefull string functions.
@@ -226,7 +226,7 @@ string TimeToStr(unsigned long Sec)
 /* This replaces all occurances of Subst with Contents in Str. */
 /* This replaces all occurances of Subst with Contents in Str. */
 string SubstVar(string Str,string Subst,string Contents)
 string SubstVar(string Str,string Subst,string Contents)
 {
 {
-   string::size_type Pos;
+   string::size_type Pos = 0;
    string::size_type OldPos = 0;
    string::size_type OldPos = 0;
    string Temp;
    string Temp;
    
    

+ 7 - 4
apt-pkg/deb/deblistparser.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: deblistparser.cc,v 1.6 1998/07/12 23:58:52 jgg Exp $
+// $Id: deblistparser.cc,v 1.7 1998/07/16 06:08:42 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    Package Cache Generator - Generator for the cache structure.
    Package Cache Generator - Generator for the cache structure.
@@ -162,7 +162,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
 
 
    if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
    if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
       return false;
       return false;
-   if (ParseDepends(Ver,"PreDepends",pkgCache::Dep::PreDepends) == false)
+   if (ParseDepends(Ver,"Pre-Depends",pkgCache::Dep::PreDepends) == false)
       return false;
       return false;
    if (ParseDepends(Ver,"Suggests",pkgCache::Dep::Suggests) == false)
    if (ParseDepends(Ver,"Suggests",pkgCache::Dep::Suggests) == false)
       return false;
       return false;
@@ -426,13 +426,16 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
    string Version;
    string Version;
    unsigned int Op;
    unsigned int Op;
 
 
-   while ((Start = ParseDepends(Start,Stop,Package,Version,Op)) != Stop)
+   while (1)
    {
    {
+      Start = ParseDepends(Start,Stop,Package,Version,Op);
       if (Start == 0)
       if (Start == 0)
 	 return _error->Error("Problem parsing dependency %s",Tag);
 	 return _error->Error("Problem parsing dependency %s",Tag);
-
+      
       if (NewDepends(Ver,Package,Version,Op,Type) == false)
       if (NewDepends(Ver,Package,Version,Op,Type) == false)
 	 return false;
 	 return false;
+      if (Start == Stop)
+	 break;
    }
    }
    return true;
    return true;
 }
 }

+ 3 - 3
apt-pkg/init.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: init.cc,v 1.2 1998/07/12 23:58:26 jgg Exp $
+// $Id: init.cc,v 1.3 1998/07/16 06:08:36 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Init - Initialize the package library
    Init - Initialize the package library
@@ -11,12 +11,12 @@
 #include <apt-pkg/init.h>
 #include <apt-pkg/init.h>
 									/*}}}*/
 									/*}}}*/
 
 
-// pkglibInitialize - Initialize the configuration class		/*{{{*/
+// pkgInitialize - Initialize the configuration class			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Directories are specified in such a way that the FindDir function will
 /* Directories are specified in such a way that the FindDir function will
    understand them. That is, if they don't start with a / then their parent
    understand them. That is, if they don't start with a / then their parent
    is prepended, this allows a fair degree of flexability. */
    is prepended, this allows a fair degree of flexability. */
-bool pkglibInitialize(Configuration &Cnf)
+bool pkgInitialize(Configuration &Cnf)
 {
 {
    // General APT things
    // General APT things
    Cnf.Set("APT::Architecture","i386");
    Cnf.Set("APT::Architecture","i386");

+ 2 - 2
apt-pkg/init.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: init.h,v 1.2 1998/07/12 23:58:27 jgg Exp $
+// $Id: init.h,v 1.3 1998/07/16 06:08:37 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Init - Initialize the package library
    Init - Initialize the package library
@@ -16,6 +16,6 @@
 
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 
 
-bool pkglibInitialize(Configuration &Cnf);
+bool pkgInitialize(Configuration &Cnf);
 
 
 #endif
 #endif

+ 19 - 16
apt-pkg/pkgcachegen.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: pkgcachegen.cc,v 1.9 1998/07/12 23:58:34 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.10 1998/07/16 06:08:38 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    Package Cache Generator - Generator for the cache structure.
    Package Cache Generator - Generator for the cache structure.
@@ -69,12 +69,8 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
       // Get a pointer to the package structure
       // Get a pointer to the package structure
       string PackageName = List.Package();
       string PackageName = List.Package();
       pkgCache::PkgIterator Pkg;
       pkgCache::PkgIterator Pkg;
-      Cache.FindPkg(PackageName);
-      if (Pkg.end() == true)
-      {
-	 if (NewPackage(Pkg,PackageName) == false)
-	    return false;
-      }
+      if (NewPackage(Pkg,PackageName) == false)
+	 return false;
       
       
       /* Get a pointer to the version structure. We know the list is sorted
       /* Get a pointer to the version structure. We know the list is sorted
          so we use that fact in the search. Insertion of new versions is
          so we use that fact in the search. Insertion of new versions is
@@ -132,6 +128,10 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
 /* This creates a new package structure and adds it to the hash table */
 /* This creates a new package structure and adds it to the hash table */
 bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
 bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
 {
 {
+   Pkg = Cache.FindPkg(Name);
+   if (Pkg.end() == false)
+      return true;
+       
    // Get a structure
    // Get a structure
    unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
    unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
    if (Package == 0)
    if (Package == 0)
@@ -222,10 +222,9 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
    Dep->ID = Cache.HeaderP->DependsCount++;
    Dep->ID = Cache.HeaderP->DependsCount++;
    
    
    // Locate the target package
    // Locate the target package
-   pkgCache::PkgIterator Pkg = Cache.FindPkg(PackageName);
-   if (Pkg.end() == true)
-      if (Owner->NewPackage(Pkg,PackageName) == false)
-	 return false;
+   pkgCache::PkgIterator Pkg;
+   if (Owner->NewPackage(Pkg,PackageName) == false)
+      return false;
    
    
    // Probe the reverse dependency list for a version string that matches
    // Probe the reverse dependency list for a version string that matches
    if (Version.empty() == false)
    if (Version.empty() == false)
@@ -257,10 +256,14 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
 bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
 bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
-					       string PackageName,
+					        string PackageName,
 						string Version)
 						string Version)
 {
 {
    pkgCache &Cache = Owner->Cache;
    pkgCache &Cache = Owner->Cache;
+
+   // We do not add self referencing provides
+   if (Ver.ParentPkg().Name() == PackageName)
+      return true;
    
    
    // Get a structure
    // Get a structure
    unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
    unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
@@ -276,10 +279,9 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
       return false;
       return false;
    
    
    // Locate the target package
    // Locate the target package
-   pkgCache::PkgIterator Pkg = Cache.FindPkg(PackageName);
-   if (Pkg.end() == true)
-      if (Owner->NewPackage(Pkg,PackageName) == false)
-	 return false;
+   pkgCache::PkgIterator Pkg;
+   if (Owner->NewPackage(Pkg,PackageName) == false)
+      return false;
    
    
    // Link it to the package
    // Link it to the package
    Prv->ParentPkg = Pkg.Index();
    Prv->ParentPkg = Pkg.Index();
@@ -314,6 +316,7 @@ bool pkgCacheGenerator::SelectFile(string File,unsigned long Flags)
 
 
    if (CurrentFile->FileName == 0)
    if (CurrentFile->FileName == 0)
       return false;
       return false;
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // CacheGenerator::WriteUniqueString - Insert a unique string		/*{{{*/
 // CacheGenerator::WriteUniqueString - Insert a unique string		/*{{{*/

+ 1 - 2
apt-pkg/tagfile.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: tagfile.cc,v 1.7 1998/07/12 23:58:39 jgg Exp $
+// $Id: tagfile.cc,v 1.8 1998/07/16 06:08:39 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Fast scanner for RFC-822 type header information
    Fast scanner for RFC-822 type header information
@@ -17,7 +17,6 @@
 
 
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
-#include <apt-pkg/init.h>
 
 
 #include <string>
 #include <string>
 #include <stdio.h>
 #include <stdio.h>

+ 2 - 2
apt-pkg/tagfile.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: tagfile.h,v 1.4 1998/07/12 23:58:40 jgg Exp $
+// $Id: tagfile.h,v 1.5 1998/07/16 06:08:40 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Fast scanner for RFC-822 type header information
    Fast scanner for RFC-822 type header information
@@ -50,7 +50,7 @@ class pkgTagSection
 
 
 class pkgTagFile
 class pkgTagFile
 {
 {
-   File Fd;
+   File &Fd;
    char *Buffer;
    char *Buffer;
    char *Start;
    char *Start;
    char *End;
    char *End;

+ 14 - 6
cmdline/apt-cache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-cache.cc,v 1.1 1998/07/15 05:56:47 jgg Exp $
+// $Id: apt-cache.cc,v 1.2 1998/07/16 06:08:43 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    apt-cache - Manages the cache file.
    apt-cache - Manages the cache file.
@@ -27,6 +27,7 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/deblistparser.h>
+#include <apt-pkg/init.h>
 
 
 #include <iostream.h>
 #include <iostream.h>
 #include <fstream.h>
 #include <fstream.h>
@@ -89,17 +90,19 @@ bool DoAdd(int argc,char *argv[])
    {
    {
       if (SplitArg(argv[I],FileName,Dist,Ver) == false)
       if (SplitArg(argv[I],FileName,Dist,Ver) == false)
 	 return false;
 	 return false;
+      cout << FileName << endl;
       
       
       // Do the merge
       // Do the merge
       File TagF(FileName.c_str(),File::ReadOnly);
       File TagF(FileName.c_str(),File::ReadOnly);
       debListParser Parser(TagF);
       debListParser Parser(TagF);
       if (_error->PendingError() == true)
       if (_error->PendingError() == true)
-	 return false;
+	 return _error->Error("Problem opening %s",FileName.c_str());
+      
       if (Gen.SelectFile(FileName) == false)
       if (Gen.SelectFile(FileName) == false)
-	 return false;
+	 return _error->Error("Problem with SelectFile");
 	 
 	 
       if (Gen.MergeList(Parser) == false)
       if (Gen.MergeList(Parser) == false)
-	 return false;
+	 return _error->Error("Problem with MergeList");
    }
    }
    
    
    return true;
    return true;
@@ -157,7 +160,11 @@ bool DumpPackage(int argc,char *argv[])
 	 for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++)
 	 for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++)
 	    cout << Prv.ParentPkg().Name() << " ";
 	    cout << Prv.ParentPkg().Name() << " ";
 	 cout << endl;
 	 cout << endl;
-      }      
+      }
+      cout << "Reverse Provides: " << endl;
+      for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++)
+	 cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr();
+      cout << endl;
    }
    }
 
 
    return true;
    return true;
@@ -333,7 +340,8 @@ int main(int argc, char *argv[])
       cerr << "Usage is apt-cache add cache file1:dist:ver file2:dist:ver ..." << endl;
       cerr << "Usage is apt-cache add cache file1:dist:ver file2:dist:ver ..." << endl;
       return 100;
       return 100;
    }
    }
-   
+
+   pkgInitialize(*_config);
    while (1)
    while (1)
    {
    {
       if (strcmp(argv[1],"add") == 0)
       if (strcmp(argv[1],"add") == 0)