+
+// FIXME: move into more generic code (metaindex ?)
+std::string MetaIndexFileName(metaIndex *metaindex)
+{
+ // FIXME: this cast is the horror, the horror
+ debReleaseIndex *r = (debReleaseIndex*)metaindex;
+
+ // see if we have a InRelease file
+ std::string PathInRelease = _config->FindDir("Dir::State::lists") +
+ URItoFileName(r->MetaIndexURI("InRelease"));
+ if (FileExists(PathInRelease))
+ return PathInRelease;
+
+ // and if not return the normal one
+ return _config->FindDir("Dir::State::lists") +
+ URItoFileName(r->MetaIndexURI("Release"));
+}
+
+std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
+ pkgSrcRecords::Parser *Parse)
+{
+ // try to find release
+ const pkgIndexFile& SI = Parse->Index();
+ for (pkgSourceList::const_iterator S = SrcList->begin();
+ S != SrcList->end(); ++S)
+ {
+ vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
+ for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
+ IF != Indexes->end(); ++IF)
+ {
+ if (&SI == (*IF))
+ {
+ std::string path = MetaIndexFileName(*S);
+ indexRecords records;
+ records.Load(path);
+ return records.GetSuite();
+ }
+ }
+ }
+ return "";
+}
+
+