]>
Commit | Line | Data |
---|---|---|
0118833a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
7db98ffc | 3 | // $Id: acquire-item.h,v 1.26.2.3 2004/01/02 18:51:00 mdz Exp $ |
0118833a AL |
4 | /* ###################################################################### |
5 | ||
6 | Acquire Item - Item to acquire | |
7 | ||
8 | When an item is instantiated it will add it self to the local list in | |
9 | the Owner Acquire class. Derived classes will then call QueueURI to | |
17caf1b1 | 10 | register all the URI's they wish to fetch at the initial moment. |
0118833a | 11 | |
770c32ec | 12 | Three item classes are provided to provide functionality for |
a52f938b | 13 | downloading of Index, Translation and Packages files. |
0118833a | 14 | |
495e5cb2 | 15 | A Archive class is provided for downloading .deb files. It does Hash |
17caf1b1 | 16 | checking and source location as well as a retry algorithm. |
b185acc2 | 17 | |
0118833a AL |
18 | ##################################################################### */ |
19 | /*}}}*/ | |
20 | #ifndef PKGLIB_ACQUIRE_ITEM_H | |
21 | #define PKGLIB_ACQUIRE_ITEM_H | |
22 | ||
23 | #include <apt-pkg/acquire.h> | |
495e5cb2 | 24 | #include <apt-pkg/hashes.h> |
229fb1a3 | 25 | #include <apt-pkg/weakptr.h> |
472ff00e | 26 | #include <apt-pkg/pkgcache.h> |
453b82a3 DK |
27 | #include <apt-pkg/cacheiterators.h> |
28 | ||
29 | #include <string> | |
30 | #include <vector> | |
0118833a | 31 | |
b9dadc24 DK |
32 | #ifndef APT_8_CLEANER_HEADERS |
33 | #include <apt-pkg/indexfile.h> | |
34 | #include <apt-pkg/vendor.h> | |
35 | #include <apt-pkg/sourcelist.h> | |
36 | #include <apt-pkg/pkgrecords.h> | |
37 | #include <apt-pkg/indexrecords.h> | |
38 | #endif | |
39 | ||
3174e150 MV |
40 | /** \addtogroup acquire |
41 | * @{ | |
42 | * | |
43 | * \file acquire-item.h | |
44 | */ | |
45 | ||
472ff00e DK |
46 | class indexRecords; |
47 | class pkgRecords; | |
48 | class pkgSourceList; | |
fa3b260f | 49 | class IndexTarget; |
472ff00e | 50 | |
92fcbfc1 | 51 | /** \brief Represents the process by which a pkgAcquire object should {{{ |
3174e150 MV |
52 | * retrieve a file or a collection of files. |
53 | * | |
54 | * By convention, Item subclasses should insert themselves into the | |
55 | * acquire queue when they are created by calling QueueURI(), and | |
56 | * remove themselves by calling Dequeue() when either Done() or | |
57 | * Failed() is invoked. Item objects are also responsible for | |
58 | * notifying the download progress indicator (accessible via | |
59 | * #Owner->Log) of their status. | |
60 | * | |
61 | * \see pkgAcquire | |
62 | */ | |
229fb1a3 | 63 | class pkgAcquire::Item : public WeakPointable |
0118833a AL |
64 | { |
65 | protected: | |
66 | ||
3174e150 | 67 | /** \brief The acquire object with which this item is associated. */ |
0118833a | 68 | pkgAcquire *Owner; |
3174e150 MV |
69 | |
70 | /** \brief Insert this item into its owner's queue. | |
71 | * | |
255c9e4b | 72 | * \param Item Metadata about this item (its URI and |
3174e150 MV |
73 | * description). |
74 | */ | |
8267fe24 AL |
75 | inline void QueueURI(ItemDesc &Item) |
76 | {Owner->Enqueue(Item);}; | |
3174e150 MV |
77 | |
78 | /** \brief Remove this item from its owner's queue. */ | |
681d76d0 | 79 | inline void Dequeue() {Owner->Dequeue(this);}; |
0118833a | 80 | |
3174e150 MV |
81 | /** \brief Rename a file without modifying its timestamp. |
82 | * | |
83 | * Many item methods call this as their final action. | |
84 | * | |
85 | * \param From The file to be renamed. | |
86 | * | |
255c9e4b | 87 | * \param To The new name of \a From. If \a To exists it will be |
3174e150 MV |
88 | * overwritten. |
89 | */ | |
472ff00e | 90 | void Rename(std::string From,std::string To); |
3c8030a4 | 91 | |
0118833a AL |
92 | public: |
93 | ||
3174e150 MV |
94 | /** \brief The current status of this item. */ |
95 | enum ItemState | |
96 | { | |
97 | /** \brief The item is waiting to be downloaded. */ | |
98 | StatIdle, | |
99 | ||
100 | /** \brief The item is currently being downloaded. */ | |
101 | StatFetching, | |
102 | ||
103 | /** \brief The item has been successfully downloaded. */ | |
104 | StatDone, | |
105 | ||
106 | /** \brief An error was encountered while downloading this | |
107 | * item. | |
108 | */ | |
109 | StatError, | |
110 | ||
111 | /** \brief The item was downloaded but its authenticity could | |
112 | * not be verified. | |
113 | */ | |
6ca714d5 MV |
114 | StatAuthError, |
115 | ||
116 | /** \brief The item was could not be downloaded because of | |
117 | * a transient network error (e.g. network down) | |
118 | */ | |
119 | StatTransientNetworkError | |
3174e150 MV |
120 | } Status; |
121 | ||
122 | /** \brief Contains a textual description of the error encountered | |
255c9e4b | 123 | * if #ItemState is #StatError or #StatAuthError. |
3174e150 | 124 | */ |
472ff00e | 125 | std::string ErrorText; |
3174e150 MV |
126 | |
127 | /** \brief The size of the object to fetch. */ | |
e2c66de5 | 128 | unsigned long long FileSize; |
3174e150 MV |
129 | |
130 | /** \brief How much of the object was already fetched. */ | |
e2c66de5 | 131 | unsigned long long PartialSize; |
3174e150 MV |
132 | |
133 | /** \brief If not \b NULL, contains the name of a subprocess that | |
134 | * is operating on this object (for instance, "gzip" or "gpgv"). | |
135 | */ | |
ffbe056d DK |
136 | APT_DEPRECATED const char *Mode; |
137 | ||
138 | /** \brief contains the name of the subprocess that is operating on this object | |
139 | * (for instance, "gzip", "rred" or "gpgv"). This is obsoleting #Mode from above | |
140 | * as it can manage the lifetime of included string properly. */ | |
141 | std::string ActiveSubprocess; | |
3174e150 MV |
142 | |
143 | /** \brief A client-supplied unique identifier. | |
144 | * | |
145 | * This field is initalized to 0; it is meant to be filled in by | |
146 | * clients that wish to use it to uniquely identify items. | |
147 | * | |
148 | * \todo it's unused in apt itself | |
149 | */ | |
b98f2859 | 150 | unsigned long ID; |
3174e150 MV |
151 | |
152 | /** \brief If \b true, the entire object has been successfully fetched. | |
153 | * | |
154 | * Subclasses should set this to \b true when appropriate. | |
155 | */ | |
8267fe24 | 156 | bool Complete; |
3174e150 MV |
157 | |
158 | /** \brief If \b true, the URI of this object is "local". | |
159 | * | |
160 | * The only effect of this field is to exclude the object from the | |
161 | * download progress indicator's overall statistics. | |
162 | */ | |
a6568219 | 163 | bool Local; |
472ff00e | 164 | std::string UsedMirror; |
30e1eab5 | 165 | |
3174e150 MV |
166 | /** \brief The number of fetch queues into which this item has been |
167 | * inserted. | |
168 | * | |
169 | * There is one queue for each source from which an item could be | |
170 | * downloaded. | |
171 | * | |
172 | * \sa pkgAcquire | |
173 | */ | |
0118833a | 174 | unsigned int QueueCounter; |
d0cfa8ad MV |
175 | |
176 | /** \brief The number of additional fetch items that are expected | |
177 | * once this item is done. | |
178 | * | |
179 | * Some items like pkgAcqMeta{Index,Sig} will queue additional | |
180 | * items. This variable can be set by the methods if it knows | |
181 | * in advance how many items to expect to get a more accurate | |
182 | * progress. | |
183 | */ | |
184 | unsigned int ExpectedAdditionalItems; | |
0118833a | 185 | |
3174e150 MV |
186 | /** \brief The name of the file into which the retrieved object |
187 | * will be written. | |
188 | */ | |
472ff00e | 189 | std::string DestFile; |
7d8afa39 | 190 | |
3174e150 MV |
191 | /** \brief Invoked by the acquire worker when the object couldn't |
192 | * be fetched. | |
193 | * | |
194 | * This is a branch of the continuation of the fetch process. | |
195 | * | |
196 | * \param Message An RFC822-formatted message from the acquire | |
197 | * method describing what went wrong. Use LookupTag() to parse | |
198 | * it. | |
199 | * | |
200 | * \param Cnf The method via which the worker tried to fetch this object. | |
201 | * | |
202 | * \sa pkgAcqMethod | |
203 | */ | |
472ff00e | 204 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
3174e150 MV |
205 | |
206 | /** \brief Invoked by the acquire worker when the object was | |
207 | * fetched successfully. | |
208 | * | |
209 | * Note that the object might \e not have been written to | |
210 | * DestFile; check for the presence of an Alt-Filename entry in | |
211 | * Message to find the file to which it was really written. | |
212 | * | |
213 | * Done is often used to switch from one stage of the processing | |
214 | * to the next (e.g. fetching, unpacking, copying). It is one | |
215 | * branch of the continuation of the fetch process. | |
216 | * | |
217 | * \param Message Data from the acquire method. Use LookupTag() | |
218 | * to parse it. | |
219 | * \param Size The size of the object that was fetched. | |
b3501edb | 220 | * \param Hashes The HashSums of the object that was fetched. |
3174e150 MV |
221 | * \param Cnf The method via which the object was fetched. |
222 | * | |
223 | * \sa pkgAcqMethod | |
224 | */ | |
b3501edb | 225 | virtual void Done(std::string Message, unsigned long long Size, HashStringList const &Hashes, |
459681d3 | 226 | pkgAcquire::MethodConfig *Cnf); |
3174e150 MV |
227 | |
228 | /** \brief Invoked when the worker starts to fetch this object. | |
229 | * | |
230 | * \param Message RFC822-formatted data from the worker process. | |
231 | * Use LookupTag() to parse it. | |
232 | * | |
233 | * \param Size The size of the object being fetched. | |
234 | * | |
235 | * \sa pkgAcqMethod | |
236 | */ | |
472ff00e | 237 | virtual void Start(std::string Message,unsigned long long Size); |
3174e150 MV |
238 | |
239 | /** \brief Custom headers to be sent to the fetch process. | |
240 | * | |
241 | * \return a string containing RFC822-style headers that are to be | |
242 | * inserted into the 600 URI Acquire message sent to the fetch | |
243 | * subprocess. The headers are inserted after a newline-less | |
244 | * line, so they should (if nonempty) have a leading newline and | |
245 | * no trailing newline. | |
246 | */ | |
b3501edb | 247 | virtual std::string Custom600Headers() const {return std::string();}; |
3174e150 MV |
248 | |
249 | /** \brief A "descriptive" URI-like string. | |
250 | * | |
251 | * \return a URI that should be used to describe what is being fetched. | |
252 | */ | |
ca15786a | 253 | virtual std::string DescURI() = 0; |
3174e150 MV |
254 | /** \brief Short item description. |
255 | * | |
256 | * \return a brief description of the object being fetched. | |
257 | */ | |
ca15786a | 258 | virtual std::string ShortDesc() {return DescURI();} |
3174e150 MV |
259 | |
260 | /** \brief Invoked by the worker when the download is completely done. */ | |
ab559b35 | 261 | virtual void Finished() {}; |
17caf1b1 | 262 | |
b3501edb | 263 | /** \brief HashSums |
3174e150 | 264 | * |
b3501edb DK |
265 | * \return the HashSums of this object, if applicable; otherwise, an |
266 | * empty list. | |
3174e150 | 267 | */ |
fa3b260f | 268 | HashStringList HashSums() const {return ExpectedHashes;}; |
b3501edb | 269 | std::string HashSum() const {HashStringList const hashes = HashSums(); HashString const * const hs = hashes.find(NULL); return hs != NULL ? hs->toStr() : ""; }; |
3174e150 MV |
270 | |
271 | /** \return the acquire process with which this item is associated. */ | |
b3501edb | 272 | pkgAcquire *GetOwner() const {return Owner;}; |
3174e150 MV |
273 | |
274 | /** \return \b true if this object is being fetched from a trusted source. */ | |
b3501edb | 275 | virtual bool IsTrusted() const {return false;}; |
c5ccf175 | 276 | |
36280399 | 277 | // report mirror problems |
702c84fb MV |
278 | /** \brief Report mirror problem |
279 | * | |
280 | * This allows reporting mirror failures back to a centralized | |
281 | * server. The apt-report-mirror-failure script is called for this | |
282 | * | |
283 | * \param FailCode A short failure string that is send | |
284 | */ | |
472ff00e | 285 | void ReportMirrorFailure(std::string FailCode); |
36280399 | 286 | |
3174e150 MV |
287 | |
288 | /** \brief Initialize an item. | |
289 | * | |
290 | * Adds the item to the list of items known to the acquire | |
291 | * process, but does not place it into any fetch queues (you must | |
292 | * manually invoke QueueURI() to do so). | |
293 | * | |
3174e150 | 294 | * \param Owner The new owner of this item. |
fa3b260f | 295 | * \param ExpectedHashes of the file represented by this item |
3174e150 | 296 | */ |
880964da MV |
297 | Item(pkgAcquire *Owner, |
298 | HashStringList const &ExpectedHashes=HashStringList()); | |
3174e150 MV |
299 | |
300 | /** \brief Remove this item from its owner's queue by invoking | |
301 | * pkgAcquire::Remove. | |
302 | */ | |
0118833a | 303 | virtual ~Item(); |
3c8030a4 DK |
304 | |
305 | protected: | |
306 | ||
307 | enum RenameOnErrorState { | |
308 | HashSumMismatch, | |
309 | SizeMismatch, | |
310 | InvalidFormat | |
311 | }; | |
312 | ||
313 | /** \brief Rename failed file and set error | |
314 | * | |
315 | * \param state respresenting the error we encountered | |
3c8030a4 DK |
316 | */ |
317 | bool RenameOnError(RenameOnErrorState const state); | |
fa3b260f DK |
318 | |
319 | /** \brief The HashSums of the item is supposed to have than done */ | |
320 | HashStringList ExpectedHashes; | |
321 | ||
322 | /** \brief The item that is currently being downloaded. */ | |
323 | pkgAcquire::ItemDesc Desc; | |
0118833a | 324 | }; |
92fcbfc1 DK |
325 | /*}}}*/ |
326 | /** \brief Information about an index patch (aka diff). */ /*{{{*/ | |
002d9943 | 327 | struct DiffInfo { |
3174e150 | 328 | /** The filename of the diff. */ |
472ff00e | 329 | std::string file; |
3174e150 | 330 | |
f6d4ab9a DK |
331 | /** The hashes of the diff */ |
332 | HashStringList result_hashes; | |
3174e150 | 333 | |
f6d4ab9a DK |
334 | /** The hashes of the file after the diff is applied */ |
335 | HashStringList patch_hashes; | |
336 | ||
337 | /** The size of the file after the diff is applied */ | |
338 | unsigned long long result_size; | |
339 | ||
340 | /** The size of the diff itself */ | |
341 | unsigned long long patch_size; | |
002d9943 | 342 | }; |
92fcbfc1 | 343 | /*}}}*/ |
ab53c018 DK |
344 | /** \brief An item that is responsible for fetching a SubIndex {{{ |
345 | * | |
346 | * The MetaIndex file includes only records for important indexes | |
347 | * and records for these SubIndex files so these can carry records | |
348 | * for addition files like PDiffs and Translations | |
349 | */ | |
350 | class pkgAcqSubIndex : public pkgAcquire::Item | |
351 | { | |
352 | protected: | |
353 | /** \brief If \b true, debugging information will be written to std::clog. */ | |
354 | bool Debug; | |
355 | ||
ab53c018 DK |
356 | public: |
357 | // Specialized action members | |
472ff00e | 358 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 359 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
ab53c018 | 360 | pkgAcquire::MethodConfig *Cnf); |
ca15786a | 361 | virtual std::string DescURI() {return Desc.URI;}; |
b3501edb | 362 | virtual std::string Custom600Headers() const; |
472ff00e | 363 | virtual bool ParseIndex(std::string const &IndexFile); |
ab53c018 | 364 | |
4c6cf493 | 365 | /** \brief Create a new pkgAcqSubIndex. |
ab53c018 DK |
366 | * |
367 | * \param Owner The Acquire object that owns this item. | |
368 | * | |
369 | * \param URI The URI of the list file to download. | |
370 | * | |
371 | * \param URIDesc A long description of the list file to download. | |
372 | * | |
373 | * \param ShortDesc A short description of the list file to download. | |
374 | * | |
b3501edb | 375 | * \param ExpectedHashes The list file's hashsums which are expected. |
ab53c018 | 376 | */ |
472ff00e | 377 | pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc, |
b3501edb | 378 | std::string const &ShortDesc, HashStringList const &ExpectedHashes); |
ab53c018 DK |
379 | }; |
380 | /*}}}*/ | |
c2184314 | 381 | |
0b58b3f8 MV |
382 | /** \brief Common base class for all classes that deal with fetching {{{ |
383 | indexes | |
384 | */ | |
c2184314 MV |
385 | class pkgAcqBaseIndex : public pkgAcquire::Item |
386 | { | |
387 | protected: | |
388 | /** \brief Pointer to the IndexTarget data | |
389 | */ | |
390 | const struct IndexTarget * Target; | |
391 | indexRecords *MetaIndexParser; | |
392 | ||
0b58b3f8 MV |
393 | pkgAcqBaseIndex(pkgAcquire *Owner, |
394 | struct IndexTarget const * const Target, | |
e110d7bf | 395 | HashStringList const &ExpectedHashes, |
0b58b3f8 | 396 | indexRecords *MetaIndexParser) |
e110d7bf MV |
397 | : Item(Owner, ExpectedHashes), Target(Target), |
398 | MetaIndexParser(MetaIndexParser) {}; | |
399 | ||
c2184314 | 400 | }; |
0b58b3f8 | 401 | /*}}}*/ |
92fcbfc1 | 402 | /** \brief An item that is responsible for fetching an index file of {{{ |
3174e150 MV |
403 | * package list diffs and starting the package list's download. |
404 | * | |
405 | * This item downloads the Index file and parses it, then enqueues | |
406 | * additional downloads of either the individual patches (using | |
407 | * pkgAcqIndexDiffs) or the entire Packages file (using pkgAcqIndex). | |
408 | * | |
409 | * \sa pkgAcqIndexDiffs, pkgAcqIndex | |
410 | */ | |
0b58b3f8 | 411 | class pkgAcqDiffIndex : public pkgAcqBaseIndex |
2237bd01 MV |
412 | { |
413 | protected: | |
3174e150 | 414 | /** \brief If \b true, debugging information will be written to std::clog. */ |
2237bd01 | 415 | bool Debug; |
3174e150 | 416 | |
3174e150 MV |
417 | /** \brief The URI of the index file to recreate at our end (either |
418 | * by downloading it or by applying partial patches). | |
419 | */ | |
472ff00e | 420 | std::string RealURI; |
3174e150 | 421 | |
3174e150 MV |
422 | /** \brief The index file which will be patched to generate the new |
423 | * file. | |
424 | */ | |
472ff00e | 425 | std::string CurrentPackagesFile; |
3174e150 MV |
426 | |
427 | /** \brief A description of the Packages file (stored in | |
428 | * pkgAcquire::ItemDesc::Description). | |
429 | */ | |
472ff00e | 430 | std::string Description; |
2237bd01 MV |
431 | |
432 | public: | |
433 | // Specialized action members | |
472ff00e | 434 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 435 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
2237bd01 | 436 | pkgAcquire::MethodConfig *Cnf); |
ca15786a | 437 | virtual std::string DescURI() {return RealURI + "Index";}; |
b3501edb | 438 | virtual std::string Custom600Headers() const; |
2237bd01 | 439 | |
3174e150 MV |
440 | /** \brief Parse the Index file for a set of Packages diffs. |
441 | * | |
442 | * Parses the Index file and creates additional download items as | |
443 | * necessary. | |
444 | * | |
445 | * \param IndexDiffFile The name of the Index file. | |
446 | * | |
447 | * \return \b true if the Index file was successfully parsed, \b | |
448 | * false otherwise. | |
449 | */ | |
472ff00e | 450 | bool ParseDiffIndex(std::string IndexDiffFile); |
2237bd01 | 451 | |
3174e150 MV |
452 | |
453 | /** \brief Create a new pkgAcqDiffIndex. | |
454 | * | |
455 | * \param Owner The Acquire object that owns this item. | |
456 | * | |
457 | * \param URI The URI of the list file to download. | |
458 | * | |
459 | * \param URIDesc A long description of the list file to download. | |
460 | * | |
461 | * \param ShortDesc A short description of the list file to download. | |
462 | * | |
b3501edb | 463 | * \param ExpectedHashes The list file's hashsums which are expected. |
3174e150 | 464 | */ |
e39698a4 MV |
465 | pkgAcqDiffIndex(pkgAcquire *Owner, |
466 | struct IndexTarget const * const Target, | |
b3501edb | 467 | HashStringList const &ExpectedHashes, |
e39698a4 | 468 | indexRecords *MetaIndexParser); |
002d9943 | 469 | }; |
92fcbfc1 | 470 | /*}}}*/ |
47d2bc78 DK |
471 | /** \brief An item that is responsible for fetching client-merge patches {{{ |
472 | * that need to be applied to a given package index file. | |
473 | * | |
474 | * Instead of downloading and applying each patch one by one like its | |
475 | * sister #pkgAcqIndexDiffs this class will download all patches at once | |
476 | * and call rred with all the patches downloaded once. Rred will then | |
477 | * merge and apply them in one go, which should be a lot faster – but is | |
478 | * incompatible with server-based merges of patches like reprepro can do. | |
479 | * | |
480 | * \sa pkgAcqDiffIndex, pkgAcqIndex | |
481 | */ | |
0b58b3f8 | 482 | class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex |
47d2bc78 DK |
483 | { |
484 | protected: | |
485 | ||
486 | /** \brief If \b true, debugging output will be written to | |
487 | * std::clog. | |
488 | */ | |
489 | bool Debug; | |
490 | ||
47d2bc78 DK |
491 | /** \brief URI of the package index file that is being |
492 | * reconstructed. | |
493 | */ | |
494 | std::string RealURI; | |
495 | ||
47d2bc78 DK |
496 | /** \brief description of the file being downloaded. */ |
497 | std::string Description; | |
498 | ||
499 | /** \brief information about the current patch */ | |
500 | struct DiffInfo const patch; | |
501 | ||
502 | /** \brief list of all download items for the patches */ | |
503 | std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches; | |
504 | ||
505 | /** The current status of this patch. */ | |
506 | enum DiffState | |
507 | { | |
508 | /** \brief The diff is currently being fetched. */ | |
509 | StateFetchDiff, | |
510 | ||
511 | /** \brief The diff is currently being applied. */ | |
512 | StateApplyDiff, | |
513 | ||
514 | /** \brief the work with this diff is done */ | |
515 | StateDoneDiff, | |
516 | ||
517 | /** \brief something bad happened and fallback was triggered */ | |
518 | StateErrorDiff | |
519 | } State; | |
520 | ||
521 | public: | |
522 | /** \brief Called when the patch file failed to be downloaded. | |
523 | * | |
524 | * This method will fall back to downloading the whole index file | |
525 | * outright; its arguments are ignored. | |
526 | */ | |
527 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); | |
b3501edb DK |
528 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
529 | pkgAcquire::MethodConfig *Cnf); | |
ca15786a | 530 | virtual std::string DescURI() {return RealURI + "Index";}; |
47d2bc78 DK |
531 | |
532 | /** \brief Create an index merge-diff item. | |
533 | * | |
534 | * \param Owner The pkgAcquire object that owns this item. | |
535 | * | |
536 | * \param URI The URI of the package index file being | |
537 | * reconstructed. | |
538 | * | |
539 | * \param URIDesc A long description of this item. | |
540 | * | |
541 | * \param ShortDesc A brief description of this item. | |
542 | * | |
b3501edb | 543 | * \param ExpectedHashes The expected md5sum of the completely |
47d2bc78 DK |
544 | * reconstructed package index file; the index file will be tested |
545 | * against this value when it is entirely reconstructed. | |
546 | * | |
547 | * \param patch contains infos about the patch this item is supposed | |
548 | * to download which were read from the index | |
549 | * | |
550 | * \param allPatches contains all related items so that each item can | |
551 | * check if it was the last one to complete the download step | |
552 | */ | |
c2184314 MV |
553 | pkgAcqIndexMergeDiffs(pkgAcquire *Owner, |
554 | struct IndexTarget const * const Target, | |
e110d7bf | 555 | HashStringList const &ExpectedHash, |
c2184314 MV |
556 | indexRecords *MetaIndexParser, |
557 | DiffInfo const &patch, | |
558 | std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches); | |
47d2bc78 DK |
559 | }; |
560 | /*}}}*/ | |
561 | /** \brief An item that is responsible for fetching server-merge patches {{{ | |
3174e150 MV |
562 | * that need to be applied to a given package index file. |
563 | * | |
564 | * After downloading and applying a single patch, this item will | |
565 | * enqueue a new pkgAcqIndexDiffs to download and apply the remaining | |
566 | * patches. If no patch can be found that applies to an intermediate | |
567 | * file or if one of the patches cannot be downloaded, falls back to | |
568 | * downloading the entire package index file using pkgAcqIndex. | |
569 | * | |
570 | * \sa pkgAcqDiffIndex, pkgAcqIndex | |
571 | */ | |
0b58b3f8 | 572 | class pkgAcqIndexDiffs : public pkgAcqBaseIndex |
ac5b205a | 573 | { |
3174e150 MV |
574 | private: |
575 | ||
576 | /** \brief Queue up the next diff download. | |
577 | * | |
578 | * Search for the next available diff that applies to the file | |
579 | * that currently exists on disk, and enqueue it by calling | |
580 | * QueueURI(). | |
581 | * | |
582 | * \return \b true if an applicable diff was found, \b false | |
583 | * otherwise. | |
584 | */ | |
3809194b | 585 | APT_HIDDEN bool QueueNextDiff(); |
3174e150 MV |
586 | |
587 | /** \brief Handle tasks that must be performed after the item | |
588 | * finishes downloading. | |
589 | * | |
b3501edb DK |
590 | * Dequeues the item and checks the resulting file's hashsums |
591 | * against ExpectedHashes after the last patch was applied. | |
3174e150 MV |
592 | * There is no need to check the md5/sha1 after a "normal" |
593 | * patch because QueueNextDiff() will check the sha1 later. | |
594 | * | |
595 | * \param allDone If \b true, the file was entirely reconstructed, | |
596 | * and its md5sum is verified. | |
597 | */ | |
3809194b | 598 | APT_HIDDEN void Finish(bool allDone=false); |
3174e150 | 599 | |
ac5b205a | 600 | protected: |
3174e150 MV |
601 | |
602 | /** \brief If \b true, debugging output will be written to | |
603 | * std::clog. | |
604 | */ | |
ac5b205a | 605 | bool Debug; |
3174e150 | 606 | |
3174e150 MV |
607 | /** \brief The URI of the package index file that is being |
608 | * reconstructed. | |
609 | */ | |
472ff00e | 610 | std::string RealURI; |
3174e150 | 611 | |
3174e150 | 612 | /** A description of the file being downloaded. */ |
472ff00e | 613 | std::string Description; |
3174e150 MV |
614 | |
615 | /** The patches that remain to be downloaded, including the patch | |
616 | * being downloaded right now. This list should be ordered so | |
617 | * that each diff appears before any diff that depends on it. | |
618 | * | |
619 | * \todo These are indexed by sha1sum; why not use some sort of | |
620 | * dictionary instead of relying on ordering and stripping them | |
621 | * off the front? | |
622 | */ | |
472ff00e | 623 | std::vector<DiffInfo> available_patches; |
8a3207f4 | 624 | |
3174e150 MV |
625 | /** The current status of this patch. */ |
626 | enum DiffState | |
627 | { | |
628 | /** \brief The diff is in an unknown state. */ | |
629 | StateFetchUnkown, | |
630 | ||
631 | /** \brief The diff is currently being fetched. */ | |
632 | StateFetchDiff, | |
633 | ||
634 | /** \brief The diff is currently being uncompressed. */ | |
caffd480 | 635 | StateUnzipDiff, // FIXME: No longer used |
3174e150 MV |
636 | |
637 | /** \brief The diff is currently being applied. */ | |
638 | StateApplyDiff | |
639 | } State; | |
6cb30d01 | 640 | |
ac5b205a MV |
641 | public: |
642 | ||
3174e150 MV |
643 | /** \brief Called when the patch file failed to be downloaded. |
644 | * | |
645 | * This method will fall back to downloading the whole index file | |
646 | * outright; its arguments are ignored. | |
647 | */ | |
472ff00e | 648 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
3174e150 | 649 | |
b3501edb | 650 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
ac5b205a | 651 | pkgAcquire::MethodConfig *Cnf); |
ca15786a | 652 | virtual std::string DescURI() {return RealURI + "Index";}; |
ac5b205a | 653 | |
3174e150 MV |
654 | /** \brief Create an index diff item. |
655 | * | |
656 | * After filling in its basic fields, this invokes Finish(true) if | |
255c9e4b | 657 | * \a diffs is empty, or QueueNextDiff() otherwise. |
3174e150 MV |
658 | * |
659 | * \param Owner The pkgAcquire object that owns this item. | |
660 | * | |
661 | * \param URI The URI of the package index file being | |
662 | * reconstructed. | |
663 | * | |
664 | * \param URIDesc A long description of this item. | |
665 | * | |
666 | * \param ShortDesc A brief description of this item. | |
667 | * | |
f6d4ab9a | 668 | * \param ExpectedHashes The expected hashsums of the completely |
3174e150 MV |
669 | * reconstructed package index file; the index file will be tested |
670 | * against this value when it is entirely reconstructed. | |
671 | * | |
672 | * \param diffs The remaining diffs from the index of diffs. They | |
673 | * should be ordered so that each diff appears before any diff | |
674 | * that depends on it. | |
675 | */ | |
c2184314 MV |
676 | pkgAcqIndexDiffs(pkgAcquire *Owner, |
677 | struct IndexTarget const * const Target, | |
e110d7bf | 678 | HashStringList const &ExpectedHash, |
c2184314 | 679 | indexRecords *MetaIndexParser, |
472ff00e | 680 | std::vector<DiffInfo> diffs=std::vector<DiffInfo>()); |
ac5b205a | 681 | }; |
92fcbfc1 DK |
682 | /*}}}*/ |
683 | /** \brief An acquire item that is responsible for fetching an index {{{ | |
3174e150 MV |
684 | * file (e.g., Packages or Sources). |
685 | * | |
686 | * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans | |
687 | * | |
688 | * \todo Why does pkgAcqIndex have protected members? | |
689 | */ | |
0b58b3f8 | 690 | class pkgAcqIndex : public pkgAcqBaseIndex |
0118833a AL |
691 | { |
692 | protected: | |
3174e150 MV |
693 | |
694 | /** \brief If \b true, the index file has been decompressed. */ | |
8b89e57f | 695 | bool Decompression; |
3174e150 MV |
696 | |
697 | /** \brief If \b true, the partially downloaded file will be | |
698 | * removed when the download completes. | |
699 | */ | |
bfd22fc0 | 700 | bool Erase; |
3174e150 | 701 | |
19818b65 MV |
702 | // Unused, used to be used to verify that "Packages: " header was there |
703 | bool __DELME_ON_NEXT_ABI_BREAK_Verify; | |
c5f661b7 | 704 | |
3174e150 MV |
705 | /** \brief The object that is actually being fetched (minus any |
706 | * compression-related extensions). | |
707 | */ | |
472ff00e | 708 | std::string RealURI; |
3174e150 | 709 | |
5d885723 DK |
710 | /** \brief The compression-related file extensions that are being |
711 | * added to the downloaded file one by one if first fails (e.g., "gz bz2"). | |
3174e150 | 712 | */ |
472ff00e | 713 | std::string CompressionExtension; |
13e8426f | 714 | |
c511c5e8 | 715 | |
59194959 MV |
716 | /** \brief Do the changes needed to fetch via AptByHash (if needed) */ |
717 | void InitByHashIfNeeded(const std::string MetaKey); | |
718 | ||
ca7fd76c MV |
719 | /** \brief Get the full pathname of the final file for the given URI |
720 | */ | |
721 | std::string GetFinalFilename(std::string const &URI, | |
722 | std::string const &compExt); | |
723 | ||
724 | /** \brief Schedule file for verification after a IMS hit */ | |
725 | void ReverifyAfterIMS(std::string const &FileName); | |
726 | ||
0118833a AL |
727 | public: |
728 | ||
17caf1b1 | 729 | // Specialized action members |
472ff00e | 730 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 731 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
459681d3 | 732 | pkgAcquire::MethodConfig *Cnf); |
b3501edb | 733 | virtual std::string Custom600Headers() const; |
ca15786a | 734 | virtual std::string DescURI() {return Desc.URI;}; |
0118833a | 735 | |
3174e150 MV |
736 | /** \brief Create a pkgAcqIndex. |
737 | * | |
738 | * \param Owner The pkgAcquire object with which this item is | |
739 | * associated. | |
740 | * | |
741 | * \param URI The URI of the index file that is to be downloaded. | |
742 | * | |
743 | * \param URIDesc A "URI-style" description of this index file. | |
744 | * | |
745 | * \param ShortDesc A brief description of this index file. | |
746 | * | |
b3501edb | 747 | * \param ExpectedHashes The expected hashsum of this index file. |
3174e150 MV |
748 | * |
749 | * \param compressExt The compression-related extension with which | |
750 | * this index file should be downloaded, or "" to autodetect | |
e85b4cd5 DK |
751 | * Compression types can be set with config Acquire::CompressionTypes, |
752 | * default is ".lzma" or ".bz2" (if the needed binaries are present) | |
753 | * fallback is ".gz" or none. | |
3174e150 | 754 | */ |
472ff00e | 755 | pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, |
b3501edb | 756 | std::string ShortDesc, HashStringList const &ExpectedHashes, |
472ff00e | 757 | std::string compressExt=""); |
c2184314 | 758 | pkgAcqIndex(pkgAcquire *Owner, |
80624be7 | 759 | IndexTarget const * const Target, |
e110d7bf | 760 | HashStringList const &ExpectedHash, |
c2184314 | 761 | indexRecords *MetaIndexParser); |
0b58b3f8 MV |
762 | void Init(std::string const &URI, std::string const &URIDesc, |
763 | std::string const &ShortDesc); | |
0118833a | 764 | }; |
92fcbfc1 DK |
765 | /*}}}*/ |
766 | /** \brief An acquire item that is responsible for fetching a {{{ | |
3174e150 MV |
767 | * translated index file. |
768 | * | |
769 | * The only difference from pkgAcqIndex is that transient failures | |
770 | * are suppressed: no error occurs if the translated index file is | |
771 | * missing. | |
772 | */ | |
a52f938b OS |
773 | class pkgAcqIndexTrans : public pkgAcqIndex |
774 | { | |
775 | public: | |
776 | ||
472ff00e | 777 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 778 | virtual std::string Custom600Headers() const; |
3174e150 MV |
779 | |
780 | /** \brief Create a pkgAcqIndexTrans. | |
781 | * | |
782 | * \param Owner The pkgAcquire object with which this item is | |
783 | * associated. | |
784 | * | |
785 | * \param URI The URI of the index file that is to be downloaded. | |
786 | * | |
787 | * \param URIDesc A "URI-style" description of this index file. | |
788 | * | |
789 | * \param ShortDesc A brief description of this index file. | |
3174e150 | 790 | */ |
472ff00e DK |
791 | pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc, |
792 | std::string ShortDesc); | |
fa3b260f | 793 | pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const * const Target, |
b3501edb | 794 | HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); |
a52f938b | 795 | }; |
92fcbfc1 DK |
796 | /*}}}*/ |
797 | /** \brief Information about an index file. */ /*{{{*/ | |
14b4780d | 798 | class IndexTarget |
7db98ffc | 799 | { |
14b4780d | 800 | public: |
3174e150 | 801 | /** \brief A URI from which the index file can be downloaded. */ |
472ff00e | 802 | std::string URI; |
3174e150 MV |
803 | |
804 | /** \brief A description of the index file. */ | |
472ff00e | 805 | std::string Description; |
3174e150 MV |
806 | |
807 | /** \brief A shorter description of the index file. */ | |
472ff00e | 808 | std::string ShortDesc; |
3174e150 MV |
809 | |
810 | /** \brief The key by which this index file should be | |
811 | * looked up within the meta signature file. | |
812 | */ | |
472ff00e | 813 | std::string MetaKey; |
ab53c018 | 814 | |
14b4780d MV |
815 | virtual bool IsOptional() const { |
816 | return false; | |
817 | } | |
818 | virtual bool IsSubIndex() const { | |
819 | return false; | |
820 | } | |
7db98ffc | 821 | }; |
92fcbfc1 | 822 | /*}}}*/ |
ab53c018 | 823 | /** \brief Information about an optional index file. */ /*{{{*/ |
14b4780d MV |
824 | class OptionalIndexTarget : public IndexTarget |
825 | { | |
826 | virtual bool IsOptional() const { | |
827 | return true; | |
828 | } | |
829 | }; | |
830 | /*}}}*/ | |
831 | /** \brief Information about an subindex index file. */ /*{{{*/ | |
832 | class SubIndexTarget : public IndexTarget | |
b36597e0 MV |
833 | { |
834 | virtual bool IsSubIndex() const { | |
835 | return true; | |
836 | } | |
837 | }; | |
838 | /*}}}*/ | |
839 | /** \brief Information about an subindex index file. */ /*{{{*/ | |
840 | class OptionalSubIndexTarget : public OptionalIndexTarget | |
ab53c018 | 841 | { |
14b4780d MV |
842 | virtual bool IsSubIndex() const { |
843 | return true; | |
844 | } | |
7db98ffc | 845 | }; |
92fcbfc1 | 846 | /*}}}*/ |
ab53c018 | 847 | |
92fcbfc1 | 848 | /** \brief An acquire item that downloads the detached signature {{{ |
3174e150 MV |
849 | * of a meta-index (Release) file, then queues up the release |
850 | * file itself. | |
851 | * | |
852 | * \todo Why protected members? | |
853 | * | |
854 | * \sa pkgAcqMetaIndex | |
855 | */ | |
7db98ffc | 856 | class pkgAcqMetaSig : public pkgAcquire::Item |
0118833a AL |
857 | { |
858 | protected: | |
ef942597 | 859 | /** \brief The last good signature file */ |
472ff00e | 860 | std::string LastGoodSig; |
ef942597 | 861 | |
3174e150 MV |
862 | /** \brief The URI of the signature file. Unlike Desc.URI, this is |
863 | * never modified; it is used to determine the file that is being | |
864 | * downloaded. | |
865 | */ | |
472ff00e | 866 | std::string RealURI; |
3174e150 MV |
867 | |
868 | /** \brief The URI of the meta-index file to be fetched after the signature. */ | |
472ff00e | 869 | std::string MetaIndexURI; |
3174e150 MV |
870 | |
871 | /** \brief A "URI-style" description of the meta-index file to be | |
872 | * fetched after the signature. | |
873 | */ | |
472ff00e | 874 | std::string MetaIndexURIDesc; |
3174e150 MV |
875 | |
876 | /** \brief A brief description of the meta-index file to be fetched | |
877 | * after the signature. | |
878 | */ | |
472ff00e | 879 | std::string MetaIndexShortDesc; |
3174e150 MV |
880 | |
881 | /** \brief A package-system-specific parser for the meta-index file. */ | |
7db98ffc | 882 | indexRecords* MetaIndexParser; |
3174e150 MV |
883 | |
884 | /** \brief The index files which should be looked up in the meta-index | |
885 | * and then downloaded. | |
886 | * | |
887 | * \todo Why a list of pointers instead of a list of structs? | |
888 | */ | |
fa3b260f | 889 | const std::vector<IndexTarget*>* IndexTargets; |
7db98ffc | 890 | |
0118833a AL |
891 | public: |
892 | ||
17caf1b1 | 893 | // Specialized action members |
472ff00e | 894 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 895 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
7db98ffc | 896 | pkgAcquire::MethodConfig *Cnf); |
b3501edb | 897 | virtual std::string Custom600Headers() const; |
ca15786a | 898 | virtual std::string DescURI() {return RealURI; }; |
7db98ffc | 899 | |
3174e150 | 900 | /** \brief Create a new pkgAcqMetaSig. */ |
472ff00e DK |
901 | pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, |
902 | std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc, | |
fa3b260f | 903 | const std::vector<IndexTarget*>* IndexTargets, |
7db98ffc | 904 | indexRecords* MetaIndexParser); |
ffcccd62 | 905 | virtual ~pkgAcqMetaSig(); |
7db98ffc | 906 | }; |
92fcbfc1 DK |
907 | /*}}}*/ |
908 | /** \brief An item that is responsible for downloading the meta-index {{{ | |
3174e150 MV |
909 | * file (i.e., Release) itself and verifying its signature. |
910 | * | |
911 | * Once the download and verification are complete, the downloads of | |
912 | * the individual index files are queued up using pkgAcqDiffIndex. | |
495e5cb2 | 913 | * If the meta-index file had a valid signature, the expected hashsums |
3174e150 | 914 | * of the index files will be the md5sums listed in the meta-index; |
495e5cb2 | 915 | * otherwise, the expected hashsums will be "" (causing the |
3174e150 MV |
916 | * authentication of the index files to be bypassed). |
917 | */ | |
7db98ffc MZ |
918 | class pkgAcqMetaIndex : public pkgAcquire::Item |
919 | { | |
920 | protected: | |
3174e150 MV |
921 | /** \brief The URI that is actually being downloaded; never |
922 | * modified by pkgAcqMetaIndex. | |
923 | */ | |
472ff00e | 924 | std::string RealURI; |
3174e150 MV |
925 | |
926 | /** \brief The file in which the signature for this index was stored. | |
927 | * | |
928 | * If empty, the signature and the md5sums of the individual | |
929 | * indices will not be checked. | |
930 | */ | |
472ff00e | 931 | std::string SigFile; |
3174e150 MV |
932 | |
933 | /** \brief The index files to download. */ | |
fa3b260f | 934 | const std::vector<IndexTarget*>* IndexTargets; |
3174e150 MV |
935 | |
936 | /** \brief The parser for the meta-index file. */ | |
7db98ffc | 937 | indexRecords* MetaIndexParser; |
3174e150 MV |
938 | |
939 | /** \brief If \b true, the index's signature is currently being verified. | |
940 | */ | |
7db98ffc | 941 | bool AuthPass; |
ce424cd4 MV |
942 | // required to deal gracefully with problems caused by incorrect ims hits |
943 | bool IMSHit; | |
7db98ffc | 944 | |
3174e150 MV |
945 | /** \brief Check that the release file is a release file for the |
946 | * correct distribution. | |
947 | * | |
948 | * \return \b true if no fatal errors were encountered. | |
949 | */ | |
472ff00e | 950 | bool VerifyVendor(std::string Message); |
3174e150 MV |
951 | |
952 | /** \brief Called when a file is finished being retrieved. | |
953 | * | |
954 | * If the file was not downloaded to DestFile, a copy process is | |
955 | * set up to copy it to DestFile; otherwise, Complete is set to \b | |
956 | * true and the file is moved to its final location. | |
957 | * | |
958 | * \param Message The message block received from the fetch | |
959 | * subprocess. | |
960 | */ | |
472ff00e | 961 | void RetrievalDone(std::string Message); |
3174e150 MV |
962 | |
963 | /** \brief Called when authentication succeeded. | |
964 | * | |
965 | * Sanity-checks the authenticated file, queues up the individual | |
966 | * index files for download, and saves the signature in the lists | |
967 | * directory next to the authenticated list file. | |
968 | * | |
969 | * \param Message The message block received from the fetch | |
970 | * subprocess. | |
971 | */ | |
472ff00e | 972 | void AuthDone(std::string Message); |
3174e150 MV |
973 | |
974 | /** \brief Starts downloading the individual index files. | |
975 | * | |
495e5cb2 | 976 | * \param verify If \b true, only indices whose expected hashsum |
3174e150 | 977 | * can be determined from the meta-index will be downloaded, and |
495e5cb2 | 978 | * the hashsums of indices will be checked (reporting |
3174e150 | 979 | * #StatAuthError if there is a mismatch). If verify is \b false, |
495e5cb2 | 980 | * no hashsum checking will be performed. |
3174e150 | 981 | */ |
7db98ffc MZ |
982 | void QueueIndexes(bool verify); |
983 | ||
984 | public: | |
0a8a80e5 | 985 | |
7db98ffc | 986 | // Specialized action members |
472ff00e | 987 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 988 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
7db98ffc | 989 | pkgAcquire::MethodConfig *Cnf); |
b3501edb | 990 | virtual std::string Custom600Headers() const; |
ca15786a | 991 | virtual std::string DescURI() {return RealURI; }; |
7db98ffc | 992 | |
3174e150 | 993 | /** \brief Create a new pkgAcqMetaIndex. */ |
7db98ffc | 994 | pkgAcqMetaIndex(pkgAcquire *Owner, |
472ff00e DK |
995 | std::string URI,std::string URIDesc, std::string ShortDesc, |
996 | std::string SigFile, | |
fa3b260f | 997 | const std::vector<IndexTarget*>* IndexTargets, |
7db98ffc | 998 | indexRecords* MetaIndexParser); |
0118833a | 999 | }; |
92fcbfc1 | 1000 | /*}}}*/ |
fe0f7911 DK |
1001 | /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/ |
1002 | class pkgAcqMetaClearSig : public pkgAcqMetaIndex | |
1003 | { | |
1004 | /** \brief The URI of the meta-index file for the detached signature */ | |
472ff00e | 1005 | std::string MetaIndexURI; |
fe0f7911 DK |
1006 | |
1007 | /** \brief A "URI-style" description of the meta-index file */ | |
472ff00e | 1008 | std::string MetaIndexURIDesc; |
fe0f7911 DK |
1009 | |
1010 | /** \brief A brief description of the meta-index file */ | |
472ff00e | 1011 | std::string MetaIndexShortDesc; |
fe0f7911 DK |
1012 | |
1013 | /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */ | |
472ff00e | 1014 | std::string MetaSigURI; |
fe0f7911 DK |
1015 | |
1016 | /** \brief A "URI-style" description of the meta-signature file */ | |
472ff00e | 1017 | std::string MetaSigURIDesc; |
fe0f7911 DK |
1018 | |
1019 | /** \brief A brief description of the meta-signature file */ | |
472ff00e | 1020 | std::string MetaSigShortDesc; |
fe0f7911 DK |
1021 | |
1022 | public: | |
472ff00e | 1023 | void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 1024 | virtual std::string Custom600Headers() const; |
fe0f7911 DK |
1025 | |
1026 | /** \brief Create a new pkgAcqMetaClearSig. */ | |
1027 | pkgAcqMetaClearSig(pkgAcquire *Owner, | |
472ff00e DK |
1028 | std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc, |
1029 | std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc, | |
1030 | std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc, | |
fa3b260f | 1031 | const std::vector<IndexTarget*>* IndexTargets, |
fe0f7911 | 1032 | indexRecords* MetaIndexParser); |
ffcccd62 | 1033 | virtual ~pkgAcqMetaClearSig(); |
fe0f7911 DK |
1034 | }; |
1035 | /*}}}*/ | |
92fcbfc1 | 1036 | /** \brief An item that is responsible for fetching a package file. {{{ |
3174e150 MV |
1037 | * |
1038 | * If the package file already exists in the cache, nothing will be | |
1039 | * done. | |
1040 | */ | |
03e39e59 AL |
1041 | class pkgAcqArchive : public pkgAcquire::Item |
1042 | { | |
1043 | protected: | |
3174e150 | 1044 | /** \brief The package version being fetched. */ |
03e39e59 | 1045 | pkgCache::VerIterator Version; |
3174e150 | 1046 | |
3174e150 MV |
1047 | /** \brief The list of sources from which to pick archives to |
1048 | * download this package from. | |
1049 | */ | |
03e39e59 | 1050 | pkgSourceList *Sources; |
3174e150 MV |
1051 | |
1052 | /** \brief A package records object, used to look up the file | |
1053 | * corresponding to each version of the package. | |
1054 | */ | |
03e39e59 | 1055 | pkgRecords *Recs; |
3174e150 | 1056 | |
3174e150 MV |
1057 | /** \brief A location in which the actual filename of the package |
1058 | * should be stored. | |
1059 | */ | |
472ff00e | 1060 | std::string &StoreFilename; |
3174e150 MV |
1061 | |
1062 | /** \brief The next file for this version to try to download. */ | |
b185acc2 | 1063 | pkgCache::VerFileIterator Vf; |
3174e150 MV |
1064 | |
1065 | /** \brief How many (more) times to try to find a new source from | |
1066 | * which to download this package version if it fails. | |
1067 | * | |
1068 | * Set from Acquire::Retries. | |
1069 | */ | |
7d8afa39 | 1070 | unsigned int Retries; |
3174e150 MV |
1071 | |
1072 | /** \brief \b true if this version file is being downloaded from a | |
1073 | * trusted source. | |
1074 | */ | |
7db98ffc | 1075 | bool Trusted; |
17caf1b1 | 1076 | |
3174e150 | 1077 | /** \brief Queue up the next available file for this version. */ |
b185acc2 | 1078 | bool QueueNext(); |
03e39e59 AL |
1079 | |
1080 | public: | |
1081 | ||
472ff00e | 1082 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 1083 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, |
459681d3 | 1084 | pkgAcquire::MethodConfig *Cnf); |
ca15786a MV |
1085 | virtual std::string DescURI() {return Desc.URI;}; |
1086 | virtual std::string ShortDesc() {return Desc.ShortDesc;}; | |
ab559b35 | 1087 | virtual void Finished(); |
b3501edb | 1088 | virtual bool IsTrusted() const; |
03e39e59 | 1089 | |
3174e150 MV |
1090 | /** \brief Create a new pkgAcqArchive. |
1091 | * | |
1092 | * \param Owner The pkgAcquire object with which this item is | |
1093 | * associated. | |
1094 | * | |
1095 | * \param Sources The sources from which to download version | |
1096 | * files. | |
1097 | * | |
1098 | * \param Recs A package records object, used to look up the file | |
1099 | * corresponding to each version of the package. | |
1100 | * | |
1101 | * \param Version The package version to download. | |
1102 | * | |
3c8030a4 | 1103 | * \param[out] StoreFilename A location in which the actual filename of |
3174e150 MV |
1104 | * the package should be stored. It will be set to a guessed |
1105 | * basename in the constructor, and filled in with a fully | |
1106 | * qualified filename once the download finishes. | |
1107 | */ | |
03e39e59 | 1108 | pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, |
30e1eab5 | 1109 | pkgRecords *Recs,pkgCache::VerIterator const &Version, |
472ff00e | 1110 | std::string &StoreFilename); |
03e39e59 | 1111 | }; |
92fcbfc1 DK |
1112 | /*}}}*/ |
1113 | /** \brief Retrieve an arbitrary file to the current directory. {{{ | |
3174e150 MV |
1114 | * |
1115 | * The file is retrieved even if it is accessed via a URL type that | |
1116 | * normally is a NOP, such as "file". If the download fails, the | |
1117 | * partial file is renamed to get a ".FAILED" extension. | |
1118 | */ | |
36375005 AL |
1119 | class pkgAcqFile : public pkgAcquire::Item |
1120 | { | |
3174e150 MV |
1121 | /** \brief How many times to retry the download, set from |
1122 | * Acquire::Retries. | |
1123 | */ | |
08cfc005 | 1124 | unsigned int Retries; |
36375005 | 1125 | |
77278c2b MV |
1126 | /** \brief Should this file be considered a index file */ |
1127 | bool IsIndexFile; | |
1128 | ||
36375005 AL |
1129 | public: |
1130 | ||
1131 | // Specialized action members | |
472ff00e | 1132 | virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); |
b3501edb | 1133 | virtual void Done(std::string Message,unsigned long long Size, HashStringList const &CalcHashes, |
459681d3 | 1134 | pkgAcquire::MethodConfig *Cnf); |
ca15786a | 1135 | virtual std::string DescURI() {return Desc.URI;}; |
b3501edb | 1136 | virtual std::string Custom600Headers() const; |
3174e150 MV |
1137 | |
1138 | /** \brief Create a new pkgAcqFile object. | |
1139 | * | |
1140 | * \param Owner The pkgAcquire object with which this object is | |
1141 | * associated. | |
1142 | * | |
1143 | * \param URI The URI to download. | |
1144 | * | |
b3501edb DK |
1145 | * \param Hashes The hashsums of the file to download, if they are known; |
1146 | * otherwise empty list. | |
3174e150 MV |
1147 | * |
1148 | * \param Size The size of the file to download, if it is known; | |
1149 | * otherwise 0. | |
1150 | * | |
1151 | * \param Desc A description of the file being downloaded. | |
1152 | * | |
1153 | * \param ShortDesc A brief description of the file being | |
1154 | * downloaded. | |
39c7baef MV |
1155 | * |
1156 | * \param DestDir The directory the file should be downloaded into. | |
1157 | * | |
1158 | * \param DestFilename The filename+path the file is downloaded to. | |
1159 | * | |
77278c2b MV |
1160 | * \param IsIndexFile The file is considered a IndexFile and cache-control |
1161 | * headers like "cache-control: max-age=0" are send | |
39c7baef | 1162 | * |
255c9e4b DK |
1163 | * If DestFilename is empty, download to DestDir/\<basename\> if |
1164 | * DestDir is non-empty, $CWD/\<basename\> otherwise. If | |
39c7baef MV |
1165 | * DestFilename is NOT empty, DestDir is ignored and DestFilename |
1166 | * is the absolute name to which the file should be downloaded. | |
3174e150 | 1167 | */ |
39c7baef | 1168 | |
b3501edb | 1169 | pkgAcqFile(pkgAcquire *Owner, std::string URI, HashStringList const &Hashes, unsigned long long Size, |
472ff00e DK |
1170 | std::string Desc, std::string ShortDesc, |
1171 | const std::string &DestDir="", const std::string &DestFilename="", | |
77278c2b | 1172 | bool IsIndexFile=false); |
36375005 | 1173 | }; |
92fcbfc1 | 1174 | /*}}}*/ |
3174e150 MV |
1175 | /** @} */ |
1176 | ||
0118833a | 1177 | #endif |