X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0dbb95d810308d8dd102fba0303eed657f9f1cd2..231fea14113439c08eba185830c58d716e905f87:/apt-pkg/deb/deblistparser.cc diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 585006451..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.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. @@ -13,7 +13,8 @@ #include #include #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 /*{{{*/ @@ -44,7 +46,7 @@ string debListParser::Package() { 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; } /*}}}*/ @@ -65,6 +67,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) { // Parse the section Ver->Section = UniqFindTagWrite("Section"); + Ver->Arch = UniqFindTagWrite("Architecture"); // Archive Size Ver->Size = (unsigned)Section.FindI("Size"); @@ -85,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) @@ -118,20 +121,65 @@ bool debListParser::UsePackage(pkgCache::PkgIterator Pkg, 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 @@ -190,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}, @@ -313,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 @@ -422,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) @@ -469,10 +520,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI, 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(); }