X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/448c38bdcd72b52f11ec5f326f822cf57653f81c..08ea7806458de0995414eaae852e0a5985875642:/apt-pkg/acquire-item.h diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 97d5ea1dd..9dbacc1ea 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -21,6 +21,7 @@ #define PKGLIB_ACQUIRE_ITEM_H #include +#include #include #include #include @@ -28,9 +29,9 @@ #include #include +#include #ifndef APT_8_CLEANER_HEADERS -#include #include #include #include @@ -46,49 +47,8 @@ class indexRecords; class pkgRecords; class pkgSourceList; -class IndexTarget; class pkgAcqMetaBase; -class APT_HIDDEN IndexTarget /*{{{*/ -/** \brief Information about an index file. */ -{ - public: - /** \brief A URI from which the index file can be downloaded. */ - std::string const URI; - - /** \brief A description of the index file. */ - std::string const Description; - - /** \brief A shorter description of the index file. */ - std::string const ShortDesc; - - /** \brief The key by which this index file should be - * looked up within the meta signature file. - */ - std::string const MetaKey; - - virtual bool IsOptional() const { - return false; - } - - IndexTarget(std::string const &MetaKey, std::string const &ShortDesc, - std::string const &LongDesc, std::string const &URI) : - URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey) {} -}; - /*}}}*/ -class APT_HIDDEN OptionalIndexTarget : public IndexTarget /*{{{*/ -/** \brief Information about an optional index file. */ -{ - public: - virtual bool IsOptional() const { - return true; - } - - OptionalIndexTarget(std::string const &MetaKey, std::string const &ShortDesc, - std::string const &LongDesc, std::string const &URI) : - IndexTarget(MetaKey, ShortDesc, LongDesc, URI) {} -}; - /*}}}*/ class pkgAcquire::Item : public WeakPointable /*{{{*/ /** \brief Represents the process by which a pkgAcquire object should * retrieve a file or a collection of files. @@ -289,6 +249,7 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/ /** \return the acquire process with which this item is associated. */ pkgAcquire *GetOwner() const; + pkgAcquire::ItemDesc &GetItemDesc(); /** \return \b true if this object is being fetched from a trusted source. */ virtual bool IsTrusted() const; @@ -385,7 +346,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/ /** \brief baseclass for the indexes files to manage them all together */ { protected: - IndexTarget const * const Target; + IndexTarget const Target; HashStringList GetExpectedHashesFor(std::string const MetaKey) const; bool QueueURI(pkgAcquire::ItemDesc &Item); @@ -403,13 +364,13 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/ }; virtual bool TransactionState(TransactionStates const state); - virtual std::string DescURI() const { return Target->URI; } + virtual std::string DescURI() const { return Target.URI; } virtual HashStringList GetExpectedHashes() const; virtual std::string GetMetaKey() const; virtual bool HashesRequired() const; - pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target); + pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target); virtual ~pkgAcqTransactionItem(); friend class pkgAcqMetaBase; @@ -423,7 +384,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/ protected: std::vector Transaction; - IndexTarget const DataTarget; public: /** \brief A package-system-specific parser for the meta-index file. */ indexRecords *MetaIndexParser; @@ -433,7 +393,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/ /** \brief The index files which should be looked up in the meta-index * and then downloaded. */ - const std::vector* const IndexTargets; + std::vector const IndexTargets; /** \brief If \b true, the index's signature is currently being verified. */ @@ -515,7 +475,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/ virtual std::string GetFinalFilename() const; pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - std::vector const * const IndexTargets, + std::vector const IndexTargets, IndexTarget const &DataTarget, indexRecords* const MetaIndexParser); }; @@ -552,7 +512,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget, - const std::vector* const IndexTargets, indexRecords * const MetaIndexParser); + std::vector const IndexTargets, indexRecords * const MetaIndexParser); friend class pkgAcqMetaSig; }; @@ -588,7 +548,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem pkgAcquire::MethodConfig const * const Cnf); /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target, + pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target, pkgAcqMetaIndex * const MetaIndex); virtual ~pkgAcqMetaSig(); }; @@ -613,7 +573,7 @@ public: IndexTarget const &ClearsignedTarget, IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget, - std::vector const * const IndexTargets, + std::vector const IndexTargets, indexRecords * const MetaIndexParser); virtual ~pkgAcqMetaClearSig(); }; @@ -628,7 +588,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem virtual std::string GetFinalFilename() const; pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const * const Target); + IndexTarget const Target); }; /*}}}*/ /** \brief An item that is responsible for fetching an index file of {{{ @@ -648,11 +608,6 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex /** \brief If \b true, debugging information will be written to std::clog. */ bool Debug; - /** \brief The index file which will be patched to generate the new - * file. - */ - std::string CurrentPackagesFile; - /** \brief A description of the Packages file (stored in * pkgAcquire::ItemDesc::Description). */ @@ -669,7 +624,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf); virtual void Done(std::string const &Message, HashStringList const &Hashes, pkgAcquire::MethodConfig const * const Cnf); - virtual std::string DescURI() const {return Target->URI + "Index";}; + virtual std::string DescURI() const {return Target.URI + "Index";}; virtual std::string Custom600Headers() const; virtual std::string GetMetaKey() const; @@ -696,7 +651,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex * \param ShortDesc A short description of the list file to download. */ pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const * const Target); + IndexTarget const Target); private: APT_HIDDEN void QueueOnIMSHit() const; }; @@ -705,17 +660,14 @@ struct APT_HIDDEN DiffInfo { /*{{{*/ /** The filename of the diff. */ std::string file; - /** The hashes of the diff */ + /** The hashes of the file after the diff is applied */ HashStringList result_hashes; - /** The hashes of the file after the diff is applied */ + /** The hashes of the diff */ HashStringList patch_hashes; - /** The size of the file after the diff is applied */ - unsigned long long result_size; - - /** The size of the diff itself */ - unsigned long long patch_size; + /** The hashes of the compressed diff */ + HashStringList download_hashes; }; /*}}}*/ /** \brief An item that is responsible for fetching client-merge patches {{{ @@ -774,7 +726,8 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf); virtual void Done(std::string const &Message, HashStringList const &Hashes, pkgAcquire::MethodConfig const * const Cnf); - virtual std::string DescURI() const {return Target->URI + "Index";}; + virtual std::string Custom600Headers() const; + virtual std::string DescURI() const {return Target.URI + "Index";}; virtual HashStringList GetExpectedHashes() const; virtual bool HashesRequired() const; @@ -796,8 +749,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * check if it was the last one to complete the download step */ pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const * const Target, - DiffInfo const &patch, + IndexTarget const Target, DiffInfo const &patch, std::vector const * const allPatches); }; /*}}}*/ @@ -886,7 +838,8 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex virtual void Done(std::string const &Message, HashStringList const &Hashes, pkgAcquire::MethodConfig const * const Cnf); - virtual std::string DescURI() const {return Target->URI + "IndexDiffs";}; + virtual std::string Custom600Headers() const; + virtual std::string DescURI() const {return Target.URI + "IndexDiffs";}; virtual HashStringList GetExpectedHashes() const; virtual bool HashesRequired() const; @@ -909,7 +862,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex * that depends on it. */ pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const * const Target, + IndexTarget const Target, std::vector const &diffs=std::vector()); }; /*}}}*/ @@ -971,9 +924,6 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex /** \brief Schedule file for verification after a IMS hit */ void ReverifyAfterIMS(); - /** \brief Validate the downloaded index file */ - bool ValidateFile(std::string const &FileName); - /** \brief Get the full pathname of the final file for the current URI */ virtual std::string GetFinalFilename() const; @@ -989,7 +939,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex virtual std::string GetMetaKey() const; pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, - IndexTarget const * const Target); + IndexTarget const Target); void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc); @@ -1082,6 +1032,120 @@ class pkgAcqArchive : public pkgAcquire::Item std::string &StoreFilename); }; /*}}}*/ +/** \brief Retrieve the changelog for the given version {{{ + * + * Downloads the changelog to a temporary file it will also remove again + * while it is deconstructed or downloads it to a named location. + */ +class pkgAcqChangelog : public pkgAcquire::Item +{ + void *d; + std::string TemporaryDirectory; + std::string const SrcName; + std::string const SrcVersion; + + public: + // we will never have hashes for changelogs. + // If you need verified ones, download the deb and extract the changelog. + virtual HashStringList GetExpectedHashes() const { return HashStringList(); } + virtual bool HashesRequired() const { return false; } + + // Specialized action members + virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf); + virtual void Done(std::string const &Message, HashStringList const &CalcHashes, + pkgAcquire::MethodConfig const * const Cnf); + virtual std::string DescURI() const {return Desc.URI;}; + + /** returns the URI to the changelog of this version + * + * @param Ver is the version to get the changelog for + * @return the URI which will be used to acquire the changelog + */ + static std::string URI(pkgCache::VerIterator const &Ver); + + /** returns the URI to the changelog of this version + * + * \param Rls is the Release file the package comes from + * \param Component in which the package resides, can be empty + * \param SrcName is the source package name + * \param SrcVersion is the source package version + * @return the URI which will be used to acquire the changelog + */ + static std::string URI(pkgCache::RlsFileIterator const &Rls, + char const * const Component, char const * const SrcName, + char const * const SrcVersion); + + /** returns the URI to the changelog of this version + * + * \param Template URI where CHANGEPATH has to be filled in + * \param Component in which the package resides, can be empty + * \param SrcName is the source package name + * \param SrcVersion is the source package version + * @return the URI which will be used to acquire the changelog + */ + static std::string URI(std::string const &Template, + char const * const Component, char const * const SrcName, + char const * const SrcVersion); + + /** returns the URI template for this release file + * + * \param Rls is a Release file + * @return the URI template to use for this release file + */ + static std::string URITemplate(pkgCache::RlsFileIterator const &Rls); + + /** \brief Create a new pkgAcqChangelog object. + * + * \param Owner The pkgAcquire object with which this object is + * associated. + * \param Ver is the version to get the changelog for + * \param DestDir The directory the file should be downloaded into. + * Will be an autocreated (and cleaned up) temporary directory if not set. + * \param DestFilename The filename the file should have in #DestDir + * Defaults to sourcepackagename.changelog if not set. + */ + pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver, + std::string const &DestDir="", std::string const &DestFilename=""); + + /** \brief Create a new pkgAcqChangelog object. + * + * \param Owner The pkgAcquire object with which this object is + * associated. + * \param Rls is the Release file the package comes from + * \param Component in which the package resides, can be empty + * \param SrcName is the source package name + * \param SrcVersion is the source package version + * \param DestDir The directory the file should be downloaded into. + * Will be an autocreated (and cleaned up) temporary directory if not set. + * \param DestFilename The filename the file should have in #DestDir + * Defaults to sourcepackagename.changelog if not set. + */ + pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls, + char const * const Component, char const * const SrcName, char const * const SrcVersion, + std::string const &DestDir="", std::string const &DestFilename=""); + + /** \brief Create a new pkgAcqChangelog object. + * + * \param Owner The pkgAcquire object with which this object is + * associated. + * \param URI is to be used to get the changelog + * \param SrcName is the source package name + * \param SrcVersion is the source package version + * \param DestDir The directory the file should be downloaded into. + * Will be an autocreated (and cleaned up) temporary directory if not set. + * \param DestFilename The filename the file should have in #DestDir + * Defaults to sourcepackagename.changelog if not set. + */ + pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI, + char const * const SrcName, char const * const SrcVersion, + std::string const &DestDir="", std::string const &DestFilename=""); + + virtual ~pkgAcqChangelog(); + +private: + APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename); +}; + /*}}}*/ /** \brief Retrieve an arbitrary file to the current directory. {{{ * * The file is retrieved even if it is accessed via a URL type that