4 #pragma implementation "apt-pkg/debmetaindex.h"
7 #include <apt-pkg/debmetaindex.h>
8 #include <apt-pkg/debindexfile.h>
9 #include <apt-pkg/strutl.h>
10 #include <apt-pkg/acquire-item.h>
11 #include <apt-pkg/configuration.h>
12 #include <apt-pkg/error.h>
16 string
debReleaseIndex::Info(const char *Type
, const string Section
) const
18 string Info
= ::URI::SiteOnly(URI
) + ' ';
19 if (Dist
[Dist
.size() - 1] == '/')
25 Info
+= Dist
+ '/' + Section
;
31 string
debReleaseIndex::MetaIndexInfo(const char *Type
) const
33 string Info
= ::URI::SiteOnly(URI
) + ' ';
34 if (Dist
[Dist
.size() - 1] == '/')
46 string
debReleaseIndex::MetaIndexFile(const char *Type
) const
48 return _config
->FindDir("Dir::State::lists") +
49 URItoFileName(MetaIndexURI(Type
));
52 string
debReleaseIndex::MetaIndexURI(const char *Type
) const
58 else if (Dist
[Dist
.size()-1] == '/')
61 Res
= URI
+ "dists/" + Dist
+ "/";
67 string
debReleaseIndex::IndexURISuffix(const char *Type
, const string Section
) const
70 if (Dist
[Dist
.size() - 1] != '/')
71 Res
+= Section
+ "/binary-" + _config
->Find("APT::Architecture") + '/';
76 string
debReleaseIndex::IndexURI(const char *Type
, const string Section
) const
78 if (Dist
[Dist
.size() - 1] == '/')
88 return URI
+ "dists/" + Dist
+ '/' + IndexURISuffix(Type
, Section
);
91 string
debReleaseIndex::SourceIndexURISuffix(const char *Type
, const string Section
) const
94 if (Dist
[Dist
.size() - 1] != '/')
95 Res
+= Section
+ "/source/";
99 string
debReleaseIndex::SourceIndexURI(const char *Type
, const string Section
) const
102 if (Dist
[Dist
.size() - 1] == '/')
111 return URI
+ "dists/" + Dist
+ "/" + SourceIndexURISuffix(Type
, Section
);
114 debReleaseIndex::debReleaseIndex(string URI
,string Dist
)
118 this->Indexes
= NULL
;
122 vector
<struct IndexTarget
*>* debReleaseIndex::ComputeIndexTargets() const
124 vector
<struct IndexTarget
*>* IndexTargets
= new vector
<IndexTarget
*>;
125 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
126 I
!= SectionEntries
.end();
129 IndexTarget
* Target
= new IndexTarget();
130 Target
->ShortDesc
= (*I
)->IsSrc
? "Sources" : "Packages";
132 = (*I
)->IsSrc
? SourceIndexURISuffix(Target
->ShortDesc
.c_str(), (*I
)->Section
)
133 : IndexURISuffix(Target
->ShortDesc
.c_str(), (*I
)->Section
);
135 = (*I
)->IsSrc
? SourceIndexURI(Target
->ShortDesc
.c_str(), (*I
)->Section
)
136 : IndexURI(Target
->ShortDesc
.c_str(), (*I
)->Section
);
138 Target
->Description
= Info (Target
->ShortDesc
.c_str(), (*I
)->Section
);
139 IndexTargets
->push_back (Target
);
144 bool debReleaseIndex::GetIndexes(pkgAcquire
*Owner
, bool GetAll
) const
146 // special case for --print-uris
148 vector
<struct IndexTarget
*> *targets
= ComputeIndexTargets();
149 for (vector
<struct IndexTarget
*>::const_iterator Target
= targets
->begin(); Target
!= targets
->end(); Target
++) {
150 new pkgAcqIndex(Owner
, (*Target
)->URI
, (*Target
)->Description
,
151 (*Target
)->ShortDesc
, "");
154 new pkgAcqMetaSig(Owner
, MetaIndexURI("Release.gpg"),
155 MetaIndexInfo("Release.gpg"), "Release.gpg",
156 MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
157 ComputeIndexTargets(),
158 new indexRecords (Dist
));
160 // Queue the translations
161 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
162 I
!= SectionEntries
.end(); I
++) {
166 debTranslationsIndex i
= debTranslationsIndex(URI
,Dist
,(*I
)->Section
);
173 bool debReleaseIndex::IsTrusted() const
175 string VerifiedSigFile
= _config
->FindDir("Dir::State::lists") +
176 URItoFileName(MetaIndexURI("Release")) + ".gpg";
178 if(_config
->FindB("APT::Authentication::TrustCDROM", false))
179 if(URI
.substr(0,strlen("cdrom:")) == "cdrom:")
182 if (FileExists(VerifiedSigFile
))
187 vector
<pkgIndexFile
*> *debReleaseIndex::GetIndexFiles()
192 Indexes
= new vector
<pkgIndexFile
*>;
193 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
194 I
!= SectionEntries
.end(); I
++) {
196 Indexes
->push_back(new debSourcesIndex (URI
, Dist
, (*I
)->Section
, IsTrusted()));
199 Indexes
->push_back(new debPackagesIndex (URI
, Dist
, (*I
)->Section
, IsTrusted()));
200 Indexes
->push_back(new debTranslationsIndex(URI
, Dist
, (*I
)->Section
));
207 void debReleaseIndex::PushSectionEntry(const debSectionEntry
*Entry
)
209 SectionEntries
.push_back(Entry
);
212 debReleaseIndex::debSectionEntry::debSectionEntry (string Section
, bool IsSrc
): Section(Section
)
217 class debSLTypeDebian
: public pkgSourceList::Type
221 bool CreateItemInternal(vector
<metaIndex
*> &List
,string URI
,
222 string Dist
,string Section
,
225 for (vector
<metaIndex
*>::const_iterator I
= List
.begin();
226 I
!= List
.end(); I
++)
228 // This check insures that there will be only one Release file
229 // queued for all the Packages files and Sources files it
231 if ((*I
)->GetType() == "deb")
233 debReleaseIndex
*Deb
= (debReleaseIndex
*) (*I
);
234 // This check insures that there will be only one Release file
235 // queued for all the Packages files and Sources files it
237 if (Deb
->GetURI() == URI
&& Deb
->GetDist() == Dist
)
239 Deb
->PushSectionEntry(new debReleaseIndex::debSectionEntry(Section
, IsSrc
));
244 // No currently created Release file indexes this entry, so we create a new one.
245 // XXX determine whether this release is trusted or not
246 debReleaseIndex
*Deb
= new debReleaseIndex(URI
,Dist
);
247 Deb
->PushSectionEntry (new debReleaseIndex::debSectionEntry(Section
, IsSrc
));
253 class debSLTypeDeb
: public debSLTypeDebian
257 bool CreateItem(vector
<metaIndex
*> &List
,string URI
,
258 string Dist
,string Section
) const
260 return CreateItemInternal(List
, URI
, Dist
, Section
, false);
266 Label
= "Standard Debian binary tree";
270 class debSLTypeDebSrc
: public debSLTypeDebian
274 bool CreateItem(vector
<metaIndex
*> &List
,string URI
,
275 string Dist
,string Section
) const
277 return CreateItemInternal(List
, URI
, Dist
, Section
, true);
283 Label
= "Standard Debian source tree";
287 debSLTypeDeb _apt_DebType
;
288 debSLTypeDebSrc _apt_DebSrcType
;