]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/deblistparser.cc
Updated error messages to reflect host/ip
[apt.git] / apt-pkg / deb / deblistparser.cc
index 585006451f0df7ccaba2c4f9de97964d1a91675e..273b7fd42c0d64c02d018c96a9459db95955d123 100644 (file)
@@ -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.19 1999/05/23 22:55:54 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -13,7 +13,8 @@
 #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>
                                                                        /*}}}*/
@@ -44,7 +45,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 +66,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");
@@ -118,13 +120,51 @@ 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 */
+      char *I = S;
+      for (; Start != End; Start++)
+        if (isspace(*Start) == 0)
+           *I++ = *Start;
+      
+      Result = AddCRC16(Result,S,I - S);
+   }
+   
+   return Result;
+}
+                                                                       /*}}}*/
 // ListParser::ParseStatus - Parse the status field                    /*{{{*/
 // ---------------------------------------------------------------------
 /* Status lines are of the form,
@@ -313,7 +353,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
@@ -469,10 +513,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();
 }