// -*- mode: cpp; mode: fold -*-
// 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.
/* This replaces all occurances of Subst with Contents in Str. */
string SubstVar(string Str,string Subst,string Contents)
{
- string::size_type Pos;
+ string::size_type Pos = 0;
string::size_type OldPos = 0;
string Temp;
// -*- mode: cpp; mode: fold -*-
// 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.
if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
return false;
- if (ParseDepends(Ver,"PreDepends",pkgCache::Dep::PreDepends) == false)
+ if (ParseDepends(Ver,"Pre-Depends",pkgCache::Dep::PreDepends) == false)
return false;
if (ParseDepends(Ver,"Suggests",pkgCache::Dep::Suggests) == false)
return false;
string Version;
unsigned int Op;
- while ((Start = ParseDepends(Start,Stop,Package,Version,Op)) != Stop)
+ while (1)
{
+ Start = ParseDepends(Start,Stop,Package,Version,Op);
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);
-
+
if (NewDepends(Ver,Package,Version,Op,Type) == false)
return false;
+ if (Start == Stop)
+ break;
}
return true;
}
// -*- mode: cpp; mode: fold -*-
// 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
#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
understand them. That is, if they don't start with a / then their parent
is prepended, this allows a fair degree of flexability. */
-bool pkglibInitialize(Configuration &Cnf)
+bool pkgInitialize(Configuration &Cnf)
{
// General APT things
Cnf.Set("APT::Architecture","i386");
// -*- mode: cpp; mode: fold -*-
// 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
#include <apt-pkg/configuration.h>
-bool pkglibInitialize(Configuration &Cnf);
+bool pkgInitialize(Configuration &Cnf);
#endif
// -*- mode: cpp; mode: fold -*-
// 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.
// Get a pointer to the package structure
string PackageName = List.Package();
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
so we use that fact in the search. Insertion of new versions is
/* This creates a new package structure and adds it to the hash table */
bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
{
+ Pkg = Cache.FindPkg(Name);
+ if (Pkg.end() == false)
+ return true;
+
// Get a structure
unsigned long Package = Map.Allocate(sizeof(pkgCache::Package));
if (Package == 0)
Dep->ID = Cache.HeaderP->DependsCount++;
// 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
if (Version.empty() == false)
// ---------------------------------------------------------------------
/* */
bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
- string PackageName,
+ string PackageName,
string Version)
{
pkgCache &Cache = Owner->Cache;
+
+ // We do not add self referencing provides
+ if (Ver.ParentPkg().Name() == PackageName)
+ return true;
// Get a structure
unsigned long Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
return false;
// 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
Prv->ParentPkg = Pkg.Index();
if (CurrentFile->FileName == 0)
return false;
+ return true;
}
/*}}}*/
// CacheGenerator::WriteUniqueString - Insert a unique string /*{{{*/
// -*- mode: cpp; mode: fold -*-
// 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
#include <apt-pkg/tagfile.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/init.h>
#include <string>
#include <stdio.h>
// -*- mode: cpp; mode: fold -*-
// 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
class pkgTagFile
{
- File Fd;
+ File &Fd;
char *Buffer;
char *Start;
char *End;
// -*- mode: cpp; mode: fold -*-
// 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.
#include <apt-pkg/error.h>
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/init.h>
#include <iostream.h>
#include <fstream.h>
{
if (SplitArg(argv[I],FileName,Dist,Ver) == false)
return false;
+ cout << FileName << endl;
// Do the merge
File TagF(FileName.c_str(),File::ReadOnly);
debListParser Parser(TagF);
if (_error->PendingError() == true)
- return false;
+ return _error->Error("Problem opening %s",FileName.c_str());
+
if (Gen.SelectFile(FileName) == false)
- return false;
+ return _error->Error("Problem with SelectFile");
if (Gen.MergeList(Parser) == false)
- return false;
+ return _error->Error("Problem with MergeList");
}
return true;
for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++)
cout << Prv.ParentPkg().Name() << " ";
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;
cerr << "Usage is apt-cache add cache file1:dist:ver file2:dist:ver ..." << endl;
return 100;
}
-
+
+ pkgInitialize(*_config);
while (1)
{
if (strcmp(argv[1],"add") == 0)