]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debsrcrecords.cc
Not /not/ immediately mapping a file is INSANE :/.
[apt.git] / apt-pkg / deb / debsrcrecords.cc
index cefaf46acc84c59479227d248cdec5da40a98f55..407b02d39da471e4b84acc936d7c42a5be3b8bcd 100644 (file)
@@ -38,10 +38,18 @@ debSrcRecordParser::debSrcRecordParser(std::string const &File,pkgIndexFile cons
    if (File.empty() == false)
    {
       if (Fd.Open(File, FileFd::ReadOnly, FileFd::Extension))
-        Tags.Init(&Fd, 102400);
+        Tags.Init(&Fd);
    }
 }
-
+std::string debSrcRecordParser::Package() const                                /*{{{*/
+{
+   auto const name = Sect.FindS("Package");
+   if (iIndex == nullptr)
+      return name.empty() ? Sect.FindS("Source") : name;
+   else
+      return name;
+}
+                                                                       /*}}}*/
 // SrcRecordParser::Binaries - Return the binaries field               /*{{{*/
 // ---------------------------------------------------------------------
 /* This member parses the binaries field into a pair of class arrays and
@@ -65,9 +73,12 @@ const char **debSrcRecordParser::Binaries()
    char* bin = Buffer;
    do {
       char* binStartNext = strchrnul(bin, ',');
-      char* binEnd = binStartNext - 1;
-      for (; isspace_ascii(*binEnd) != 0; --binEnd)
-        binEnd = 0;
+      // Found a comma, clean up any space before it
+      if (binStartNext > Buffer) {
+        char* binEnd = binStartNext - 1;
+        for (; binEnd > Buffer && isspace_ascii(*binEnd) != 0; --binEnd)
+           *binEnd = 0;
+      }
       StaticBinList.push_back(bin);
       if (*binStartNext != ',')
         break;
@@ -92,14 +103,16 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
    unsigned int I;
    const char *Start, *Stop;
    BuildDepRec rec;
-   const char *fields[] = {"Build-Depends", 
+   const char *fields[] = {"Build-Depends",
                            "Build-Depends-Indep",
                           "Build-Conflicts",
-                          "Build-Conflicts-Indep"};
+                          "Build-Conflicts-Indep",
+                          "Build-Depends-Arch",
+                          "Build-Conflicts-Arch"};
 
    BuildDeps.clear();
 
-   for (I = 0; I < 4; I++) 
+   for (I = 0; I < 6; I++)
    {
       if (ArchOnly && (I == 1 || I == 3))
          continue;
@@ -190,6 +203,15 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List)
               ParseQuoteWord(C, path) == false)
            return _error->Error("Error parsing file record in %s of source package %s", checksumField.c_str(), Package().c_str());
 
+        if (iIndex == nullptr && checksumField == "Files")
+        {
+           // the Files field has a different format than the rest in deb-changes files
+           std::string ignore;
+           if (ParseQuoteWord(C, ignore) == false ||
+                 ParseQuoteWord(C, path) == false)
+              return _error->Error("Error parsing file record in %s of source package %s", checksumField.c_str(), Package().c_str());
+        }
+
         HashString const hashString(*type, hash);
         if (Base.empty() == false)
            path = Base + path;
@@ -216,6 +238,7 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List)
         F.Path = path;
         F.FileSize = strtoull(size.c_str(), NULL, 10);
         F.Hashes.push_back(hashString);
+        F.Hashes.FileSize(F.FileSize);
 
         APT_IGNORE_DEPRECATED_PUSH
         F.Size = F.FileSize;