summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-worker.cc9
-rw-r--r--apt-pkg/contrib/cdromutl.cc28
-rw-r--r--apt-pkg/contrib/fileutl.cc53
-rw-r--r--apt-pkg/contrib/fileutl.h9
-rw-r--r--apt-pkg/contrib/strutl.cc29
-rw-r--r--apt-pkg/contrib/strutl.h3
-rw-r--r--apt-pkg/deb/deblistparser.cc13
-rw-r--r--apt-pkg/deb/deblistparser.h3
-rw-r--r--apt-pkg/deb/dpkginit.cc88
-rw-r--r--apt-pkg/deb/dpkginit.h9
-rw-r--r--apt-pkg/deb/dpkgpm.cc4
-rw-r--r--apt-pkg/pkgcache.cc4
-rw-r--r--apt-pkg/pkgcachegen.cc47
-rw-r--r--apt-pkg/pkgcachegen.h11
14 files changed, 204 insertions, 106 deletions
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 29d5cd9d5..6d70e79d8 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-worker.cc,v 1.22 1999/05/23 06:47:43 jgg Exp $
+// $Id: acquire-worker.cc,v 1.23 1999/07/26 17:46:07 jgg Exp $
/* ######################################################################
Acquire Worker
@@ -26,7 +26,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
-#include <wait.h>
#include <stdio.h>
#include <errno.h>
/*}}}*/
@@ -84,8 +83,7 @@ pkgAcquire::Worker::~Worker()
if (Process > 0)
{
kill(Process,SIGINT);
- if (waitpid(Process,0,0) != Process)
- _error->Warning("I waited but nothing was there!");
+ ExecWait(Process,Access.c_str(),true);
}
}
/*}}}*/
@@ -471,8 +469,7 @@ bool pkgAcquire::Worker::MethodFailure()
{
_error->Error("Method %s has died unexpectedly!",Access.c_str());
- if (waitpid(Process,0,0) != Process)
- _error->Warning("I waited but nothing was there!");
+ ExecWait(Process,Access.c_str(),true);
Process = -1;
close(InFd);
close(OutFd);
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 7f79e878a..cd8a77aa0 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cdromutl.cc,v 1.7 1999/07/02 22:21:01 jgg Exp $
+// $Id: cdromutl.cc,v 1.8 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
CDROM Utilities - Some functions to manipulate CDROM mounts.
@@ -93,18 +93,7 @@ bool UnmountCdrom(string Path)
}
// Wait for mount
- int Status = 0;
- while (waitpid(Child,&Status,0) != Child)
- {
- if (errno == EINTR)
- continue;
- return _error->Errno("waitpid","Couldn't wait for subprocess");
- }
-
- // Check for an error code.
- if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
- return false;
- return true;
+ return ExecWait(Child,"mount",true);
}
/*}}}*/
// MountCdrom - Mount a cdrom /*{{{*/
@@ -142,18 +131,7 @@ bool MountCdrom(string Path)
}
// Wait for mount
- int Status = 0;
- while (waitpid(Child,&Status,0) != Child)
- {
- if (errno == EINTR)
- continue;
- return _error->Errno("waitpid","Couldn't wait for subprocess");
- }
-
- // Check for an error code.
- if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
- return false;
- return true;
+ return ExecWait(Child,"mount",true);
}
/*}}}*/
// IdentCdrom - Generate a unique string for this CD /*{{{*/
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index c24a216ef..a2c6ab370 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.29 1999/07/20 05:53:33 jgg Exp $
+// $Id: fileutl.cc,v 1.30 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
File Utilities
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
+#include <wait.h>
#include <errno.h>
/*}}}*/
@@ -249,6 +250,47 @@ int ExecFork()
return Process;
}
/*}}}*/
+// ExecWait - Fancy waitpid /*{{{*/
+// ---------------------------------------------------------------------
+/* Waits for the given sub process. If Reap is set the no errors are
+ generated. Otherwise a failed subprocess will generate a proper descriptive
+ message */
+bool ExecWait(int Pid,const char *Name,bool Reap)
+{
+ if (Pid <= 1)
+ return true;
+
+ // Wait and collect the error code
+ int Status;
+ while (waitpid(Pid,&Status,0) != Pid)
+ {
+ if (errno == EINTR)
+ continue;
+
+ if (Reap == true)
+ return false;
+
+ return _error->Error("Waited, for %s but it wasn't there",Name);
+ }
+
+
+ // Check for an error code.
+ if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
+ {
+ if (Reap == true)
+ return false;
+ if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
+ return _error->Error("Sub-process %s recieved a segmentation fault.",Name);
+
+ if (WIFEXITED(Status) != 0)
+ return _error->Error("Sub-process %s returned an error code (%u)",Name,WEXITSTATUS(Status));
+
+ return _error->Error("Sub-process %s exited unexpectedly",Name);
+ }
+
+ return true;
+}
+ /*}}}*/
// FileFd::Open - Open a file /*{{{*/
// ---------------------------------------------------------------------
@@ -302,7 +344,7 @@ FileFd::~FileFd()
// ---------------------------------------------------------------------
/* We are carefull to handle interruption by a signal while reading
gracefully. */
-bool FileFd::Read(void *To,unsigned long Size)
+bool FileFd::Read(void *To,unsigned long Size,bool AllowEof)
{
int Res;
errno = 0;
@@ -325,6 +367,13 @@ bool FileFd::Read(void *To,unsigned long Size)
if (Size == 0)
return true;
+ // Eof handling
+ if (AllowEof == true)
+ {
+ Flags |= HitEof;
+ return true;
+ }
+
Flags |= Fail;
return _error->Error("read, still have %u to read but none left",Size);
}
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 1186fb283..fe904acf5 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.h,v 1.20 1999/07/20 05:53:33 jgg Exp $
+// $Id: fileutl.h,v 1.21 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
File Utilities
@@ -32,14 +32,15 @@ class FileFd
protected:
int iFd;
- enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2)};
+ enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
+ HitEof = (1<<3)};
unsigned long Flags;
string FileName;
public:
enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny};
- bool Read(void *To,unsigned long Size);
+ bool Read(void *To,unsigned long Size,bool AllowEof = false);
bool Write(const void *From,unsigned long Size);
bool Seek(unsigned long To);
bool Skip(unsigned long To);
@@ -56,6 +57,7 @@ class FileFd
inline bool Failed() {return (Flags & Fail) == Fail;};
inline void EraseOnFailure() {Flags |= DelOnFail;};
inline void OpFail() {Flags |= Fail;};
+ inline bool Eof() {return (Flags & HitEof) == HitEof;};
inline string &Name() {return FileName;};
FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1),
@@ -76,6 +78,7 @@ void SetCloseExec(int Fd,bool Close);
void SetNonBlock(int Fd,bool Block);
bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0);
int ExecFork();
+bool ExecWait(int Pid,const char *Name,bool Reap = false);
// File string manipulators
string flNotDir(string File);
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 6c3009462..fb5f6683c 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.26 1999/06/27 04:55:54 jgg Exp $
+// $Id: strutl.cc,v 1.27 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -666,6 +666,33 @@ bool StrToTime(string Val,time_t &Result)
return true;
}
/*}}}*/
+// StrToNum - Convert a fixed length string to a number /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the crazy fixed length string headers in
+ tar and ar files. */
+bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
+{
+ char S[30];
+ if (Len >= sizeof(S))
+ return false;
+ memcpy(S,Str,Len);
+ S[Len] = 0;
+
+ // All spaces is a zero
+ Res = 0;
+ unsigned I;
+ for (I = 0; S[I] == ' '; I++);
+ if (S[I] == 0)
+ return true;
+
+ char *End;
+ Res = strtoul(S,&End,Base);
+ if (End == S)
+ return false;
+
+ return true;
+}
+ /*}}}*/
// URI::CopyFrom - Copy from an object /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 2f2629985..6ba1f9ebe 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.h,v 1.13 1999/05/27 05:54:41 jgg Exp $
+// $Id: strutl.h,v 1.14 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
String Util - These are some usefull string functions
@@ -41,6 +41,7 @@ bool StrToTime(string Val,time_t &Result);
string LookupTag(string Message,const char *Tag,const char *Default = 0);
int StringToBool(string Text,int Default = -1);
bool ReadMessages(int Fd, vector<string> &List);
+bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 182d46829..86cd526fb 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.cc,v 1.20 1999/06/04 05:54:20 jgg Exp $
+// $Id: deblistparser.cc,v 1.21 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -24,6 +24,7 @@
/* */
debListParser::debListParser(FileFd &File) : Tags(File)
{
+ Arch = _config->Find("APT::architecture");
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
@@ -157,7 +158,7 @@ unsigned short debListParser::VersionHash()
char *I = S;
for (; Start != End; Start++)
if (isspace(*Start) == 0)
- *I++ = *Start;
+ *I++ = tolower(*Start);
Result = AddCRC16(Result,S,I - S);
}
@@ -466,11 +467,11 @@ bool debListParser::GrabWord(string Word,WordList *List,int Count,
bool debListParser::Step()
{
iOffset = Tags.Offset();
- string Arch = _config->Find("APT::architecture");
while (Tags.Step(Section) == true)
- {
- /* See if this is the correct Architecture, if it isnt then we
- drop the whole section */
+ {
+ /* See if this is the correct Architecture, if it isn't then we
+ drop the whole section. A missing arch tag only happens (in theory)
+ inside the Status file, so that is a positive return */
const char *Start;
const char *Stop;
if (Section.Find("Architecture",Start,Stop) == false)
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 3c8ea5b0a..6e2c5ef94 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.h,v 1.7 1999/05/23 22:55:55 jgg Exp $
+// $Id: deblistparser.h,v 1.8 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
Debian Package List Parser - This implements the abstract parser
@@ -20,6 +20,7 @@ class debListParser : public pkgCacheGenerator::ListParser
pkgTagFile Tags;
pkgTagSection Section;
unsigned long iOffset;
+ string Arch;
// Parser Helper
struct WordList
diff --git a/apt-pkg/deb/dpkginit.cc b/apt-pkg/deb/dpkginit.cc
index 518d18f59..5327de0e1 100644
--- a/apt-pkg/deb/dpkginit.cc
+++ b/apt-pkg/deb/dpkginit.cc
@@ -1,10 +1,14 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkginit.cc,v 1.2 1999/04/18 06:36:36 jgg Exp $
+// $Id: dpkginit.cc,v 1.3 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG init - Initialize the dpkg stuff
+ This class provides the locking mechanism used by dpkg for its
+ database area. It does the proper consistency checks and acquires the
+ correct kind of lock.
+
##################################################################### */
/*}}}*/
// Includes /*{{{*/
@@ -24,10 +28,10 @@
// DpkgLock::pkgDpkgLock - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgDpkgLock::pkgDpkgLock()
+pkgDpkgLock::pkgDpkgLock(bool WithUpdates)
{
LockFD = -1;
- GetLock();
+ GetLock(WithUpdates);
}
/*}}}*/
// DpkgLock::~pkgDpkgLock - Destructor /*{{{*/
@@ -42,7 +46,7 @@ pkgDpkgLock::~pkgDpkgLock()
// ---------------------------------------------------------------------
/* This mirrors the operations dpkg does when it starts up. Note the
checking of the updates directory. */
-bool pkgDpkgLock::GetLock()
+bool pkgDpkgLock::GetLock(bool WithUpdates)
{
// Disable file locking
if (_config->FindB("Debug::NoLocking",false) == true)
@@ -56,41 +60,15 @@ bool pkgDpkgLock::GetLock()
if (LockFD == -1)
return _error->Error("Unable to lock the administration directory, "
"are you root?");
-
- // Check for updates.. (dirty)
- string File = AdminDir + "updates/";
- DIR *DirP = opendir(File.c_str());
- if (DirP != 0)
+
+ // See if we need to abort with a dirty journal
+ if (WithUpdates == true && CheckUpdates() == false)
{
- /* We ignore any files that are not all digits, this skips .,.. and
- some tmp files dpkg will leave behind.. */
- bool Damaged = false;
- for (struct dirent *Ent = readdir(DirP); Ent != 0; Ent = readdir(DirP))
- {
- Damaged = true;
- for (unsigned int I = 0; Ent->d_name[I] != 0; I++)
- {
- // Check if its not a digit..
- if (isdigit(Ent->d_name[I]) == 0)
- {
- Damaged = false;
- break;
- }
- }
- if (Damaged == true)
- break;
- }
- closedir(DirP);
-
- // Woops, we have to run dpkg to rewrite the status file
- if (Damaged == true)
- {
- Close();
- return _error->Error("dpkg was interrupted, you must manually "
- "run 'dpkg --configure -a' to correct the problem. ");
- }
+ Close();
+ return _error->Error("dpkg was interrupted, you must manually "
+ "run 'dpkg --configure -a' to correct the problem. ");
}
-
+
return true;
}
/*}}}*/
@@ -103,3 +81,39 @@ void pkgDpkgLock::Close()
LockFD = -1;
}
/*}}}*/
+// DpkgLock::CheckUpdates - Check if the updates dir is dirty /*{{{*/
+// ---------------------------------------------------------------------
+/* This does a check of the updates directory to see if it has any entries
+ in it. */
+bool pkgDpkgLock::CheckUpdates()
+{
+ // Check for updates.. (dirty)
+ string File = flNotFile(_config->Find("Dir::State::status")) + "updates/";
+ DIR *DirP = opendir(File.c_str());
+ if (DirP == 0)
+ return true;
+
+ /* We ignore any files that are not all digits, this skips .,.. and
+ some tmp files dpkg will leave behind.. */
+ bool Damaged = false;
+ for (struct dirent *Ent = readdir(DirP); Ent != 0; Ent = readdir(DirP))
+ {
+ Damaged = true;
+ for (unsigned int I = 0; Ent->d_name[I] != 0; I++)
+ {
+ // Check if its not a digit..
+ if (isdigit(Ent->d_name[I]) == 0)
+ {
+ Damaged = false;
+ break;
+ }
+ }
+ if (Damaged == true)
+ break;
+ }
+ closedir(DirP);
+
+ return Damaged;
+}
+ /*}}}*/
+
diff --git a/apt-pkg/deb/dpkginit.h b/apt-pkg/deb/dpkginit.h
index 288f50d04..532ff6236 100644
--- a/apt-pkg/deb/dpkginit.h
+++ b/apt-pkg/deb/dpkginit.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkginit.h,v 1.1 1998/11/23 07:03:11 jgg Exp $
+// $Id: dpkginit.h,v 1.2 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG init - Initialize the dpkg stuff
@@ -23,10 +23,11 @@ class pkgDpkgLock
public:
- bool GetLock();
+ bool CheckUpdates();
+ bool GetLock(bool WithUpdates);
void Close();
-
- pkgDpkgLock();
+
+ pkgDpkgLock(bool WithUpdates = true);
~pkgDpkgLock();
};
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 4e108c419..7645929db 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkgpm.cc,v 1.11 1999/07/09 04:11:34 jgg Exp $
+// $Id: dpkgpm.cc,v 1.12 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG Package Manager - Provide an interface to dpkg
@@ -121,7 +121,7 @@ bool pkgDPkgPM::RunScripts(const char *Cnf)
// Restore sig int/quit
signal(SIGQUIT,SIG_DFL);
signal(SIGINT,SIG_DFL);
-
+
// Check for an error code.
if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
{
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 040c672c8..b07c02a3b 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.cc,v 1.26 1999/06/04 05:54:20 jgg Exp $
+// $Id: pkgcache.cc,v 1.27 1999/07/26 17:46:07 jgg Exp $
/* ######################################################################
Package Cache - Accessor code for the cache
@@ -44,7 +44,7 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
MajorVersion = 3;
- MinorVersion = 2;
+ MinorVersion = 3;
Dirty = true;
HeaderSz = sizeof(pkgCache::Header);
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 478778946..0a645ca7e 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcachegen.cc,v 1.40 1999/07/15 03:15:48 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.41 1999/07/26 17:46:07 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -33,8 +33,10 @@
// ---------------------------------------------------------------------
/* We set the diry flag and make sure that is written to the disk */
pkgCacheGenerator::pkgCacheGenerator(DynamicMMap &Map,OpProgress &Prog) :
- Map(Map), Cache(Map), Progress(Prog)
+ Map(Map), Cache(Map), Progress(&Prog)
{
+ CurrentFile = 0;
+
if (_error->PendingError() == true)
return;
@@ -68,7 +70,8 @@ pkgCacheGenerator::~pkgCacheGenerator()
// ---------------------------------------------------------------------
/* This provides the generation of the entries in the cache. Each loop
goes through a single package record from the underlying parse engine. */
-bool pkgCacheGenerator::MergeList(ListParser &List)
+bool pkgCacheGenerator::MergeList(ListParser &List,
+ pkgCache::VerIterator *OutVer)
{
List.Owner = this;
@@ -84,8 +87,8 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
if (NewPackage(Pkg,PackageName) == false)
return _error->Error("Error occured while processing %s (NewPackage)",PackageName.c_str());
Counter++;
- if (Counter % 100 == 0)
- Progress.Progress(List.Offset());
+ if (Counter % 100 == 0 && Progress != 0)
+ Progress->Progress(List.Offset());
/* 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
@@ -120,6 +123,13 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
if (NewFileVer(Ver,List) == false)
return _error->Error("Error occured while processing %s (NewFileVer1)",PackageName.c_str());
+ // Read only a single record and return
+ if (OutVer != 0)
+ {
+ *OutVer = Ver;
+ return true;
+ }
+
continue;
}
@@ -147,6 +157,13 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
if (NewFileVer(Ver,List) == false)
return _error->Error("Error occured while processing %s (NewVersion2)",PackageName.c_str());
+
+ // Read only a single record and return
+ if (OutVer != 0)
+ {
+ *OutVer = Ver;
+ return true;
+ }
}
return true;
@@ -188,6 +205,9 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,string Name)
bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
ListParser &List)
{
+ if (CurrentFile == 0)
+ return true;
+
// Get a structure
unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
if (VerFile == 0)
@@ -366,7 +386,8 @@ bool pkgCacheGenerator::SelectFile(string File,unsigned long Flags)
if (CurrentFile->FileName == 0)
return false;
- Progress.SubProgress(Buf.st_size);
+ if (Progress != 0)
+ Progress->SubProgress(Buf.st_size);
return true;
}
/*}}}*/
@@ -572,10 +593,10 @@ bool pkgPkgCacheCheck(string CacheFile)
return true;
}
/*}}}*/
-// AddSourcesSize - Add the size of the status files /*{{{*/
+// AddStatusSize - Add the size of the status files /*{{{*/
// ---------------------------------------------------------------------
/* This adds the size of all the status files to the size counter */
-static bool pkgAddSourcesSize(unsigned long &TotalSize)
+bool pkgAddStatusSize(unsigned long &TotalSize)
{
// Grab the file names
string xstatus = _config->FindFile("Dir::State::xstatus");
@@ -598,8 +619,8 @@ static bool pkgAddSourcesSize(unsigned long &TotalSize)
// MergeStatus - Add the status files to the cache /*{{{*/
// ---------------------------------------------------------------------
/* This adds the status files to the map */
-static bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
- unsigned long &CurrentSize,unsigned long TotalSize)
+bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
+ unsigned long &CurrentSize,unsigned long TotalSize)
{
// Grab the file names
string Status[3];
@@ -653,7 +674,7 @@ bool pkgGenerateSrcCache(pkgSourceList &List,OpProgress &Progress,
TotalSize += Buf.st_size;
}
- if (pkgAddSourcesSize(TotalSize) == false)
+ if (pkgAddStatusSize(TotalSize) == false)
return false;
// Generate the pkg source cache
@@ -759,7 +780,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
// Compute the progress
unsigned long TotalSize = 0;
- if (pkgAddSourcesSize(TotalSize) == false)
+ if (pkgAddStatusSize(TotalSize) == false)
return false;
unsigned long CurrentSize = 0;
@@ -873,7 +894,7 @@ MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
// Compute the progress
unsigned long TotalSize = 0;
- if (pkgAddSourcesSize(TotalSize) == false)
+ if (pkgAddStatusSize(TotalSize) == false)
{
delete Map;
return 0;
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 2bdabcee0..f264b314d 100644
--- a/apt-pkg/pkgcachegen.h
+++ b/apt-pkg/pkgcachegen.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcachegen.h,v 1.16 1999/07/15 03:15:48 jgg Exp $
+// $Id: pkgcachegen.h,v 1.17 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -45,7 +45,7 @@ class pkgCacheGenerator
DynamicMMap &Map;
pkgCache Cache;
- OpProgress &Progress;
+ OpProgress *Progress;
string PkgFileName;
pkgCache::PackageFile *CurrentFile;
@@ -59,8 +59,9 @@ class pkgCacheGenerator
public:
+ void DropProgress() {Progress = 0;};
bool SelectFile(string File,unsigned long Flags = 0);
- bool MergeList(ListParser &List);
+ bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
inline pkgCache &GetCache() {return Cache;};
inline pkgCache::PkgFileIterator GetCurFile()
{return pkgCache::PkgFileIterator(Cache,CurrentFile);};
@@ -112,4 +113,8 @@ class pkgCacheGenerator::ListParser
virtual ~ListParser() {};
};
+bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
+ unsigned long &CurrentSize,unsigned long TotalSize);
+bool pkgAddStatusSize(unsigned long &TotalSize);
+
#endif