]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
show more details for "Hash Sum mismatch" errors
[apt.git] / apt-pkg / deb / debindexfile.cc
index 708b40a964e52d65db0fcd5e46d6f84ad5dab6f5..9be2db4c95667a16035ae9bfcf26c0ff547ba1b9 100644 (file)
@@ -121,12 +121,18 @@ std::string debTranslationsIndex::GetArchitecture() const
 pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
                                                                        /*}}}*/
 // dpkg/status Index                                                   /*{{{*/
@@ -149,12 +155,18 @@ uint8_t debStatusIndex::GetIndexFlags() const
 pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debStatusListParser(&Pkg);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
                                                                        /*}}}*/
 // DebPkgFile Index - a single .deb file as an index                   /*{{{*/
@@ -225,12 +237,18 @@ bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
 pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
 uint8_t debDebPkgFileIndex::GetIndexFlags() const
 {
@@ -277,6 +295,57 @@ pkgSrcRecords::Parser *debDscFileIndex::CreateSrcParser() const
    if (Exists() == false)
       return NULL;
    return new debDscRecordParser(File, this);
+}
+std::string debDscFileIndex::GetComponent() const
+{
+   return "local-dsc";
+}
+std::string debDscFileIndex::GetArchitecture() const
+{
+   return "source";
+}
+uint8_t debDscFileIndex::GetIndexFlags() const
+{
+   return pkgCache::Flag::LocalSource;
+}
+                                                                       /*}}}*/
+// ControlFile Index - a directory with a debian/control file          /*{{{*/
+std::string debDebianSourceDirIndex::GetComponent() const
+{
+   return "local-control";
+}
+                                                                       /*}}}*/
+// String Package Index - a string of Packages file content            /*{{{*/
+std::string debStringPackageIndex::GetArchitecture() const
+{
+   return std::string();
+}
+std::string debStringPackageIndex::GetComponent() const
+{
+   return "apt-tmp-index";
+}
+uint8_t debStringPackageIndex::GetIndexFlags() const
+{
+   return pkgCache::Flag::NotSource;
+}
+const pkgIndexFile::Type *debStringPackageIndex::GetType() const
+{
+   return pkgIndexFile::Type::GetType("Debian Package Index");
+}
+debStringPackageIndex::debStringPackageIndex(std::string const &content) :
+   pkgDebianIndexRealFile("", false), d(NULL)
+{
+   char fn[1024];
+   std::string const tempdir = GetTempDir();
+   snprintf(fn, sizeof(fn), "%s/%s.XXXXXX", tempdir.c_str(), "apt-tmp-index");
+   int const fd = mkstemp(fn);
+   File = fn;
+   FileFd::Write(fd, content.data(), content.length());
+   close(fd);
+}
+debStringPackageIndex::~debStringPackageIndex()
+{
+   RemoveFile("~debStringPackageIndex", File);
 }
                                                                        /*}}}*/