// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.cc,v 1.12 1998/12/14 06:54:43 jgg Exp $
+// $Id: deblistparser.cc,v 1.23 1999/09/30 06:30:34 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
#include <apt-pkg/deblistparser.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
-#include <strutl.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/crc-16.h>
#include <system.h>
/*}}}*/
/* */
debListParser::debListParser(FileFd &File) : Tags(File)
{
+ Arch = _config->Find("APT::architecture");
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
{
string Result = Section.FindS("Package");
if (Result.empty() == true)
- _error->Error("Encoutered a section with no Package: header");
+ _error->Error("Encountered a section with no Package: header");
return Result;
}
/*}}}*/
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
+ Ver->Arch = UniqFindTagWrite("Architecture");
// Archive Size
Ver->Size = (unsigned)Section.FindI("Size");
{"extra",pkgCache::State::Extra}};
if (GrabWord(string(Start,Stop-Start),PrioList,
_count(PrioList),Ver->Priority) == false)
- return _error->Error("Malformed Priority line");
+ Ver->Priority = pkgCache::State::Extra;
}
if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
Pkg->Section = UniqFindTagWrite("Section");
if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
return false;
- if (Section.FindFlag("Immediate-Configure",Pkg->Flags,pkgCache::Flag::ImmediateConf) == false)
+ if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false)
return false;
+
+ if (strcmp(Pkg.Name(),"apt") == 0)
+ Pkg->Flags |= pkgCache::Flag::Important;
+
if (ParseStatus(Pkg,Ver) == false)
return false;
return true;
}
/*}}}*/
+// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+unsigned short debListParser::VersionHash()
+{
+ const char *Sections[] ={"Installed-Size",
+ "Depends",
+ "Pre-Depends",
+// "Suggests",
+// "Recommends",
+ "Conflicts",
+ "Replaces",0};
+ unsigned long Result = INIT_FCS;
+ char S[300];
+ for (const char **I = Sections; *I != 0; I++)
+ {
+ const char *Start;
+ const char *End;
+ if (Section.Find(*I,Start,End) == false || End - Start >= (signed)sizeof(S))
+ continue;
+
+ /* Strip out any spaces from the text, this undoes dpkgs reformatting
+ of certain fields. dpkg also has the rather interesting notion of
+ reformatting depends operators < -> <= */
+ char *I = S;
+ for (; Start != End; Start++)
+ {
+ if (isspace(*Start) == 0)
+ *I++ = tolower(*Start);
+ if (*Start == '<' && Start[1] != '<' && Start[1] != '=')
+ *I++ = '=';
+ if (*Start == '>' && Start[1] != '>' && Start[1] != '=')
+ *I++ = '=';
+ }
+
+ Result = AddCRC16(Result,S,I - S);
+ }
+
+ return Result;
+}
+ /*}}}*/
// ListParser::ParseStatus - Parse the status field /*{{{*/
// ---------------------------------------------------------------------
/* Status lines are of the form,
Status: want flag status
want = unknown, install, hold, deinstall, purge
flag = ok, reinstreq, hold, hold-reinstreq
- status = not-installed, unpacked, half-configured, uninstalled,
+ status = not-installed, unpacked, half-configured,
half-installed, config-files, post-inst-failed,
removal-failed, installed
{"unpacked",pkgCache::State::UnPacked},
{"half-configured",pkgCache::State::HalfConfigured},
{"installed",pkgCache::State::Installed},
- {"uninstalled",pkgCache::State::UnInstalled},
{"half-installed",pkgCache::State::HalfInstalled},
{"config-files",pkgCache::State::ConfigFiles},
{"post-inst-failed",pkgCache::State::HalfConfigured},
if (I == Stop || Start == I)
return 0;
- Ver = string(Start,I-Start);
+ // Skip trailing whitespace
+ const char *End = I;
+ for (; End > Start && isspace(End[-1]); End--);
+
+ Ver = string(Start,End-Start);
I++;
}
else
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)
if (Section.Find("Architecture",Start,Stop) == true)
FileI->Architecture = WriteUniqString(Start,Stop - Start);
- unsigned long Fl = 0;
- if (Section.FindFlag("NotAutomatic",Fl,1) == false)
+ if (Section.FindFlag("NotAutomatic",FileI->Flags,
+ pkgCache::Flag::NotAutomatic) == false)
_error->Warning("Bad NotAutomatic flag");
- FileI->NotAutomatic = Fl;
return !_error->PendingError();
}