X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/138d4b3d84035f2e0547d7de999d7c7ebb6b7adc..231fea14113439c08eba185830c58d716e905f87:/apt-pkg/deb/deblistparser.cc diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 157a465f4..9da03a7f6 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.17 1999/02/21 08:38:53 jgg Exp $ +// $Id: deblistparser.cc,v 1.23 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### Package Cache Generator - Generator for the cache structure. @@ -14,6 +14,7 @@ #include #include #include +#include #include /*}}}*/ @@ -23,6 +24,7 @@ /* */ debListParser::debListParser(FileFd &File) : Tags(File) { + Arch = _config->Find("APT::architecture"); } /*}}}*/ // ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/ @@ -86,7 +88,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) {"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) @@ -130,13 +132,54 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, 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 @@ -195,7 +238,6 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg, {"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}, @@ -318,7 +360,11 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, 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 @@ -427,11 +473,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)