summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:52:13 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:52:13 +0000
commitb0b4efb96c3fad90bf978d61b230501bcdadff3d (patch)
tree63c6013b85da3fe3835f1ef37466c91279fa9c47 /apt-pkg
parent30456e14d97be16516a5a84ce9bf9acba143da87 (diff)
Release support
Author: jgg Date: 1998-12-14 02:23:46 GMT Release support
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheiterators.h9
-rw-r--r--apt-pkg/contrib/cmndline.cc10
-rw-r--r--apt-pkg/contrib/cmndline.h4
-rw-r--r--apt-pkg/deb/deblistparser.cc112
-rw-r--r--apt-pkg/deb/deblistparser.h7
-rw-r--r--apt-pkg/pkgcache.h12
-rw-r--r--apt-pkg/pkgcachegen.cc16
-rw-r--r--apt-pkg/pkgcachegen.h6
-rw-r--r--apt-pkg/tagfile.cc55
-rw-r--r--apt-pkg/tagfile.h6
10 files changed, 133 insertions, 104 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 0b5044178..c5b4b14c0 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cacheiterators.h,v 1.9 1998/11/27 00:07:23 jgg Exp $
+// $Id: cacheiterators.h,v 1.10 1998/12/14 02:23:46 jgg Exp $
/* ######################################################################
Cache Iterators - Iterators for navigating the cache structure
@@ -268,8 +268,13 @@ class pkgCache::PkgFileIterator
inline operator PackageFile const *() const {return File == Owner->PkgFileP?0:File;};
inline const char *FileName() const {return File->FileName == 0?0:Owner->StrP + File->FileName;};
+ inline const char *Archive() const {return File->Archive == 0?0:Owner->StrP + File->Archive;};
+ inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
- inline const char *Distribution() const {return File->Distribution == 0?0:Owner->StrP + File->Distribution;};
+ inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
+ inline const char *Label() const {return File->Origin == 0?0:Owner->StrP + File->Label;};
+ inline const char *Architecture() const {return File->Origin == 0?0:Owner->StrP + File->Architecture;};
+
inline unsigned long Index() const {return File - Owner->PkgFileP;};
bool IsOk();
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 858a5300a..629b8e9e5 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.6 1998/11/25 23:54:22 jgg Exp $
+// $Id: cmndline.cc,v 1.7 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -316,7 +316,7 @@ unsigned int CommandLine::FileSize() const
// CommandLine::DispatchArg - Do something with the first arg /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool CommandLine::DispatchArg(Dispatch *Map)
+bool CommandLine::DispatchArg(Dispatch *Map,bool NoMatch)
{
int I;
for (I = 0; Map[I].Match != 0; I++)
@@ -332,7 +332,11 @@ bool CommandLine::DispatchArg(Dispatch *Map)
// No matching name
if (Map[I].Match == 0)
- _error->Error("Invalid operation %s",FileList[0]);
+ {
+ if (NoMatch == true)
+ _error->Error("Invalid operation %s",FileList[0]);
+ }
+
return false;
}
/*}}}*/
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 2e1e05229..40d7f08ba 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.4 1998/11/25 23:54:31 jgg Exp $
+// $Id: cmndline.h,v 1.5 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -78,7 +78,7 @@ class CommandLine
bool Parse(int argc,const char **argv);
void ShowHelp();
unsigned int FileSize() const;
- bool DispatchArg(Dispatch *List);
+ bool DispatchArg(Dispatch *List,bool NoMatch = true);
CommandLine(Args *AList,Configuration *Conf);
~CommandLine();
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 8b778a726..0e5be1266 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.10 1998/08/09 00:51:35 jgg Exp $
+// $Id: deblistparser.cc,v 1.11 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -25,42 +25,6 @@ debListParser::debListParser(FileFd &File) : Tags(File)
{
}
/*}}}*/
-// ListParser::FindTag - Find the tag and return a string /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debListParser::FindTag(const char *Tag)
-{
- const char *Start;
- const char *Stop;
- if (Section.Find(Tag,Start,Stop) == false)
- return string();
- return string(Start,Stop - Start);
-}
- /*}}}*/
-// ListParser::FindTagI - Find the tag and return an int /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-signed long debListParser::FindTagI(const char *Tag,signed long Default)
-{
- const char *Start;
- const char *Stop;
- if (Section.Find(Tag,Start,Stop) == false)
- return Default;
-
- // Copy it into a temp buffer so we can use strtol
- char S[300];
- if ((unsigned)(Stop - Start) >= sizeof(S))
- return Default;
- strncpy(S,Start,Stop-Start);
- S[Stop - Start] = 0;
-
- char *End;
- signed long Result = strtol(S,&End,10);
- if (S == End)
- return Default;
- return Result;
-}
- /*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -73,45 +37,12 @@ unsigned long debListParser::UniqFindTagWrite(const char *Tag)
return WriteUniqString(Start,Stop - Start);
}
/*}}}*/
-// ListParser::HandleFlag - Sets a flag variable based on a tag /*{{{*/
-// ---------------------------------------------------------------------
-/* This checks the tag for true/false yes/no etc */
-bool debListParser::HandleFlag(const char *Tag,unsigned long &Flags,
- unsigned long Flag)
-{
- const char *Start;
- const char *Stop;
- if (Section.Find(Tag,Start,Stop) == false)
- return true;
-
- int Set = 2;
- if (stringcasecmp(Start,Stop,"yes") == 0)
- Set = 1;
- if (stringcasecmp(Start,Stop,"true") == 0)
- Set = 1;
- if (stringcasecmp(Start,Stop,"no") == 0)
- Set = 0;
- if (stringcasecmp(Start,Stop,"false") == 0)
- Set = 0;
- if (Set == 2)
- {
- _error->Warning("Unknown flag value");
- return true;
- }
-
- if (Set == 0)
- Flags &= ~Flag;
- if (Set == 1)
- Flags |= Flag;
- return true;
-}
- /*}}}*/
// ListParser::Package - Return the package name /*{{{*/
// ---------------------------------------------------------------------
/* This is to return the name of the package this section describes */
string debListParser::Package()
{
- string Result = FindTag("Package");
+ string Result = Section.FindS("Package");
if (Result.empty() == true)
_error->Error("Encoutered a section with no Package: header");
return Result;
@@ -124,7 +55,7 @@ string debListParser::Package()
entry is assumed to only describe package properties */
string debListParser::Version()
{
- return FindTag("Version");
+ return Section.FindS("Version");
}
/*}}}*/
// ListParser::NewVersion - Fill in the version structure /*{{{*/
@@ -136,10 +67,10 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
Ver->Section = UniqFindTagWrite("Section");
// Archive Size
- Ver->Size = (unsigned)FindTagI("Size");
+ Ver->Size = (unsigned)Section.FindI("Size");
// Unpacked Size (in K)
- Ver->InstalledSize = (unsigned)FindTagI("Installed-Size");
+ Ver->InstalledSize = (unsigned)Section.FindI("Installed-Size");
Ver->InstalledSize *= 1024;
// Priority
@@ -185,9 +116,9 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
{
if (Pkg->Section == 0)
Pkg->Section = UniqFindTagWrite("Section");
- if (HandleFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+ if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
return false;
- if (HandleFlag("Immediate-Configure",Pkg->Flags,pkgCache::Flag::ImmediateConf) == false)
+ if (Section.FindFlag("Immediate-Configure",Pkg->Flags,pkgCache::Flag::ImmediateConf) == false)
return false;
if (ParseStatus(Pkg,Ver) == false)
return false;
@@ -512,3 +443,32 @@ bool debListParser::Step()
return false;
}
/*}}}*/
+// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
+ FileFd &File)
+{
+ pkgTagFile Tags(File);
+ pkgTagSection Section;
+ if (Tags.Step(Section) == false)
+ return false;
+
+ const char *Start;
+ const char *Stop;
+ if (Section.Find("Archive",Start,Stop) == true)
+ FileI->Archive = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Component",Start,Stop) == true)
+ FileI->Component = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Version",Start,Stop) == true)
+ FileI->Version = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Origin",Start,Stop) == true)
+ FileI->Origin = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Label",Start,Stop) == true)
+ FileI->Label = WriteUniqString(Start,Stop - Start);
+ if (Section.Find("Architecture",Start,Stop) == true)
+ FileI->Architecture = WriteUniqString(Start,Stop - Start);
+
+ return !_error->PendingError();
+}
+ /*}}}*/
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 72e8ed073..6888c1a5e 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.5 1998/07/19 04:42:17 jgg Exp $
+// $Id: deblistparser.h,v 1.6 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Debian Package List Parser - This implements the abstract parser
@@ -28,10 +28,7 @@ class debListParser : public pkgCacheGenerator::ListParser
unsigned char Val;
};
- string FindTag(const char *Tag);
- signed long FindTagI(const char *Tag,signed long Default = 0);
unsigned long UniqFindTagWrite(const char *Tag);
- bool HandleFlag(const char *Tag,unsigned long &Flags,unsigned long Flag);
bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
const char *ParseDepends(const char *Start,const char *Stop,
string &Package,string &Ver,unsigned int &Op);
@@ -52,6 +49,8 @@ class debListParser : public pkgCacheGenerator::ListParser
virtual unsigned long Size() {return Section.size();};
virtual bool Step();
+
+ bool LoadReleaseInfo(pkgCache::PkgFileIterator FileI,FileFd &File);
debListParser(FileFd &File);
};
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 70d08826e..56ab50a37 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgcache.h,v 1.12 1998/12/08 01:34:13 jgg Exp $
+// $Id: pkgcache.h,v 1.13 1998/12/14 02:23:46 jgg Exp $
/* ######################################################################
Cache - Structure definitions for the cache file
@@ -198,9 +198,15 @@ struct pkgCache::PackageFile
{
// Names
__apt_ptrloc FileName; // Stringtable
+ __apt_ptrloc Archive; // Stringtable
+ __apt_ptrloc Component; // Stringtable
__apt_ptrloc Version; // Stringtable
- __apt_ptrloc Distribution; // Stringtable
- __apt_ptrloc Size;
+ __apt_ptrloc Origin; // Stringtable
+ __apt_ptrloc Label; // Stringtable
+ __apt_ptrloc Architecture; // Stringtable
+ unsigned long Size;
+ unsigned char NotAutomatic; // Bool
+
// Linked list
__apt_ptrloc NextFile; // PackageFile
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index ccb6bedd4..58561bf35 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.24 1998/12/07 07:26:21 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.25 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -635,8 +635,8 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
{
string File = ListDir + URItoFileName(I->PackagesURI());
-
- if (stat(File.c_str(),&Buf) != 0)
+
+ if (FileExists(File) == false)
continue;
FileFd Pkg(File,FileFd::ReadOnly);
@@ -652,6 +652,16 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
if (Gen.MergeList(Parser) == false)
return _error->Error("Problem with MergeList %s",File.c_str());
+
+ // Check the release file
+ string RFile = ListDir + URItoFileName(I->ReleaseURI());
+ if (FileExists(RFile) == true)
+ {
+ FileFd Rel(RFile,FileFd::ReadOnly);
+ if (_error->PendingError() == true)
+ return false;
+ Parser.LoadReleaseInfo(Gen.GetCurFile(),Rel);
+ }
}
// Write the src cache
diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h
index 093f979d7..4c22ecf6f 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.10 1998/08/09 00:51:34 jgg Exp $
+// $Id: pkgcachegen.h,v 1.11 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -57,7 +57,9 @@ class pkgCacheGenerator
bool SelectFile(string File,unsigned long Flags = 0);
bool MergeList(ListParser &List);
inline pkgCache &GetCache() {return Cache;};
-
+ inline pkgCache::PkgFileIterator GetCurFile()
+ {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
+
pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress);
~pkgCacheGenerator();
};
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 7f2bf6b1d..eb0840366 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.cc,v 1.18 1998/12/08 05:24:41 jgg Exp $
+// $Id: tagfile.cc,v 1.19 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
@@ -17,6 +17,7 @@
#include <apt-pkg/tagfile.h>
#include <apt-pkg/error.h>
+#include <strutl.h>
#include <string>
#include <stdio.h>
@@ -225,14 +226,54 @@ string pkgTagSection::FindS(const char *Tag)
// TagSection::FindI - Find an integer /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned int pkgTagSection::FindI(const char *Tag)
+signed int pkgTagSection::FindI(const char *Tag,signed long Default)
{
const char *Start;
- const char *End;
- if (Find(Tag,Start,End) == false)
- return 0;
+ const char *Stop;
+ if (Find(Tag,Start,Stop) == false)
+ return Default;
+
+ // Copy it into a temp buffer so we can use strtol
+ char S[300];
+ if ((unsigned)(Stop - Start) >= sizeof(S))
+ return Default;
+ strncpy(S,Start,Stop-Start);
+ S[Stop - Start] = 0;
+
+ char *End;
+ signed long Result = strtol(S,&End,10);
+ if (S == End)
+ return Default;
+ return Result;
+}
+ /*}}}*/
+// TagSection::FindFlag - Locate a yes/no type flag /*{{{*/
+// ---------------------------------------------------------------------
+/* The bits marked in Flag are masked on/off in Flags */
+bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
+ unsigned long Flag)
+{
+ const char *Start;
+ const char *Stop;
+ if (Find(Tag,Start,Stop) == false)
+ return true;
- return atoi(string(Start,End).c_str());
+ switch (StringToBool(string(Start,Stop)))
+ {
+ case 0:
+ Flags &= ~Flag;
+ return true;
+
+ case 1:
+ Flags |= Flag;
+ return true;
+
+ default:
+ _error->Warning("Unknown flag value");
+ return true;
+ }
+ return true;
}
/*}}}*/
-
+
+
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 83dd73d2a..82c856f8d 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tagfile.h,v 1.12 1998/12/07 07:26:23 jgg Exp $
+// $Id: tagfile.h,v 1.13 1998/12/14 02:23:47 jgg Exp $
/* ######################################################################
Fast scanner for RFC-822 type header information
@@ -45,7 +45,9 @@ class pkgTagSection
bool Find(const char *Tag,const char *&Start, const char *&End);
string FindS(const char *Tag);
- unsigned int FindI(const char *Tag);
+ signed int FindI(const char *Tag,signed long Default = 0);
+ bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
+ unsigned long Flag);
bool Scan(const char *Start,unsigned long MaxLength);
inline unsigned long size() {return Stop - Section;};