]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
Merge remote-tracking branch 'origin/feature/deb-src-bts731102' into feature/source...
[apt.git] / cmdline / apt-get.cc
index 5f04135d267b1511d34b89ce9d69e1766bd45e3d..7e59f3d6792c6a6dd7c2a34dcb65c6e8e759b7ff 100644 (file)
@@ -135,16 +135,13 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
 }
                                                                        /*}}}*/
 
-// FIXME: move into more generic code (metaindex ?)
+
+// helper that can go wit hthe next ABI break
 #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
-std::string MetaIndexFileName(metaIndex *metaindex)
+std::string MetaIndexFileNameOnDisk(metaIndex *metaindex)
 {
    // FIXME: this cast is the horror, the horror
    debReleaseIndex *r = (debReleaseIndex*)metaindex;
-#else
-std::string MetaIndexFileName(metaIndex *r)
-{
-#endif
 
    // see if we have a InRelease file
    std::string PathInRelease =  r->MetaIndexFile("InRelease");
@@ -152,14 +149,22 @@ std::string MetaIndexFileName(metaIndex *r)
       return PathInRelease;
 
    // and if not return the normal one
-   return r->MetaIndexFile("Release");
+   if (FileExists(PathInRelease))
+      return r->MetaIndexFile("Release");
+
+   return "";
 }
+#endif
 
+// GetReleaseForSourceRecord - Return Suite for the given srcrecord    /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
                                       pkgSrcRecords::Parser *Parse)
 {
    // try to find release
-   const pkgIndexFile& SI = Parse->Index();
+   const pkgIndexFile& CurrentIndexFile = Parse->Index();
+
    for (pkgSourceList::const_iterator S = SrcList->begin(); 
         S != SrcList->end(); ++S)
    {
@@ -167,19 +172,25 @@ std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
       for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
            IF != Indexes->end(); ++IF)
       {
-         if (&SI == (*IF))
+         if (&CurrentIndexFile == (*IF))
          {
-            std::string path = MetaIndexFileName(*S);
-            indexRecords records;
-            records.Load(path);
-            return records.GetSuite();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
+            std::string path = MetaIndexFileNameOnDisk(*S);
+#else
+            std::string path = (*S)->LocalFileName();
+#endif
+            if (path != "") 
+            {
+               indexRecords records;
+               records.Load(path);
+               return records.GetSuite();
+            }
          }
       }
    }
    return "";
 }
-
-
+                                                                       /*}}}*/
 // FindSrc - Find a source record                                      /*{{{*/
 // ---------------------------------------------------------------------
 /* */