summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.h
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/acquire-item.h')
-rw-r--r--apt-pkg/acquire-item.h432
1 files changed, 234 insertions, 198 deletions
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index c027a2764..3c522f66e 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -47,6 +47,7 @@ class indexRecords;
class pkgRecords;
class pkgSourceList;
class IndexTarget;
+class pkgAcqMetaBase;
/** \brief Represents the process by which a pkgAcquire object should {{{
* retrieve a file or a collection of files.
@@ -62,6 +63,8 @@ class IndexTarget;
*/
class pkgAcquire::Item : public WeakPointable
{
+ void *d;
+
protected:
/** \brief The acquire object with which this item is associated. */
@@ -116,7 +119,7 @@ class pkgAcquire::Item : public WeakPointable
/** \brief The item was could not be downloaded because of
* a transient network error (e.g. network down)
*/
- StatTransientNetworkError
+ StatTransientNetworkError,
} Status;
/** \brief Contains a textual description of the error encountered
@@ -168,6 +171,9 @@ class pkgAcquire::Item : public WeakPointable
*/
unsigned int QueueCounter;
+ /** \brief TransactionManager */
+ pkgAcqMetaBase *TransactionManager;
+
/** \brief The number of additional fetch items that are expected
* once this item is done.
*
@@ -183,6 +189,9 @@ class pkgAcquire::Item : public WeakPointable
*/
std::string DestFile;
+ /** \brief storge name until a transaction is finished */
+ std::string PartialFile;
+
/** \brief Invoked by the acquire worker when the object couldn't
* be fetched.
*
@@ -290,7 +299,8 @@ class pkgAcquire::Item : public WeakPointable
* \param ExpectedHashes of the file represented by this item
*/
Item(pkgAcquire *Owner,
- HashStringList const &ExpectedHashes=HashStringList());
+ HashStringList const &ExpectedHashes=HashStringList(),
+ pkgAcqMetaBase *TransactionManager=NULL);
/** \brief Remove this item from its owner's queue by invoking
* pkgAcquire::Remove.
@@ -330,62 +340,206 @@ struct DiffInfo {
unsigned long size;
};
/*}}}*/
-/** \brief An item that is responsible for fetching a SubIndex {{{
- *
- * The MetaIndex file includes only records for important indexes
- * and records for these SubIndex files so these can carry records
- * for addition files like PDiffs and Translations
- */
-class pkgAcqSubIndex : public pkgAcquire::Item
+ /*}}}*/
+
+class pkgAcqMetaBase : public pkgAcquire::Item
{
+ void *d;
+
protected:
- /** \brief If \b true, debugging information will be written to std::clog. */
- bool Debug;
+ std::vector<Item*> Transaction;
public:
- // Specialized action members
- virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
- pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return Desc.URI;};
- virtual std::string Custom600Headers() const;
- virtual bool ParseIndex(std::string const &IndexFile);
+ // transaction code
+ void Add(Item *I);
+ void AbortTransaction();
+ bool TransactionHasError() APT_PURE;
+ void CommitTransaction();
+
+ // helper for the signature warning
+ bool GenerateAuthWarning(const std::string &RealURI,
+ const std::string &Message);
+
+
+ pkgAcqMetaBase(pkgAcquire *Owner,
+ HashStringList const &ExpectedHashes=HashStringList(),
+ pkgAcqMetaBase *TransactionManager=NULL)
+ : Item(Owner, ExpectedHashes, TransactionManager) {};
+};
- /** \brief Create a new pkgAcqSubIndex.
+
+/** \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 hashsums
+ * of the index files will be the md5sums listed in the meta-index;
+ * otherwise, the expected hashsums will be "" (causing the
+ * authentication of the index files to be bypassed).
+ */
+class pkgAcqMetaIndex : public pkgAcqMetaBase
+{
+ void *d;
+
+ protected:
+ /** \brief The URI that is actually being downloaded; never
+ * modified by pkgAcqMetaIndex.
+ */
+ std::string RealURI;
+
+ /** \brief The file in which the signature for this index was stored.
*
- * \param Owner The Acquire object that owns this item.
+ * If empty, the signature and the md5sums of the individual
+ * indices will not be checked.
+ */
+ std::string SigFile;
+
+ /** \brief The index files to download. */
+ const std::vector<IndexTarget*>* IndexTargets;
+
+ /** \brief The parser for the meta-index file. */
+ indexRecords* MetaIndexParser;
+
+ /** \brief If \b true, the index's signature is currently being verified.
+ */
+ bool AuthPass;
+ // required to deal gracefully with problems caused by incorrect ims hits
+ bool IMSHit;
+
+ /** \brief Check that the release file is a release file for the
+ * correct distribution.
*
- * \param URI The URI of the list file to download.
+ * \return \b true if no fatal errors were encountered.
+ */
+ bool VerifyVendor(std::string Message);
+
+ /** \brief Called when a file is finished being retrieved.
*
- * \param URIDesc A long description of the list file to download.
+ * If the file was not downloaded to DestFile, a copy process is
+ * set up to copy it to DestFile; otherwise, Complete is set to \b
+ * true and the file is moved to its final location.
*
- * \param ShortDesc A short description of the list file to download.
+ * \param Message The message block received from the fetch
+ * subprocess.
+ */
+ void RetrievalDone(std::string Message);
+
+ /** \brief Called when authentication succeeded.
*
- * \param ExpectedHashes The list file's hashsums which are expected.
+ * Sanity-checks the authenticated file, queues up the individual
+ * index files for download, and saves the signature in the lists
+ * directory next to the authenticated list file.
+ *
+ * \param Message The message block received from the fetch
+ * subprocess.
+ */
+ void AuthDone(std::string Message);
+
+ /** \brief Starts downloading the individual index files.
+ *
+ * \param verify If \b true, only indices whose expected hashsum
+ * can be determined from the meta-index will be downloaded, and
+ * the hashsums of indices will be checked (reporting
+ * #StatAuthError if there is a mismatch). If verify is \b false,
+ * no hashsum checking will be performed.
*/
- pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc,
- std::string const &ShortDesc, HashStringList const &ExpectedHashes);
+ void QueueIndexes(bool verify);
+
+ /** \brief The URI of the meta-index file for the detached signature */
+ std::string MetaIndexSigURI;
+
+ /** \brief A "URI-style" description of the meta-index file */
+ std::string MetaIndexSigURIDesc;
+
+ /** \brief A brief description of the meta-index file */
+ std::string MetaIndexSigShortDesc;
+
+ /** \brief delayed constructor */
+ void Init(std::string URIDesc, std::string ShortDesc);
+
+ public:
+
+ // Specialized action members
+ virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+ virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+ pkgAcquire::MethodConfig *Cnf);
+ virtual std::string Custom600Headers() const;
+ virtual std::string DescURI() const {return RealURI; };
+ virtual void Finished();
+
+ /** \brief Create a new pkgAcqMetaIndex. */
+ pkgAcqMetaIndex(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
+ std::string URI,std::string URIDesc, std::string ShortDesc,
+ std::string MetaIndexSigURI, std::string MetaIndexSigURIDesc, std::string MetaIndexSigShortDesc,
+ const std::vector<IndexTarget*>* IndexTargets,
+ indexRecords* MetaIndexParser);
+};
+ /*}}}*/
+/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
+class pkgAcqMetaClearSig : public pkgAcqMetaIndex
+{
+ void *d;
+
+ /** \brief The URI of the meta-index file for the detached signature */
+ std::string MetaIndexURI;
+
+ /** \brief A "URI-style" description of the meta-index file */
+ std::string MetaIndexURIDesc;
+
+ /** \brief A brief description of the meta-index file */
+ std::string MetaIndexShortDesc;
+
+ /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */
+ std::string MetaSigURI;
+
+ /** \brief A "URI-style" description of the meta-signature file */
+ std::string MetaSigURIDesc;
+
+ /** \brief A brief description of the meta-signature file */
+ std::string MetaSigShortDesc;
+
+public:
+ virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+ virtual std::string Custom600Headers() const;
+ virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+ pkgAcquire::MethodConfig *Cnf);
+
+ /** \brief Create a new pkgAcqMetaClearSig. */
+ pkgAcqMetaClearSig(pkgAcquire *Owner,
+ std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc,
+ std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc,
+ std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc,
+ const std::vector<IndexTarget*>* IndexTargets,
+ indexRecords* MetaIndexParser);
+ virtual ~pkgAcqMetaClearSig();
};
/*}}}*/
+
/** \brief Common base class for all classes that deal with fetching {{{
indexes
*/
class pkgAcqBaseIndex : public pkgAcquire::Item
{
+ void *d;
+
protected:
/** \brief Pointer to the IndexTarget data
*/
const struct IndexTarget * Target;
indexRecords *MetaIndexParser;
+ /** \brief The MetaIndex Key */
+ std::string MetaKey;
pkgAcqBaseIndex(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
struct IndexTarget const * const Target,
HashStringList const &ExpectedHashes,
indexRecords *MetaIndexParser)
- : Item(Owner, ExpectedHashes), Target(Target),
+ : Item(Owner, ExpectedHashes, TransactionManager), Target(Target),
MetaIndexParser(MetaIndexParser) {};
-
};
/*}}}*/
/** \brief An item that is responsible for fetching an index file of {{{
@@ -399,6 +553,8 @@ class pkgAcqBaseIndex : public pkgAcquire::Item
*/
class pkgAcqDiffIndex : public pkgAcqBaseIndex
{
+ void *d;
+
protected:
/** \brief If \b true, debugging information will be written to std::clog. */
bool Debug;
@@ -452,6 +608,7 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex
* \param ExpectedHashes The list file's hashsums which are expected.
*/
pkgAcqDiffIndex(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
struct IndexTarget const * const Target,
HashStringList const &ExpectedHashes,
indexRecords *MetaIndexParser);
@@ -470,6 +627,8 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex
*/
class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
{
+ void *d;
+
protected:
/** \brief If \b true, debugging output will be written to
@@ -540,6 +699,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
* check if it was the last one to complete the download step
*/
pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
struct IndexTarget const * const Target,
HashStringList const &ExpectedHash,
indexRecords *MetaIndexParser,
@@ -560,6 +720,8 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
*/
class pkgAcqIndexDiffs : public pkgAcqBaseIndex
{
+ void *d;
+
private:
/** \brief Queue up the next diff download.
@@ -668,6 +830,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex
* that depends on it.
*/
pkgAcqIndexDiffs(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
struct IndexTarget const * const Target,
HashStringList const &ExpectedHash,
indexRecords *MetaIndexParser,
@@ -684,6 +847,8 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex
*/
class pkgAcqIndex : public pkgAcqBaseIndex
{
+ void *d;
+
protected:
/** \brief If \b true, the index file has been decompressed. */
@@ -694,6 +859,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex
*/
bool Erase;
+ // FIXME:
// Unused, used to be used to verify that "Packages: " header was there
bool __DELME_ON_NEXT_ABI_BREAK_Verify;
@@ -711,13 +877,16 @@ class pkgAcqIndex : public pkgAcqBaseIndex
/** \brief Do the changes needed to fetch via AptByHash (if needed) */
void InitByHashIfNeeded(const std::string MetaKey);
+ /** \brief Auto select the right compression to use */
+ void AutoSelectCompression();
+
/** \brief Get the full pathname of the final file for the given URI
*/
std::string GetFinalFilename(std::string const &URI,
std::string const &compExt);
/** \brief Schedule file for verification after a IMS hit */
- void ReverifyAfterIMS(std::string const &FileName);
+ void ReverifyAfterIMS();
public:
@@ -748,12 +917,12 @@ class pkgAcqIndex : public pkgAcqBaseIndex
* fallback is ".gz" or none.
*/
pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
- std::string ShortDesc, HashStringList const &ExpectedHashes,
- std::string compressExt="");
- pkgAcqIndex(pkgAcquire *Owner,
+ std::string ShortDesc, HashStringList const &ExpectedHashes);
+ pkgAcqIndex(pkgAcquire *Owner, pkgAcqMetaBase *TransactionManager,
IndexTarget const * const Target,
HashStringList const &ExpectedHash,
indexRecords *MetaIndexParser);
+
void Init(std::string const &URI, std::string const &URIDesc,
std::string const &ShortDesc);
};
@@ -767,6 +936,8 @@ class pkgAcqIndex : public pkgAcqBaseIndex
*/
class pkgAcqIndexTrans : public pkgAcqIndex
{
+ void *d;
+
public:
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
@@ -783,15 +954,21 @@ class pkgAcqIndexTrans : public pkgAcqIndex
*
* \param ShortDesc A brief description of this index file.
*/
- pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
+ pkgAcqIndexTrans(pkgAcquire *Owner,
+ std::string URI,std::string URIDesc,
std::string ShortDesc);
- pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const * const Target,
- HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser);
+ pkgAcqIndexTrans(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
+ IndexTarget const * const Target,
+ HashStringList const &ExpectedHashes,
+ indexRecords *MetaIndexParser);
};
/*}}}*/
/** \brief Information about an index file. */ /*{{{*/
class IndexTarget
{
+ void *d;
+
public:
/** \brief A URI from which the index file can be downloaded. */
std::string URI;
@@ -810,35 +987,18 @@ class IndexTarget
virtual bool IsOptional() const {
return false;
}
- virtual bool IsSubIndex() const {
- return false;
- }
};
/*}}}*/
/** \brief Information about an optional index file. */ /*{{{*/
class OptionalIndexTarget : public IndexTarget
{
+ void *d;
+
virtual bool IsOptional() const {
return true;
}
};
/*}}}*/
-/** \brief Information about an subindex index file. */ /*{{{*/
-class SubIndexTarget : public IndexTarget
-{
- virtual bool IsSubIndex() const {
- return true;
- }
-};
- /*}}}*/
-/** \brief Information about an subindex index file. */ /*{{{*/
-class OptionalSubIndexTarget : public OptionalIndexTarget
-{
- virtual bool IsSubIndex() const {
- return true;
- }
-};
- /*}}}*/
/** \brief An acquire item that downloads the detached signature {{{
* of a meta-index (Release) file, then queues up the release
@@ -848,8 +1008,10 @@ class OptionalSubIndexTarget : public OptionalIndexTarget
*
* \sa pkgAcqMetaIndex
*/
-class pkgAcqMetaSig : public pkgAcquire::Item
+class pkgAcqMetaSig : public pkgAcqMetaBase
{
+ void *d;
+
protected:
/** \brief The last good signature file */
std::string LastGoodSig;
@@ -860,22 +1022,12 @@ class pkgAcqMetaSig : public pkgAcquire::Item
*/
std::string RealURI;
- /** \brief The URI of the meta-index file to be fetched after the signature. */
- std::string MetaIndexURI;
-
- /** \brief A "URI-style" description of the meta-index file to be
- * fetched after the signature.
- */
- std::string MetaIndexURIDesc;
-
- /** \brief A brief description of the meta-index file to be fetched
- * after the signature.
- */
- std::string MetaIndexShortDesc;
-
/** \brief A package-system-specific parser for the meta-index file. */
indexRecords* MetaIndexParser;
+ /** \brief The file we need to verify */
+ std::string MetaIndexFile;
+
/** \brief The index files which should be looked up in the meta-index
* and then downloaded.
*
@@ -883,6 +1035,12 @@ class pkgAcqMetaSig : public pkgAcquire::Item
*/
const std::vector<IndexTarget*>* IndexTargets;
+ /** \brief If we are in fetching or download state */
+ bool AuthPass;
+
+ /** \brief Was this file already on disk */
+ bool IMSHit;
+
public:
// Specialized action members
@@ -893,141 +1051,15 @@ class pkgAcqMetaSig : public pkgAcquire::Item
virtual std::string DescURI() const {return RealURI; };
/** \brief Create a new pkgAcqMetaSig. */
- pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc,
- std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc,
+ pkgAcqMetaSig(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
+ std::string URI,std::string URIDesc, std::string ShortDesc,
+ std::string MetaIndexFile,
const std::vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser);
virtual ~pkgAcqMetaSig();
};
/*}}}*/
-/** \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 hashsums
- * of the index files will be the md5sums listed in the meta-index;
- * otherwise, the expected hashsums will be "" (causing the
- * authentication of the index files to be bypassed).
- */
-class pkgAcqMetaIndex : public pkgAcquire::Item
-{
- protected:
- /** \brief The URI that is actually being downloaded; never
- * modified by pkgAcqMetaIndex.
- */
- std::string RealURI;
-
- /** \brief The file in which the signature for this index was stored.
- *
- * If empty, the signature and the md5sums of the individual
- * indices will not be checked.
- */
- std::string SigFile;
-
- /** \brief The index files to download. */
- const std::vector<IndexTarget*>* IndexTargets;
-
- /** \brief The parser for the meta-index file. */
- indexRecords* MetaIndexParser;
-
- /** \brief If \b true, the index's signature is currently being verified.
- */
- bool AuthPass;
- // required to deal gracefully with problems caused by incorrect ims hits
- bool IMSHit;
-
- /** \brief Check that the release file is a release file for the
- * correct distribution.
- *
- * \return \b true if no fatal errors were encountered.
- */
- bool VerifyVendor(std::string Message);
-
- /** \brief Called when a file is finished being retrieved.
- *
- * If the file was not downloaded to DestFile, a copy process is
- * set up to copy it to DestFile; otherwise, Complete is set to \b
- * true and the file is moved to its final location.
- *
- * \param Message The message block received from the fetch
- * subprocess.
- */
- void RetrievalDone(std::string Message);
-
- /** \brief Called when authentication succeeded.
- *
- * Sanity-checks the authenticated file, queues up the individual
- * index files for download, and saves the signature in the lists
- * directory next to the authenticated list file.
- *
- * \param Message The message block received from the fetch
- * subprocess.
- */
- void AuthDone(std::string Message);
-
- /** \brief Starts downloading the individual index files.
- *
- * \param verify If \b true, only indices whose expected hashsum
- * can be determined from the meta-index will be downloaded, and
- * the hashsums of indices will be checked (reporting
- * #StatAuthError if there is a mismatch). If verify is \b false,
- * no hashsum checking will be performed.
- */
- void QueueIndexes(bool verify);
-
- public:
-
- // Specialized action members
- virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
- pkgAcquire::MethodConfig *Cnf);
- virtual std::string Custom600Headers() const;
- virtual std::string DescURI() const {return RealURI; };
-
- /** \brief Create a new pkgAcqMetaIndex. */
- pkgAcqMetaIndex(pkgAcquire *Owner,
- std::string URI,std::string URIDesc, std::string ShortDesc,
- std::string SigFile,
- const std::vector<IndexTarget*>* IndexTargets,
- indexRecords* MetaIndexParser);
-};
- /*}}}*/
-/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
-class pkgAcqMetaClearSig : public pkgAcqMetaIndex
-{
- /** \brief The URI of the meta-index file for the detached signature */
- std::string MetaIndexURI;
-
- /** \brief A "URI-style" description of the meta-index file */
- std::string MetaIndexURIDesc;
-
- /** \brief A brief description of the meta-index file */
- std::string MetaIndexShortDesc;
-
- /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */
- std::string MetaSigURI;
-
- /** \brief A "URI-style" description of the meta-signature file */
- std::string MetaSigURIDesc;
-
- /** \brief A brief description of the meta-signature file */
- std::string MetaSigShortDesc;
-
-public:
- void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
- virtual std::string Custom600Headers() const;
-
- /** \brief Create a new pkgAcqMetaClearSig. */
- pkgAcqMetaClearSig(pkgAcquire *Owner,
- std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc,
- std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc,
- std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc,
- const std::vector<IndexTarget*>* IndexTargets,
- indexRecords* MetaIndexParser);
- virtual ~pkgAcqMetaClearSig();
-};
- /*}}}*/
/** \brief An item that is responsible for fetching a package file. {{{
*
* If the package file already exists in the cache, nothing will be
@@ -1035,6 +1067,8 @@ public:
*/
class pkgAcqArchive : public pkgAcquire::Item
{
+ void *d;
+
protected:
/** \brief The package version being fetched. */
pkgCache::VerIterator Version;
@@ -1113,6 +1147,8 @@ class pkgAcqArchive : public pkgAcquire::Item
*/
class pkgAcqFile : public pkgAcquire::Item
{
+ void *d;
+
/** \brief How many times to retry the download, set from
* Acquire::Retries.
*/