summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:50:59 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:50:59 +0000
commite1b74f61dfb6980d643cb7c666c761ff3bda2f1e (patch)
tree1a2ce32d1bd25d0c0f2be05ad013306f64bb8b93 /apt-pkg
parent08e8f724674eb96678dcabf856534c58f5c29996 (diff)
Sync
Author: jgg Date: 1998-09-26 05:34:18 GMT Sync
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/cmndline.cc39
-rw-r--r--apt-pkg/contrib/cmndline.h8
-rw-r--r--apt-pkg/contrib/configuration.cc18
-rw-r--r--apt-pkg/init.cc6
-rw-r--r--apt-pkg/makefile4
-rw-r--r--apt-pkg/orderlist.cc3
-rw-r--r--apt-pkg/pkgcachegen.cc36
7 files changed, 79 insertions, 35 deletions
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 6b36325c7..8e25d395f 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.cc,v 1.1 1998/09/22 05:30:26 jgg Exp $
+// $Id: cmndline.cc,v 1.2 1998/09/26 05:34:24 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -24,11 +24,20 @@ CommandLine::CommandLine(Args *AList,Configuration *Conf) : ArgList(AList),
{
}
/*}}}*/
+// CommandLine::~CommandLine - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+CommandLine::~CommandLine()
+{
+ delete [] FileList;
+}
+ /*}}}*/
// CommandLine::Parse - Main action member /*{{{*/
// ---------------------------------------------------------------------
/* */
bool CommandLine::Parse(int argc,const char **argv)
{
+ delete [] FileList;
FileList = new const char *[argc];
const char **Files = FileList;
int I;
@@ -99,6 +108,10 @@ bool CommandLine::Parse(int argc,const char **argv)
if (A->end() == true)
return _error->Error("Command line option %s is not understood",argv[I]);
+
+ // The option is not boolean
+ if (A->IsBoolean() == false)
+ return _error->Error("Command line option %s is not boolean",argv[I]);
}
// Deal with it.
@@ -164,6 +177,19 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Parse a configuration file
if ((A->Flags & ConfigFile) == ConfigFile)
return ReadConfigFile(*Conf,Argument);
+
+ // Arbitary item specification
+ if ((A->Flags & ArbItem) == ArbItem)
+ {
+ const char *J;
+ for (J = Argument; *J != 0 && *J != '='; J++);
+ if (*J == 0)
+ return _error->Error("Option %s: Configuration item sepecification must have an =.",argv[I]);
+
+ Conf->Set(string(Argument,J-Argument),string(J+1));
+
+ return true;
+ }
Conf->Set(A->ConfName,Argument);
return true;
@@ -278,3 +304,14 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
return true;
}
/*}}}*/
+// CommandLine::FileSize - Count the number of filenames /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+unsigned int CommandLine::FileSize() const
+{
+ unsigned int Count = 0;
+ for (const char **I = FileList; I != 0 && *I != 0; I++)
+ Count++;
+ return Count;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 038f421e7..27f69729c 100644
--- a/apt-pkg/contrib/cmndline.h
+++ b/apt-pkg/contrib/cmndline.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.h,v 1.1 1998/09/22 05:30:26 jgg Exp $
+// $Id: cmndline.h,v 1.2 1998/09/26 05:34:25 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -67,15 +67,18 @@ class CommandLine
IntLevel = (1 << 1),
Boolean = (1 << 2),
InvBoolean = (1 << 3),
- ConfigFile = (1 << 4) | HasArg
+ ConfigFile = (1 << 4) | HasArg,
+ ArbItem = (1 << 5) | HasArg
};
const char **FileList;
bool Parse(int argc,const char **argv);
void ShowHelp();
+ unsigned int FileSize() const;
CommandLine(Args *AList,Configuration *Conf);
+ ~CommandLine();
};
struct CommandLine::Args
@@ -86,6 +89,7 @@ struct CommandLine::Args
unsigned long Flags;
inline bool end() {return ShortOpt == 0 && LongOpt == 0;};
+ inline bool IsBoolean() {return Flags == 0 || (Flags & (Boolean|InvBoolean)) != 0;};
};
#endif
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index bff2dc6e3..b12fed6be 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.4 1998/09/22 05:30:26 jgg Exp $
+// $Id: configuration.cc,v 1.5 1998/09/26 05:34:26 jgg Exp $
/* ######################################################################
Configuration Class
@@ -156,17 +156,17 @@ bool Configuration::FindB(const char *Name,bool Default)
if (End == Itm->Value.c_str() || Res < 0 || Res > 1)
{
// Check for positives
- if (strcasecmp(Itm->Value,"no") == 0 ||
- strcasecmp(Itm->Value,"false") == 0 ||
- strcasecmp(Itm->Value,"without") == 0 ||
- strcasecmp(Itm->Value,"disable") == 0)
+ if (strcasecmp(Itm->Value.c_str(),"no") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"false") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"without") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"disable") == 0)
return false;
// Check for negatives
- if (strcasecmp(Itm->Value,"no") == 0 ||
- strcasecmp(Itm->Value,"false") == 0 ||
- strcasecmp(Itm->Value,"without") == 0 ||
- strcasecmp(Itm->Value,"disable") == 0)
+ if (strcasecmp(Itm->Value.c_str(),"yes") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"true") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"with") == 0 ||
+ strcasecmp(Itm->Value.c_str(),"enable") == 0)
return false;
return Default;
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index e171d2c6c..27353c878 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: init.cc,v 1.5 1998/09/22 05:30:24 jgg Exp $
+// $Id: init.cc,v 1.6 1998/09/26 05:34:19 jgg Exp $
/* ######################################################################
Init - Initialize the package library
@@ -38,8 +38,8 @@ bool pkgInitialize(Configuration &Cnf)
// Cache
Cnf.Set("Dir::Cache","/tmp/");
Cnf.Set("Dir::Cache::archives","archives/");
- Cnf.Set("Dir::Cache::srcpkgcache","srcpkgcache");
- Cnf.Set("Dir::Cache::pkgcache","pkgcache");
+ Cnf.Set("Dir::Cache::srcpkgcache","srcpkgcache.bin");
+ Cnf.Set("Dir::Cache::pkgcache","pkgcache.bin");
// Configuration
Cnf.Set("Dir::Etc","/etc/apt/");
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index 66c1ac6a0..2c33400d7 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -11,8 +11,8 @@ include ../buildlib/defaults.mak
# The library name
LIBRARY=apt-pkg
-MAJOR=2
-MINOR=0.0
+MAJOR=2.0
+MINOR=0
SLIBS=$(PTHREADLIB)
# Source code for the contributed non-core things
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index 85d35d5a1..04d8c4c7e 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: orderlist.cc,v 1.2 1998/07/12 23:58:28 jgg Exp $
+// $Id: orderlist.cc,v 1.3 1998/09/26 05:34:21 jgg Exp $
/* ######################################################################
Order List - Represents and Manipulates an ordered list of packages.
@@ -402,6 +402,7 @@ bool pkgOrderList::VisitProvides(DepIterator D)
bool pkgOrderList::VisitNode(PkgIterator Pkg)
{
// Looping or irrelevent.
+ // This should probably trancend not installed packages
if (Pkg.end() == true || IsFlag(Pkg,Added) == true ||
IsFlag(Pkg,AddPending) == true || IsFlag(Pkg,InList) == false)
return true;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 46ae33c83..6b3bfa3c5 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.16 1998/09/18 02:42:38 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.17 1998/09/26 05:34:23 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -323,6 +323,7 @@ bool pkgCacheGenerator::SelectFile(string File,unsigned long Flags)
CurrentFile->mtime = Buf.st_mtime;
CurrentFile->NextFile = Cache.HeaderP->FileList;
CurrentFile->Flags = Flags;
+ CurrentFile->ID = Cache.HeaderP->PackageFileCount;
PkgFileName = File;
Cache.HeaderP->FileList = CurrentFile - Cache.PkgFileP;
Cache.HeaderP->PackageFileCount++;
@@ -382,10 +383,25 @@ bool pkgSrcCacheCheck(pkgSourceList &List)
{
if (_error->PendingError() == true)
return false;
-
- // Open the source package cache
+
string CacheFile = _config->FindDir("Dir::Cache::srcpkgcache");
string ListDir = _config->FindDir("Dir::State::lists");
+
+ // Count the number of missing files
+ int Missing = 0;
+ for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
+ {
+ string File = ListDir + URItoFileName(I->PackagesURI());
+ struct stat Buf;
+ if (stat(File.c_str(),&Buf) != 0)
+ {
+ _error->WarningE("stat","Couldn't stat source package list '%s' (%s)",
+ I->PackagesInfo().c_str(),File.c_str());
+ Missing++;
+ }
+ }
+
+ // Open the source package cache
if (FileExists(CacheFile) == false)
return false;
@@ -410,20 +426,6 @@ bool pkgSrcCacheCheck(pkgSourceList &List)
return false;
}
- // Count the number of missing files
- int Missing = 0;
- for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
- {
- string File = ListDir + URItoFileName(I->PackagesURI());
- struct stat Buf;
- if (stat(File.c_str(),&Buf) != 0)
- {
- _error->WarningE("stat","Couldn't stat source package list '%s' (%s)",
- I->PackagesInfo().c_str(),File.c_str());
- Missing++;
- }
- }
-
// They are certianly out of sync
if (Cache.Head().PackageFileCount != List.size() - Missing)
return false;