1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire-item.h,v 1.26.2.3 2004/01/02 18:51:00 mdz Exp $
4 /* ######################################################################
6 Acquire Item - Item to acquire
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
10 register all the URI's they wish to fetch at the initial moment.
12 Three item classes are provided to provide functionality for
13 downloading of Index, Translation and Packages files.
15 A Archive class is provided for downloading .deb files. It does Hash
16 checking and source location as well as a retry algorithm.
18 ##################################################################### */
20 #ifndef PKGLIB_ACQUIRE_ITEM_H
21 #define PKGLIB_ACQUIRE_ITEM_H
23 #include <apt-pkg/acquire.h>
24 #include <apt-pkg/hashes.h>
25 #include <apt-pkg/weakptr.h>
26 #include <apt-pkg/pkgcache.h>
27 #include <apt-pkg/cacheiterators.h>
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>
40 /** \addtogroup acquire
43 * \file acquire-item.h
51 /** \brief Represents the process by which a pkgAcquire object should {{{
52 * retrieve a file or a collection of files.
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.
63 class pkgAcquire::Item
: public WeakPointable
67 /** \brief The acquire object with which this item is associated. */
70 /** \brief Insert this item into its owner's queue.
72 * \param Item Metadata about this item (its URI and
75 inline void QueueURI(ItemDesc
&Item
)
76 {Owner
->Enqueue(Item
);};
78 /** \brief Remove this item from its owner's queue. */
79 inline void Dequeue() {Owner
->Dequeue(this);};
81 /** \brief Rename a file without modifying its timestamp.
83 * Many item methods call this as their final action.
85 * \param From The file to be renamed.
87 * \param To The new name of \a From. If \a To exists it will be
90 void Rename(std::string From
,std::string To
);
94 /** \brief The current status of this item. */
97 /** \brief The item is waiting to be downloaded. */
100 /** \brief The item is currently being downloaded. */
103 /** \brief The item has been successfully downloaded. */
106 /** \brief An error was encountered while downloading this
111 /** \brief The item was downloaded but its authenticity could
116 /** \brief The item was could not be downloaded because of
117 * a transient network error (e.g. network down)
119 StatTransientNetworkError
122 /** \brief Contains a textual description of the error encountered
123 * if #ItemState is #StatError or #StatAuthError.
125 std::string ErrorText
;
127 /** \brief The size of the object to fetch. */
128 unsigned long long FileSize
;
130 /** \brief How much of the object was already fetched. */
131 unsigned long long PartialSize
;
133 /** \brief If not \b NULL, contains the name of a subprocess that
134 * is operating on this object (for instance, "gzip" or "gpgv").
136 APT_DEPRECATED
const char *Mode
;
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
;
143 /** \brief A client-supplied unique identifier.
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.
148 * \todo it's unused in apt itself
152 /** \brief If \b true, the entire object has been successfully fetched.
154 * Subclasses should set this to \b true when appropriate.
158 /** \brief If \b true, the URI of this object is "local".
160 * The only effect of this field is to exclude the object from the
161 * download progress indicator's overall statistics.
164 std::string UsedMirror
;
166 /** \brief The number of fetch queues into which this item has been
169 * There is one queue for each source from which an item could be
174 unsigned int QueueCounter
;
176 /** \brief The number of additional fetch items that are expected
177 * once this item is done.
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
184 unsigned int ExpectedAdditionalItems
;
186 /** \brief The name of the file into which the retrieved object
189 std::string DestFile
;
191 /** \brief Invoked by the acquire worker when the object couldn't
194 * This is a branch of the continuation of the fetch process.
196 * \param Message An RFC822-formatted message from the acquire
197 * method describing what went wrong. Use LookupTag() to parse
200 * \param Cnf The method via which the worker tried to fetch this object.
204 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
206 /** \brief Invoked by the acquire worker when the object was
207 * fetched successfully.
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.
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.
217 * \param Message Data from the acquire method. Use LookupTag()
219 * \param Size The size of the object that was fetched.
220 * \param Hashes The HashSums of the object that was fetched.
221 * \param Cnf The method via which the object was fetched.
225 virtual void Done(std::string Message
, unsigned long long Size
, HashStringList
const &Hashes
,
226 pkgAcquire::MethodConfig
*Cnf
);
228 /** \brief Invoked when the worker starts to fetch this object.
230 * \param Message RFC822-formatted data from the worker process.
231 * Use LookupTag() to parse it.
233 * \param Size The size of the object being fetched.
237 virtual void Start(std::string Message
,unsigned long long Size
);
239 /** \brief Custom headers to be sent to the fetch process.
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.
247 virtual std::string
Custom600Headers() const {return std::string();};
249 /** \brief A "descriptive" URI-like string.
251 * \return a URI that should be used to describe what is being fetched.
253 virtual std::string
DescURI() = 0;
254 /** \brief Short item description.
256 * \return a brief description of the object being fetched.
258 virtual std::string
ShortDesc() {return DescURI();}
260 /** \brief Invoked by the worker when the download is completely done. */
261 virtual void Finished() {};
265 * \return the HashSums of this object, if applicable; otherwise, an
268 HashStringList
HashSums() const {return ExpectedHashes
;};
269 std::string
HashSum() const {HashStringList
const hashes
= HashSums(); HashString
const * const hs
= hashes
.find(NULL
); return hs
!= NULL
? hs
->toStr() : ""; };
271 /** \return the acquire process with which this item is associated. */
272 pkgAcquire
*GetOwner() const {return Owner
;};
274 /** \return \b true if this object is being fetched from a trusted source. */
275 virtual bool IsTrusted() const {return false;};
277 // report mirror problems
278 /** \brief Report mirror problem
280 * This allows reporting mirror failures back to a centralized
281 * server. The apt-report-mirror-failure script is called for this
283 * \param FailCode A short failure string that is send
285 void ReportMirrorFailure(std::string FailCode
);
288 /** \brief Initialize an item.
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).
294 * \param Owner The new owner of this item.
295 * \param ExpectedHashes of the file represented by this item
297 Item(pkgAcquire
*Owner
,
298 HashStringList
const &ExpectedHashes
=HashStringList());
300 /** \brief Remove this item from its owner's queue by invoking
301 * pkgAcquire::Remove.
307 enum RenameOnErrorState
{
313 /** \brief Rename failed file and set error
315 * \param state respresenting the error we encountered
317 bool RenameOnError(RenameOnErrorState
const state
);
319 /** \brief The HashSums of the item is supposed to have than done */
320 HashStringList ExpectedHashes
;
322 /** \brief The item that is currently being downloaded. */
323 pkgAcquire::ItemDesc Desc
;
326 /** \brief Information about an index patch (aka diff). */ /*{{{*/
328 /** The filename of the diff. */
331 /** The hashes of the diff */
332 HashStringList result_hashes
;
334 /** The hashes of the file after the diff is applied */
335 HashStringList patch_hashes
;
337 /** The size of the file after the diff is applied */
338 unsigned long long result_size
;
340 /** The size of the diff itself */
341 unsigned long long patch_size
;
344 /** \brief An item that is responsible for fetching a SubIndex {{{
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
350 class pkgAcqSubIndex
: public pkgAcquire::Item
353 /** \brief If \b true, debugging information will be written to std::clog. */
357 // Specialized action members
358 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
359 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
360 pkgAcquire::MethodConfig
*Cnf
);
361 virtual std::string
DescURI() {return Desc
.URI
;};
362 virtual std::string
Custom600Headers() const;
363 virtual bool ParseIndex(std::string
const &IndexFile
);
365 /** \brief Create a new pkgAcqSubIndex.
367 * \param Owner The Acquire object that owns this item.
369 * \param URI The URI of the list file to download.
371 * \param URIDesc A long description of the list file to download.
373 * \param ShortDesc A short description of the list file to download.
375 * \param ExpectedHashes The list file's hashsums which are expected.
377 pkgAcqSubIndex(pkgAcquire
*Owner
, std::string
const &URI
,std::string
const &URIDesc
,
378 std::string
const &ShortDesc
, HashStringList
const &ExpectedHashes
);
382 /** \brief Common base class for all classes that deal with fetching {{{
385 class pkgAcqBaseIndex
: public pkgAcquire::Item
388 /** \brief Pointer to the IndexTarget data
390 const struct IndexTarget
* Target
;
391 indexRecords
*MetaIndexParser
;
393 pkgAcqBaseIndex(pkgAcquire
*Owner
,
394 struct IndexTarget
const * const Target
,
395 HashStringList
const &ExpectedHashes
,
396 indexRecords
*MetaIndexParser
)
397 : Item(Owner
, ExpectedHashes
), Target(Target
),
398 MetaIndexParser(MetaIndexParser
) {};
402 /** \brief An item that is responsible for fetching an index file of {{{
403 * package list diffs and starting the package list's download.
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).
409 * \sa pkgAcqIndexDiffs, pkgAcqIndex
411 class pkgAcqDiffIndex
: public pkgAcqBaseIndex
414 /** \brief If \b true, debugging information will be written to std::clog. */
417 /** \brief The URI of the index file to recreate at our end (either
418 * by downloading it or by applying partial patches).
422 /** \brief The index file which will be patched to generate the new
425 std::string CurrentPackagesFile
;
427 /** \brief A description of the Packages file (stored in
428 * pkgAcquire::ItemDesc::Description).
430 std::string Description
;
433 // Specialized action members
434 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
435 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
436 pkgAcquire::MethodConfig
*Cnf
);
437 virtual std::string
DescURI() {return RealURI
+ "Index";};
438 virtual std::string
Custom600Headers() const;
440 /** \brief Parse the Index file for a set of Packages diffs.
442 * Parses the Index file and creates additional download items as
445 * \param IndexDiffFile The name of the Index file.
447 * \return \b true if the Index file was successfully parsed, \b
450 bool ParseDiffIndex(std::string IndexDiffFile
);
453 /** \brief Create a new pkgAcqDiffIndex.
455 * \param Owner The Acquire object that owns this item.
457 * \param URI The URI of the list file to download.
459 * \param URIDesc A long description of the list file to download.
461 * \param ShortDesc A short description of the list file to download.
463 * \param ExpectedHashes The list file's hashsums which are expected.
465 pkgAcqDiffIndex(pkgAcquire
*Owner
,
466 struct IndexTarget
const * const Target
,
467 HashStringList
const &ExpectedHashes
,
468 indexRecords
*MetaIndexParser
);
471 /** \brief An item that is responsible for fetching client-merge patches {{{
472 * that need to be applied to a given package index file.
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.
480 * \sa pkgAcqDiffIndex, pkgAcqIndex
482 class pkgAcqIndexMergeDiffs
: public pkgAcqBaseIndex
486 /** \brief If \b true, debugging output will be written to
491 /** \brief URI of the package index file that is being
496 /** \brief description of the file being downloaded. */
497 std::string Description
;
499 /** \brief information about the current patch */
500 struct DiffInfo
const patch
;
502 /** \brief list of all download items for the patches */
503 std::vector
<pkgAcqIndexMergeDiffs
*> const * const allPatches
;
505 /** The current status of this patch. */
508 /** \brief The diff is currently being fetched. */
511 /** \brief The diff is currently being applied. */
514 /** \brief the work with this diff is done */
517 /** \brief something bad happened and fallback was triggered */
522 /** \brief Called when the patch file failed to be downloaded.
524 * This method will fall back to downloading the whole index file
525 * outright; its arguments are ignored.
527 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
528 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
529 pkgAcquire::MethodConfig
*Cnf
);
530 virtual std::string
DescURI() {return RealURI
+ "Index";};
532 /** \brief Create an index merge-diff item.
534 * \param Owner The pkgAcquire object that owns this item.
536 * \param URI The URI of the package index file being
539 * \param URIDesc A long description of this item.
541 * \param ShortDesc A brief description of this item.
543 * \param ExpectedHashes The expected md5sum of the completely
544 * reconstructed package index file; the index file will be tested
545 * against this value when it is entirely reconstructed.
547 * \param patch contains infos about the patch this item is supposed
548 * to download which were read from the index
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
553 pkgAcqIndexMergeDiffs(pkgAcquire
*Owner
,
554 struct IndexTarget
const * const Target
,
555 HashStringList
const &ExpectedHash
,
556 indexRecords
*MetaIndexParser
,
557 DiffInfo
const &patch
,
558 std::vector
<pkgAcqIndexMergeDiffs
*> const * const allPatches
);
561 /** \brief An item that is responsible for fetching server-merge patches {{{
562 * that need to be applied to a given package index file.
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.
570 * \sa pkgAcqDiffIndex, pkgAcqIndex
572 class pkgAcqIndexDiffs
: public pkgAcqBaseIndex
576 /** \brief Queue up the next diff download.
578 * Search for the next available diff that applies to the file
579 * that currently exists on disk, and enqueue it by calling
582 * \return \b true if an applicable diff was found, \b false
585 APT_HIDDEN
bool QueueNextDiff();
587 /** \brief Handle tasks that must be performed after the item
588 * finishes downloading.
590 * Dequeues the item and checks the resulting file's hashsums
591 * against ExpectedHashes after the last patch was applied.
592 * There is no need to check the md5/sha1 after a "normal"
593 * patch because QueueNextDiff() will check the sha1 later.
595 * \param allDone If \b true, the file was entirely reconstructed,
596 * and its md5sum is verified.
598 APT_HIDDEN
void Finish(bool allDone
=false);
602 /** \brief If \b true, debugging output will be written to
607 /** \brief The URI of the package index file that is being
612 /** A description of the file being downloaded. */
613 std::string Description
;
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.
619 * \todo These are indexed by sha1sum; why not use some sort of
620 * dictionary instead of relying on ordering and stripping them
623 std::vector
<DiffInfo
> available_patches
;
625 /** The current status of this patch. */
628 /** \brief The diff is in an unknown state. */
631 /** \brief The diff is currently being fetched. */
634 /** \brief The diff is currently being uncompressed. */
635 StateUnzipDiff
, // FIXME: No longer used
637 /** \brief The diff is currently being applied. */
643 /** \brief Called when the patch file failed to be downloaded.
645 * This method will fall back to downloading the whole index file
646 * outright; its arguments are ignored.
648 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
650 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
651 pkgAcquire::MethodConfig
*Cnf
);
652 virtual std::string
DescURI() {return RealURI
+ "Index";};
654 /** \brief Create an index diff item.
656 * After filling in its basic fields, this invokes Finish(true) if
657 * \a diffs is empty, or QueueNextDiff() otherwise.
659 * \param Owner The pkgAcquire object that owns this item.
661 * \param URI The URI of the package index file being
664 * \param URIDesc A long description of this item.
666 * \param ShortDesc A brief description of this item.
668 * \param ExpectedHashes The expected hashsums of the completely
669 * reconstructed package index file; the index file will be tested
670 * against this value when it is entirely reconstructed.
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.
676 pkgAcqIndexDiffs(pkgAcquire
*Owner
,
677 struct IndexTarget
const * const Target
,
678 HashStringList
const &ExpectedHash
,
679 indexRecords
*MetaIndexParser
,
680 std::vector
<DiffInfo
> diffs
=std::vector
<DiffInfo
>());
683 /** \brief An acquire item that is responsible for fetching an index {{{
684 * file (e.g., Packages or Sources).
686 * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans
688 * \todo Why does pkgAcqIndex have protected members?
690 class pkgAcqIndex
: public pkgAcqBaseIndex
694 /** \brief If \b true, the index file has been decompressed. */
697 /** \brief If \b true, the partially downloaded file will be
698 * removed when the download completes.
702 // Unused, used to be used to verify that "Packages: " header was there
703 bool __DELME_ON_NEXT_ABI_BREAK_Verify
;
705 /** \brief The object that is actually being fetched (minus any
706 * compression-related extensions).
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").
713 std::string CompressionExtension
;
716 /** \brief Do the changes needed to fetch via AptByHash (if needed) */
717 void InitByHashIfNeeded(const std::string MetaKey
);
719 /** \brief Get the full pathname of the final file for the given URI
721 std::string
GetFinalFilename(std::string
const &URI
,
722 std::string
const &compExt
);
724 /** \brief Schedule file for verification after a IMS hit */
725 void ReverifyAfterIMS(std::string
const &FileName
);
729 // Specialized action members
730 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
731 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
732 pkgAcquire::MethodConfig
*Cnf
);
733 virtual std::string
Custom600Headers() const;
734 virtual std::string
DescURI() {return Desc
.URI
;};
736 /** \brief Create a pkgAcqIndex.
738 * \param Owner The pkgAcquire object with which this item is
741 * \param URI The URI of the index file that is to be downloaded.
743 * \param URIDesc A "URI-style" description of this index file.
745 * \param ShortDesc A brief description of this index file.
747 * \param ExpectedHashes The expected hashsum of this index file.
749 * \param compressExt The compression-related extension with which
750 * this index file should be downloaded, or "" to autodetect
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.
755 pkgAcqIndex(pkgAcquire
*Owner
,std::string URI
,std::string URIDesc
,
756 std::string ShortDesc
, HashStringList
const &ExpectedHashes
,
757 std::string compressExt
="");
758 pkgAcqIndex(pkgAcquire
*Owner
,
759 IndexTarget
const * const Target
,
760 HashStringList
const &ExpectedHash
,
761 indexRecords
*MetaIndexParser
);
762 void Init(std::string
const &URI
, std::string
const &URIDesc
,
763 std::string
const &ShortDesc
);
766 /** \brief An acquire item that is responsible for fetching a {{{
767 * translated index file.
769 * The only difference from pkgAcqIndex is that transient failures
770 * are suppressed: no error occurs if the translated index file is
773 class pkgAcqIndexTrans
: public pkgAcqIndex
777 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
778 virtual std::string
Custom600Headers() const;
780 /** \brief Create a pkgAcqIndexTrans.
782 * \param Owner The pkgAcquire object with which this item is
785 * \param URI The URI of the index file that is to be downloaded.
787 * \param URIDesc A "URI-style" description of this index file.
789 * \param ShortDesc A brief description of this index file.
791 pkgAcqIndexTrans(pkgAcquire
*Owner
,std::string URI
,std::string URIDesc
,
792 std::string ShortDesc
);
793 pkgAcqIndexTrans(pkgAcquire
*Owner
, IndexTarget
const * const Target
,
794 HashStringList
const &ExpectedHashes
, indexRecords
*MetaIndexParser
);
797 /** \brief Information about an index file. */ /*{{{*/
801 /** \brief A URI from which the index file can be downloaded. */
804 /** \brief A description of the index file. */
805 std::string Description
;
807 /** \brief A shorter description of the index file. */
808 std::string ShortDesc
;
810 /** \brief The key by which this index file should be
811 * looked up within the meta signature file.
815 virtual bool IsOptional() const {
818 virtual bool IsSubIndex() const {
823 /** \brief Information about an optional index file. */ /*{{{*/
824 class OptionalIndexTarget
: public IndexTarget
826 virtual bool IsOptional() const {
831 /** \brief Information about an subindex index file. */ /*{{{*/
832 class SubIndexTarget
: public IndexTarget
834 virtual bool IsSubIndex() const {
839 /** \brief Information about an subindex index file. */ /*{{{*/
840 class OptionalSubIndexTarget
: public OptionalIndexTarget
842 virtual bool IsSubIndex() const {
848 /** \brief An acquire item that downloads the detached signature {{{
849 * of a meta-index (Release) file, then queues up the release
852 * \todo Why protected members?
854 * \sa pkgAcqMetaIndex
856 class pkgAcqMetaSig
: public pkgAcquire::Item
859 /** \brief The last good signature file */
860 std::string LastGoodSig
;
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
868 /** \brief The URI of the meta-index file to be fetched after the signature. */
869 std::string MetaIndexURI
;
871 /** \brief A "URI-style" description of the meta-index file to be
872 * fetched after the signature.
874 std::string MetaIndexURIDesc
;
876 /** \brief A brief description of the meta-index file to be fetched
877 * after the signature.
879 std::string MetaIndexShortDesc
;
881 /** \brief A package-system-specific parser for the meta-index file. */
882 indexRecords
* MetaIndexParser
;
884 /** \brief The index files which should be looked up in the meta-index
885 * and then downloaded.
887 * \todo Why a list of pointers instead of a list of structs?
889 const std::vector
<IndexTarget
*>* IndexTargets
;
893 // Specialized action members
894 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
895 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
896 pkgAcquire::MethodConfig
*Cnf
);
897 virtual std::string
Custom600Headers() const;
898 virtual std::string
DescURI() {return RealURI
; };
900 /** \brief Create a new pkgAcqMetaSig. */
901 pkgAcqMetaSig(pkgAcquire
*Owner
,std::string URI
,std::string URIDesc
, std::string ShortDesc
,
902 std::string MetaIndexURI
, std::string MetaIndexURIDesc
, std::string MetaIndexShortDesc
,
903 const std::vector
<IndexTarget
*>* IndexTargets
,
904 indexRecords
* MetaIndexParser
);
905 virtual ~pkgAcqMetaSig();
908 /** \brief An item that is responsible for downloading the meta-index {{{
909 * file (i.e., Release) itself and verifying its signature.
911 * Once the download and verification are complete, the downloads of
912 * the individual index files are queued up using pkgAcqDiffIndex.
913 * If the meta-index file had a valid signature, the expected hashsums
914 * of the index files will be the md5sums listed in the meta-index;
915 * otherwise, the expected hashsums will be "" (causing the
916 * authentication of the index files to be bypassed).
918 class pkgAcqMetaIndex
: public pkgAcquire::Item
921 /** \brief The URI that is actually being downloaded; never
922 * modified by pkgAcqMetaIndex.
926 /** \brief The file in which the signature for this index was stored.
928 * If empty, the signature and the md5sums of the individual
929 * indices will not be checked.
933 /** \brief The index files to download. */
934 const std::vector
<IndexTarget
*>* IndexTargets
;
936 /** \brief The parser for the meta-index file. */
937 indexRecords
* MetaIndexParser
;
939 /** \brief If \b true, the index's signature is currently being verified.
942 // required to deal gracefully with problems caused by incorrect ims hits
945 /** \brief Check that the release file is a release file for the
946 * correct distribution.
948 * \return \b true if no fatal errors were encountered.
950 bool VerifyVendor(std::string Message
);
952 /** \brief Called when a file is finished being retrieved.
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.
958 * \param Message The message block received from the fetch
961 void RetrievalDone(std::string Message
);
963 /** \brief Called when authentication succeeded.
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.
969 * \param Message The message block received from the fetch
972 void AuthDone(std::string Message
);
974 /** \brief Starts downloading the individual index files.
976 * \param verify If \b true, only indices whose expected hashsum
977 * can be determined from the meta-index will be downloaded, and
978 * the hashsums of indices will be checked (reporting
979 * #StatAuthError if there is a mismatch). If verify is \b false,
980 * no hashsum checking will be performed.
982 void QueueIndexes(bool verify
);
986 // Specialized action members
987 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
988 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
989 pkgAcquire::MethodConfig
*Cnf
);
990 virtual std::string
Custom600Headers() const;
991 virtual std::string
DescURI() {return RealURI
; };
993 /** \brief Create a new pkgAcqMetaIndex. */
994 pkgAcqMetaIndex(pkgAcquire
*Owner
,
995 std::string URI
,std::string URIDesc
, std::string ShortDesc
,
997 const std::vector
<IndexTarget
*>* IndexTargets
,
998 indexRecords
* MetaIndexParser
);
1001 /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
1002 class pkgAcqMetaClearSig
: public pkgAcqMetaIndex
1004 /** \brief The URI of the meta-index file for the detached signature */
1005 std::string MetaIndexURI
;
1007 /** \brief A "URI-style" description of the meta-index file */
1008 std::string MetaIndexURIDesc
;
1010 /** \brief A brief description of the meta-index file */
1011 std::string MetaIndexShortDesc
;
1013 /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */
1014 std::string MetaSigURI
;
1016 /** \brief A "URI-style" description of the meta-signature file */
1017 std::string MetaSigURIDesc
;
1019 /** \brief A brief description of the meta-signature file */
1020 std::string MetaSigShortDesc
;
1023 void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
1024 virtual std::string
Custom600Headers() const;
1026 /** \brief Create a new pkgAcqMetaClearSig. */
1027 pkgAcqMetaClearSig(pkgAcquire
*Owner
,
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
,
1031 const std::vector
<IndexTarget
*>* IndexTargets
,
1032 indexRecords
* MetaIndexParser
);
1033 virtual ~pkgAcqMetaClearSig();
1036 /** \brief An item that is responsible for fetching a package file. {{{
1038 * If the package file already exists in the cache, nothing will be
1041 class pkgAcqArchive
: public pkgAcquire::Item
1044 /** \brief The package version being fetched. */
1045 pkgCache::VerIterator Version
;
1047 /** \brief The list of sources from which to pick archives to
1048 * download this package from.
1050 pkgSourceList
*Sources
;
1052 /** \brief A package records object, used to look up the file
1053 * corresponding to each version of the package.
1057 /** \brief A location in which the actual filename of the package
1060 std::string
&StoreFilename
;
1062 /** \brief The next file for this version to try to download. */
1063 pkgCache::VerFileIterator Vf
;
1065 /** \brief How many (more) times to try to find a new source from
1066 * which to download this package version if it fails.
1068 * Set from Acquire::Retries.
1070 unsigned int Retries
;
1072 /** \brief \b true if this version file is being downloaded from a
1077 /** \brief Queue up the next available file for this version. */
1082 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
1083 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &Hashes
,
1084 pkgAcquire::MethodConfig
*Cnf
);
1085 virtual std::string
DescURI() {return Desc
.URI
;};
1086 virtual std::string
ShortDesc() {return Desc
.ShortDesc
;};
1087 virtual void Finished();
1088 virtual bool IsTrusted() const;
1090 /** \brief Create a new pkgAcqArchive.
1092 * \param Owner The pkgAcquire object with which this item is
1095 * \param Sources The sources from which to download version
1098 * \param Recs A package records object, used to look up the file
1099 * corresponding to each version of the package.
1101 * \param Version The package version to download.
1103 * \param[out] StoreFilename A location in which the actual filename of
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.
1108 pkgAcqArchive(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
1109 pkgRecords
*Recs
,pkgCache::VerIterator
const &Version
,
1110 std::string
&StoreFilename
);
1113 /** \brief Retrieve an arbitrary file to the current directory. {{{
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.
1119 class pkgAcqFile
: public pkgAcquire::Item
1121 /** \brief How many times to retry the download, set from
1124 unsigned int Retries
;
1126 /** \brief Should this file be considered a index file */
1131 // Specialized action members
1132 virtual void Failed(std::string Message
,pkgAcquire::MethodConfig
*Cnf
);
1133 virtual void Done(std::string Message
,unsigned long long Size
, HashStringList
const &CalcHashes
,
1134 pkgAcquire::MethodConfig
*Cnf
);
1135 virtual std::string
DescURI() {return Desc
.URI
;};
1136 virtual std::string
Custom600Headers() const;
1138 /** \brief Create a new pkgAcqFile object.
1140 * \param Owner The pkgAcquire object with which this object is
1143 * \param URI The URI to download.
1145 * \param Hashes The hashsums of the file to download, if they are known;
1146 * otherwise empty list.
1148 * \param Size The size of the file to download, if it is known;
1151 * \param Desc A description of the file being downloaded.
1153 * \param ShortDesc A brief description of the file being
1156 * \param DestDir The directory the file should be downloaded into.
1158 * \param DestFilename The filename+path the file is downloaded to.
1160 * \param IsIndexFile The file is considered a IndexFile and cache-control
1161 * headers like "cache-control: max-age=0" are send
1163 * If DestFilename is empty, download to DestDir/\<basename\> if
1164 * DestDir is non-empty, $CWD/\<basename\> otherwise. If
1165 * DestFilename is NOT empty, DestDir is ignored and DestFilename
1166 * is the absolute name to which the file should be downloaded.
1169 pkgAcqFile(pkgAcquire
*Owner
, std::string URI
, HashStringList
const &Hashes
, unsigned long long Size
,
1170 std::string Desc
, std::string ShortDesc
,
1171 const std::string
&DestDir
="", const std::string
&DestFilename
="",
1172 bool IsIndexFile
=false);