X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/dd09a217ac0d331f4a0324cf42559da5d35edc9a..229fb1a3a35bade26cfff373087461d7a98aade3:/apt-pkg/acquire-item.h diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 217ddb3ef..b338b2a41 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -12,7 +12,7 @@ Three item classes are provided to provide functionality for downloading of Index, Translation and Packages files. - A Archive class is provided for downloading .deb files. It does Md5 + A Archive class is provided for downloading .deb files. It does Hash checking and source location as well as a retry algorithm. ##################################################################### */ @@ -26,10 +26,8 @@ #include #include #include - -#ifdef __GNUG__ -#pragma interface "apt-pkg/acquire-item.h" -#endif +#include +#include /** \addtogroup acquire * @{ @@ -37,7 +35,7 @@ * \file acquire-item.h */ -/** \brief Represents the process by which a pkgAcquire object should +/** \brief Represents the process by which a pkgAcquire object should {{{ * retrieve a file or a collection of files. * * By convention, Item subclasses should insert themselves into the @@ -49,7 +47,7 @@ * * \see pkgAcquire */ -class pkgAcquire::Item +class pkgAcquire::Item : public WeakPointable { protected: @@ -100,7 +98,12 @@ class pkgAcquire::Item /** \brief The item was downloaded but its authenticity could * not be verified. */ - StatAuthError + StatAuthError, + + /** \brief The item was could not be downloaded because of + * a transient network error (e.g. network down) + */ + StatTransientNetworkError } Status; /** \brief Contains a textual description of the error encountered @@ -185,12 +188,12 @@ class pkgAcquire::Item * \param Message Data from the acquire method. Use LookupTag() * to parse it. * \param Size The size of the object that was fetched. - * \param Md5Hash The MD5Sum of the object that was fetched. + * \param Hash The HashSum of the object that was fetched. * \param Cnf The method via which the object was fetched. * * \sa pkgAcqMethod */ - virtual void Done(string Message,unsigned long Size,string Md5Hash, + virtual void Done(string Message,unsigned long Size,string Hash, pkgAcquire::MethodConfig *Cnf); /** \brief Invoked when the worker starts to fetch this object. @@ -228,12 +231,12 @@ class pkgAcquire::Item /** \brief Invoked by the worker when the download is completely done. */ virtual void Finished() {}; - /** \brief MD5Sum. + /** \brief HashSum * - * \return the MD5Sum of this object, if applicable; otherwise, an + * \return the HashSum of this object, if applicable; otherwise, an * empty string. */ - virtual string MD5Sum() {return string();}; + virtual string HashSum() {return string();}; /** \return the acquire process with which this item is associated. */ pkgAcquire *GetOwner() {return Owner;}; @@ -259,8 +262,8 @@ class pkgAcquire::Item */ virtual ~Item(); }; - -/** \brief Information about an index patch (aka diff). */ + /*}}}*/ +/** \brief Information about an index patch (aka diff). */ /*{{{*/ struct DiffInfo { /** The filename of the diff. */ string file; @@ -271,8 +274,8 @@ struct DiffInfo { /** The size of the diff. */ unsigned long size; }; - -/** \brief An item that is responsible for fetching an index file of + /*}}}*/ +/** \brief An item that is responsible for fetching an index file of {{{ * package list diffs and starting the package list's download. * * This item downloads the Index file and parses it, then enqueues @@ -295,10 +298,10 @@ class pkgAcqDiffIndex : public pkgAcquire::Item */ string RealURI; - /** \brief The MD5Sum that the real index file should have after + /** \brief The Hash that the real index file should have after * all patches have been applied. */ - string ExpectedMD5; + HashString ExpectedHash; /** \brief The index file which will be patched to generate the new * file. @@ -341,13 +344,13 @@ class pkgAcqDiffIndex : public pkgAcquire::Item * * \param ShortDesc A short description of the list file to download. * - * \param ExpectedMD5 The list file's MD5 signature. + * \param ExpectedHash The list file's MD5 signature. */ pkgAcqDiffIndex(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, string ExpectedMD5); + string ShortDesc, HashString ExpectedHash); }; - -/** \brief An item that is responsible for fetching all the patches + /*}}}*/ +/** \brief An item that is responsible for fetching all the patches {{{ * that need to be applied to a given package index file. * * After downloading and applying a single patch, this item will @@ -377,7 +380,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * finishes downloading. * * Dequeues the item and checks the resulting file's md5sum - * against ExpectedMD5 after the last patch was applied. + * against ExpectedHash after the last patch was applied. * There is no need to check the md5/sha1 after a "normal" * patch because QueueNextDiff() will check the sha1 later. * @@ -403,10 +406,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item */ string RealURI; - /** \brief The MD5Sum of the package index file that is being + /** \brief The HashSum of the package index file that is being * reconstructed. */ - string ExpectedMD5; + HashString ExpectedHash; /** A description of the file being downloaded. */ string Description; @@ -420,6 +423,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * off the front? */ vector available_patches; + + /** Stop applying patches when reaching that sha1 */ + string ServerSha1; + /** The current status of this patch. */ enum DiffState { @@ -463,7 +470,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * * \param ShortDesc A brief description of this item. * - * \param ExpectedMD5 The expected md5sum of the completely + * \param ExpectedHash The expected md5sum of the completely * reconstructed package index file; the index file will be tested * against this value when it is entirely reconstructed. * @@ -472,11 +479,12 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * that depends on it. */ pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, string ExpectedMD5, + string ShortDesc, HashString ExpectedHash, + string ServerSha1, vector diffs=vector()); }; - -/** \brief An acquire item that is responsible for fetching an index + /*}}}*/ +/** \brief An acquire item that is responsible for fetching an index {{{ * file (e.g., Packages or Sources). * * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans @@ -505,8 +513,8 @@ class pkgAcqIndex : public pkgAcquire::Item */ string RealURI; - /** \brief The expected md5sum of the decompressed index file. */ - string ExpectedMD5; + /** \brief The expected hashsum of the decompressed index file. */ + HashString ExpectedHash; /** \brief The compression-related file extension that is being * added to the downloaded file (e.g., ".gz" or ".bz2"). @@ -521,6 +529,7 @@ class pkgAcqIndex : public pkgAcquire::Item pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); virtual string DescURI() {return RealURI + CompressionExtension;}; + virtual string HashSum() {return ExpectedHash.toStr(); }; /** \brief Create a pkgAcqIndex. * @@ -533,17 +542,19 @@ class pkgAcqIndex : public pkgAcquire::Item * * \param ShortDesc A brief description of this index file. * - * \param ExpectedMD5 The expected md5sum of this index file. + * \param ExpectedHash The expected hashsum of this index file. * * \param compressExt The compression-related extension with which * this index file should be downloaded, or "" to autodetect - * (".bz2" is used if bzip2 is installed, ".gz" otherwise). + * Compression types can be set with config Acquire::CompressionTypes, + * default is ".lzma" or ".bz2" (if the needed binaries are present) + * fallback is ".gz" or none. */ pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, string ExpectedMD5, string compressExt=""); + string ShortDesc, HashString ExpectedHash, string compressExt=""); }; - -/** \brief An acquire item that is responsible for fetching a + /*}}}*/ +/** \brief An acquire item that is responsible for fetching a {{{ * translated index file. * * The only difference from pkgAcqIndex is that transient failures @@ -566,18 +577,12 @@ class pkgAcqIndexTrans : public pkgAcqIndex * \param URIDesc A "URI-style" description of this index file. * * \param ShortDesc A brief description of this index file. - * - * \param ExpectedMD5 The expected md5sum of this index file. - * - * \param compressExt The compression-related extension with which - * this index file should be downloaded, or "" to autodetect - * (".bz2" is used if bzip2 is installed, ".gz" otherwise). */ pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc); }; - -/** \brief Information about an index file. */ + /*}}}*/ +/** \brief Information about an index file. */ /*{{{*/ struct IndexTarget { /** \brief A URI from which the index file can be downloaded. */ @@ -594,8 +599,8 @@ struct IndexTarget */ string MetaKey; }; - -/** \brief An acquire item that downloads the detached signature + /*}}}*/ +/** \brief An acquire item that downloads the detached signature {{{ * of a meta-index (Release) file, then queues up the release * file itself. * @@ -606,6 +611,10 @@ struct IndexTarget class pkgAcqMetaSig : public pkgAcquire::Item { protected: + /** \brief The last good signature file */ + string LastGoodSig; + + /** \brief The fetch request that is currently being processed. */ pkgAcquire::ItemDesc Desc; @@ -653,15 +662,15 @@ class pkgAcqMetaSig : public pkgAcquire::Item const vector* IndexTargets, indexRecords* MetaIndexParser); }; - -/** \brief An item that is responsible for downloading the meta-index + /*}}}*/ +/** \brief An item that is responsible for downloading the meta-index {{{ * file (i.e., Release) itself and verifying its signature. * * Once the download and verification are complete, the downloads of * the individual index files are queued up using pkgAcqDiffIndex. - * If the meta-index file had a valid signature, the expected md5sums + * If the meta-index file had a valid signature, the expected hashsums * of the index files will be the md5sums listed in the meta-index; - * otherwise, the expected md5sums will be "" (causing the + * otherwise, the expected hashsums will be "" (causing the * authentication of the index files to be bypassed). */ class pkgAcqMetaIndex : public pkgAcquire::Item @@ -725,11 +734,11 @@ class pkgAcqMetaIndex : public pkgAcquire::Item /** \brief Starts downloading the individual index files. * - * \param verify If \b true, only indices whose expected md5sum + * \param verify If \b true, only indices whose expected hashsum * can be determined from the meta-index will be downloaded, and - * the md5sums of indices will be checked (reporting + * the hashsums of indices will be checked (reporting * #StatAuthError if there is a mismatch). If verify is \b false, - * no md5sum checking will be performed. + * no hashsum checking will be performed. */ void QueueIndexes(bool verify); @@ -737,7 +746,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item // Specialized action members virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size,string Md5Hash, + virtual void Done(string Message,unsigned long Size, string Hash, pkgAcquire::MethodConfig *Cnf); virtual string Custom600Headers(); virtual string DescURI() {return RealURI; }; @@ -749,8 +758,8 @@ class pkgAcqMetaIndex : public pkgAcquire::Item const vector* IndexTargets, indexRecords* MetaIndexParser); }; - -/** \brief An item that is responsible for fetching a package file. + /*}}}*/ +/** \brief An item that is responsible for fetching a package file. {{{ * * If the package file already exists in the cache, nothing will be * done. @@ -774,8 +783,8 @@ class pkgAcqArchive : public pkgAcquire::Item */ pkgRecords *Recs; - /** \brief The md5sum of this package. */ - string MD5; + /** \brief The hashsum of this package. */ + HashString ExpectedHash; /** \brief A location in which the actual filename of the package * should be stored. @@ -803,13 +812,12 @@ class pkgAcqArchive : public pkgAcquire::Item public: virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size,string Md5Hash, + virtual void Done(string Message,unsigned long Size,string Hash, pkgAcquire::MethodConfig *Cnf); - virtual string MD5Sum() {return MD5;}; virtual string DescURI() {return Desc.URI;}; virtual string ShortDesc() {return Desc.ShortDesc;}; virtual void Finished(); - + virtual string HashSum() {return ExpectedHash.toStr(); }; virtual bool IsTrusted(); /** \brief Create a new pkgAcqArchive. @@ -834,8 +842,8 @@ class pkgAcqArchive : public pkgAcquire::Item pkgRecords *Recs,pkgCache::VerIterator const &Version, string &StoreFilename); }; - -/** \brief Retrieve an arbitrary file to the current directory. + /*}}}*/ +/** \brief Retrieve an arbitrary file to the current directory. {{{ * * The file is retrieved even if it is accessed via a URL type that * normally is a NOP, such as "file". If the download fails, the @@ -846,22 +854,26 @@ class pkgAcqFile : public pkgAcquire::Item /** \brief The currently active download process. */ pkgAcquire::ItemDesc Desc; - /** \brief The md5sum of the file to download, if it is known. */ - string Md5Hash; + /** \brief The hashsum of the file to download, if it is known. */ + HashString ExpectedHash; /** \brief How many times to retry the download, set from * Acquire::Retries. */ unsigned int Retries; + /** \brief Should this file be considered a index file */ + bool IsIndexFile; + public: // Specialized action members virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long Size,string Md5Hash, + virtual void Done(string Message,unsigned long Size,string CalcHash, pkgAcquire::MethodConfig *Cnf); - virtual string MD5Sum() {return Md5Hash;}; virtual string DescURI() {return Desc.URI;}; + virtual string HashSum() {return ExpectedHash.toStr(); }; + virtual string Custom600Headers(); /** \brief Create a new pkgAcqFile object. * @@ -870,7 +882,7 @@ class pkgAcqFile : public pkgAcquire::Item * * \param URI The URI to download. * - * \param MD5 The md5sum of the file to download, if it is known; + * \param Hash The hashsum of the file to download, if it is known; * otherwise "". * * \param Size The size of the file to download, if it is known; @@ -885,6 +897,8 @@ class pkgAcqFile : public pkgAcquire::Item * * \param DestFilename The filename+path the file is downloaded to. * + * \param IsIndexFile The file is considered a IndexFile and cache-control + * headers like "cache-control: max-age=0" are send * * If DestFilename is empty, download to DestDir/ if * DestDir is non-empty, $CWD/ otherwise. If @@ -892,11 +906,12 @@ class pkgAcqFile : public pkgAcquire::Item * is the absolute name to which the file should be downloaded. */ - pkgAcqFile(pkgAcquire *Owner, string URI, string MD5, unsigned long Size, + pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Size, string Desc, string ShortDesc, - const string &DestDir="", const string &DestFilename=""); + const string &DestDir="", const string &DestFilename="", + bool IsIndexFile=false); }; - + /*}}}*/ /** @} */ #endif