3 #include <apt-pkg/debmetaindex.h>
4 #include <apt-pkg/debindexfile.h>
5 #include <apt-pkg/strutl.h>
6 #include <apt-pkg/acquire-item.h>
7 #include <apt-pkg/configuration.h>
8 #include <apt-pkg/error.h>
12 string
debReleaseIndex::Info(const char *Type
, const string Section
) const
14 string Info
= ::URI::SiteOnly(URI
) + ' ';
15 if (Dist
[Dist
.size() - 1] == '/')
21 Info
+= Dist
+ '/' + Section
;
27 string
debReleaseIndex::MetaIndexInfo(const char *Type
) const
29 string Info
= ::URI::SiteOnly(URI
) + ' ';
30 if (Dist
[Dist
.size() - 1] == '/')
42 string
debReleaseIndex::MetaIndexFile(const char *Type
) const
44 return _config
->FindDir("Dir::State::lists") +
45 URItoFileName(MetaIndexURI(Type
));
48 string
debReleaseIndex::MetaIndexURI(const char *Type
) const
54 else if (Dist
[Dist
.size()-1] == '/')
57 Res
= URI
+ "dists/" + Dist
+ "/";
63 string
debReleaseIndex::IndexURISuffix(const char *Type
, const string Section
) const
66 if (Dist
[Dist
.size() - 1] != '/')
67 Res
+= Section
+ "/binary-" + _config
->Find("APT::Architecture") + '/';
72 string
debReleaseIndex::IndexURI(const char *Type
, const string Section
) const
74 if (Dist
[Dist
.size() - 1] == '/')
84 return URI
+ "dists/" + Dist
+ '/' + IndexURISuffix(Type
, Section
);
87 string
debReleaseIndex::SourceIndexURISuffix(const char *Type
, const string Section
) const
90 if (Dist
[Dist
.size() - 1] != '/')
91 Res
+= Section
+ "/source/";
95 string
debReleaseIndex::SourceIndexURI(const char *Type
, const string Section
) const
98 if (Dist
[Dist
.size() - 1] == '/')
107 return URI
+ "dists/" + Dist
+ "/" + SourceIndexURISuffix(Type
, Section
);
110 debReleaseIndex::debReleaseIndex(string URI
,string Dist
)
114 this->Indexes
= NULL
;
118 vector
<struct IndexTarget
*>* debReleaseIndex::ComputeIndexTargets() const
120 vector
<struct IndexTarget
*>* IndexTargets
= new vector
<IndexTarget
*>;
121 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
122 I
!= SectionEntries
.end();
125 IndexTarget
* Target
= new IndexTarget();
126 Target
->ShortDesc
= (*I
)->IsSrc
? "Sources" : "Packages";
128 = (*I
)->IsSrc
? SourceIndexURISuffix(Target
->ShortDesc
.c_str(), (*I
)->Section
)
129 : IndexURISuffix(Target
->ShortDesc
.c_str(), (*I
)->Section
);
131 = (*I
)->IsSrc
? SourceIndexURI(Target
->ShortDesc
.c_str(), (*I
)->Section
)
132 : IndexURI(Target
->ShortDesc
.c_str(), (*I
)->Section
);
134 Target
->Description
= Info (Target
->ShortDesc
.c_str(), (*I
)->Section
);
135 IndexTargets
->push_back (Target
);
140 bool debReleaseIndex::GetIndexes(pkgAcquire
*Owner
, bool GetAll
) const
142 // special case for --print-uris
144 vector
<struct IndexTarget
*> *targets
= ComputeIndexTargets();
145 for (vector
<struct IndexTarget
*>::const_iterator Target
= targets
->begin(); Target
!= targets
->end(); Target
++) {
146 new pkgAcqIndex(Owner
, (*Target
)->URI
, (*Target
)->Description
,
147 (*Target
)->ShortDesc
, "");
150 new pkgAcqMetaSig(Owner
, MetaIndexURI("Release.gpg"),
151 MetaIndexInfo("Release.gpg"), "Release.gpg",
152 MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
153 ComputeIndexTargets(),
154 new indexRecords (Dist
));
156 // Queue the translations
157 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
158 I
!= SectionEntries
.end(); I
++) {
162 debTranslationsIndex i
= debTranslationsIndex(URI
,Dist
,(*I
)->Section
);
169 bool debReleaseIndex::IsTrusted() const
171 string VerifiedSigFile
= _config
->FindDir("Dir::State::lists") +
172 URItoFileName(MetaIndexURI("Release")) + ".gpg";
174 if(_config
->FindB("APT::Authentication::TrustCDROM", false))
175 if(URI
.substr(0,strlen("cdrom:")) == "cdrom:")
178 if (FileExists(VerifiedSigFile
))
183 vector
<pkgIndexFile
*> *debReleaseIndex::GetIndexFiles()
188 Indexes
= new vector
<pkgIndexFile
*>;
189 for (vector
<const debSectionEntry
*>::const_iterator I
= SectionEntries
.begin();
190 I
!= SectionEntries
.end(); I
++) {
192 Indexes
->push_back(new debSourcesIndex (URI
, Dist
, (*I
)->Section
, IsTrusted()));
195 Indexes
->push_back(new debPackagesIndex (URI
, Dist
, (*I
)->Section
, IsTrusted()));
196 Indexes
->push_back(new debTranslationsIndex(URI
, Dist
, (*I
)->Section
));
203 void debReleaseIndex::PushSectionEntry(const debSectionEntry
*Entry
)
205 SectionEntries
.push_back(Entry
);
208 debReleaseIndex::debSectionEntry::debSectionEntry (string Section
, bool IsSrc
): Section(Section
)
213 class debSLTypeDebian
: public pkgSourceList::Type
217 bool CreateItemInternal(vector
<metaIndex
*> &List
,string URI
,
218 string Dist
,string Section
,
221 for (vector
<metaIndex
*>::const_iterator I
= List
.begin();
222 I
!= List
.end(); I
++)
224 // This check insures that there will be only one Release file
225 // queued for all the Packages files and Sources files it
227 if ((*I
)->GetType() == "deb")
229 debReleaseIndex
*Deb
= (debReleaseIndex
*) (*I
);
230 // This check insures that there will be only one Release file
231 // queued for all the Packages files and Sources files it
233 if (Deb
->GetURI() == URI
&& Deb
->GetDist() == Dist
)
235 Deb
->PushSectionEntry(new debReleaseIndex::debSectionEntry(Section
, IsSrc
));
240 // No currently created Release file indexes this entry, so we create a new one.
241 // XXX determine whether this release is trusted or not
242 debReleaseIndex
*Deb
= new debReleaseIndex(URI
,Dist
);
243 Deb
->PushSectionEntry (new debReleaseIndex::debSectionEntry(Section
, IsSrc
));
249 class debSLTypeDeb
: public debSLTypeDebian
253 bool CreateItem(vector
<metaIndex
*> &List
,string URI
,
254 string Dist
,string Section
) const
256 return CreateItemInternal(List
, URI
, Dist
, Section
, false);
262 Label
= "Standard Debian binary tree";
266 class debSLTypeDebSrc
: public debSLTypeDebian
270 bool CreateItem(vector
<metaIndex
*> &List
,string URI
,
271 string Dist
,string Section
) const
273 return CreateItemInternal(List
, URI
, Dist
, Section
, true);
279 Label
= "Standard Debian source tree";
283 debSLTypeDeb _apt_DebType
;
284 debSLTypeDebSrc _apt_DebSrcType
;