19#ifndef PKGLIB_ACQUIRE_ITEM_H
20#define PKGLIB_ACQUIRE_ITEM_H
23#include <apt-pkg/hashes.h>
24#include <apt-pkg/indexfile.h>
26#include <apt-pkg/weakptr.h>
30#include <unordered_map>
128 std::string UsedMirror;
171 virtual void Failed(std::string
const &Message,pkgAcquire::MethodConfig
const *
const Cnf);
172 APT_HIDDEN
void FailMessage(std::string
const &Message);
194 pkgAcquire::MethodConfig
const *
const Cnf);
215 pkgAcquire::MethodConfig
const *
const Cnf);
226 virtual void Start(std::string
const &Message,
unsigned long long const Size);
238 APT_HIDDEN std::unordered_map<std::string, std::string> &ModifyCustomFields();
240 APT_HIDDEN
bool PopAlternativeURI(std::string &NewURI);
241 APT_HIDDEN
bool IsGoodAlternativeURI(std::string
const &AltUri)
const;
242 APT_HIDDEN
void PushAlternativeURI(std::string &&NewURI, std::unordered_map<std::string, std::string> &&fields,
bool const at_the_back);
243 APT_HIDDEN
void RemoveAlternativeSite(std::string
const &AltUri);
274 pkgAcquire::ItemDesc &GetItemDesc();
300 bool APT_HIDDEN IsRedirectionLoop(std::string
const &NewURI);
306 time_point APT_HIDDEN FetchAfter();
315 enum RenameOnErrorState {
355 bool Rename(std::string
const &From, std::string
const &To);
373 HashStringList GetExpectedHashesFor(std::string
const &MetaKey)
const;
375 bool QueueURI(pkgAcquire::ItemDesc &Item)
override;
386 enum TransactionStates {
391 virtual bool TransactionState(TransactionStates
const state);
393 [[nodiscard]] std::string DescURI()
const override {
return Target.
URI; }
395 [[nodiscard]]
virtual std::string GetMetaKey()
const;
396 [[nodiscard]]
bool HashesRequired()
const override;
397 [[nodiscard]]
virtual bool AcquireByHash()
const;
411 std::vector<pkgAcqTransactionItem*> Transaction;
429 void QueueForSignatureVerify(
pkgAcqTransactionItem *
const I, std::string
const &File, std::string
const &Signature);
431 [[nodiscard]] std::string Custom600Headers()
const override;
443 bool CheckAuthDone(std::string
const &Message, pkgAcquire::MethodConfig
const *
const Cnf);
446 bool CheckStopAuthentication(pkgAcquire::Item *
const I,
const std::string &Message);
453 bool VerifyVendor(std::string
const &Message);
455 bool TransactionState(TransactionStates state)
override;
460 TransactionStates State;
463 bool QueueURI(pkgAcquire::ItemDesc &Item)
override;
465 [[nodiscard]]
bool HashesRequired()
const override;
469 void AbortTransaction();
470 bool TransactionHasError()
const;
471 void CommitTransaction();
476 const std::string &From,
477 const std::string &To);
483 [[nodiscard]] std::string GetFinalFilename()
const override;
507 void Init(std::string
const &URIDesc, std::string
const &ShortDesc);
510 [[nodiscard]] std::string DescURI()
const override;
513 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
515 pkgAcquire::MethodConfig
const *Cnf)
override;
540 std::string MetaIndexFileSignature;
545 [[nodiscard]] std::string GetFinalFilename()
const override;
548 [[nodiscard]]
bool HashesRequired()
const override {
return false; }
551 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
553 pkgAcquire::MethodConfig
const *Cnf)
override;
554 [[nodiscard]] std::string Custom600Headers()
const override;
573 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
574 [[nodiscard]] std::string Custom600Headers()
const override;
575 bool VerifyDone(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
577 pkgAcquire::MethodConfig
const *Cnf)
override;
578 void Finished()
override;
588 void QueueIndexes(
bool const verify);
606 [[nodiscard]] std::string GetFinalFilename()
const override;
607 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
634 STAGE_DECOMPRESS_AND_VERIFY,
639 void StageDownloadDone(std::string
const &Message);
644 void StageDecompressDone();
663 [[nodiscard]] std::string GetFinalFilename()
const override;
665 bool TransactionState(TransactionStates state)
override;
669 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
671 pkgAcquire::MethodConfig
const *Cnf)
override;
672 [[nodiscard]] std::string Custom600Headers()
const override;
673 [[nodiscard]] std::string DescURI()
const override {
return Desc.URI; };
674 [[nodiscard]] std::string GetMetaKey()
const override;
677 IndexTarget const &Target,
bool const Derived =
false) APT_NONNULL(2, 3);
681 APT_HIDDEN
void Init(std::
string const &
URI, std::
string const &URIDesc,
682 std::
string const &ShortDesc);
683 APT_HIDDEN
bool CommonFailed(std::
string const &TargetURI,
684 std::
string const &Message,
pkgAcquire::MethodConfig const *const Cnf);
713 std::vector<pkgAcqIndexMergeDiffs*> * diffs;
714 std::vector<DiffInfo> available_patches;
722 [[nodiscard]] std::string GetFinalFilename()
const override;
724 bool QueueURI(pkgAcquire::ItemDesc &Item)
override;
726 bool TransactionState(TransactionStates state)
override;
730 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
731 bool VerifyDone(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
733 pkgAcquire::MethodConfig
const *Cnf)
override;
734 [[nodiscard]] std::string DescURI()
const override {
return Target.
URI +
"Index"; };
735 [[nodiscard]] std::string GetMetaKey()
const override;
747 bool ParseDiffIndex(std::string
const &IndexDiffFile);
763 APT_HIDDEN
void QueueOnIMSHit()
const;
790 std::vector<pkgAcqIndexMergeDiffs*>
const *
const allPatches;
814 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
816 pkgAcquire::MethodConfig
const *Cnf)
override;
817 [[nodiscard]] std::string Custom600Headers()
const override;
818 [[nodiscard]] std::string DescURI()
const override {
return Target.
URI +
"Index"; };
820 [[nodiscard]]
bool HashesRequired()
const override;
821 [[nodiscard]]
bool AcquireByHash()
const override;
837 std::vector<pkgAcqIndexMergeDiffs *>
const *
const allPatches) APT_NONNULL(2, 3, 6);
865 APT_HIDDEN
bool QueueNextDiff();
878 APT_HIDDEN
void Finish(
bool const allDone=
false);
914 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
917 pkgAcquire::MethodConfig
const * Cnf)
override;
918 [[nodiscard]] std::string Custom600Headers()
const override;
919 [[nodiscard]] std::string DescURI()
const override {
return Target.
URI +
"IndexDiffs"; };
921 [[nodiscard]]
bool HashesRequired()
const override;
922 [[nodiscard]]
bool AcquireByHash()
const override;
939 std::vector<DiffInfo>
const &diffs = std::vector<DiffInfo>()) APT_NONNULL(2, 3);
983 [[nodiscard]] std::string GetFinalFilename()
const override;
986 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const * Cnf)
override;
988 pkgAcquire::MethodConfig
const *Cnf)
override;
989 [[nodiscard]] std::string DescURI()
const override;
990 [[nodiscard]] std::string ShortDesc()
const override;
991 void Finished()
override;
992 [[nodiscard]]
bool IsTrusted()
const override;
994 [[nodiscard]]
bool HashesRequired()
const override;
1015 pkgRecords *
const Recs,pkgCache::VerIterator
const &Version,
1016 std::string &StoreFilename);
1029 std::string TemporaryDirectory;
1030 std::string
const SrcName;
1031 std::string
const SrcVersion;
1036 [[nodiscard]]
HashStringList GetExpectedHashes()
const override {
return {}; }
1037 [[nodiscard]]
bool HashesRequired()
const override {
return false; }
1040 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const *Cnf)
override;
1041 void Done(std::string
const &Message,
HashStringList const &CalcHashes,
1042 pkgAcquire::MethodConfig
const *Cnf)
override;
1043 [[nodiscard]] std::string DescURI()
const override {
return Desc.URI; };
1050 static std::string
URI(pkgCache::VerIterator
const &Ver);
1060 static std::string
URI(pkgCache::RlsFileIterator
const &Rls,
1061 char const *
const Component,
char const *
const SrcName,
1062 char const *
const SrcVersion);
1072 static std::string
URI(std::string
const &Template,
1073 char const *
const Component,
char const *
const SrcName,
1074 char const *
const SrcVersion);
1081 static std::string URITemplate(pkgCache::RlsFileIterator
const &Rls);
1094 std::string
const &DestDir=
"", std::string
const &DestFilename=
"");
1110 char const *
const Component,
char const *
const SrcName,
char const *
const SrcVersion,
1111 std::string
const &DestDir=
"", std::string
const &DestFilename=
"");
1126 char const *
const SrcName,
char const *
const SrcVersion,
1127 std::string
const &DestDir=
"", std::string
const &DestFilename=
"");
1132 APT_HIDDEN
void Init(std::string
const &DestDir, std::string
const &DestFilename);
1151 [[nodiscard]]
bool HashesRequired()
const override;
1154 void Done(std::string
const &Message,
HashStringList const &CalcHashes,
1155 pkgAcquire::MethodConfig
const *Cnf)
override;
1156 [[nodiscard]] std::string DescURI()
const override {
return Desc.URI; };
1157 [[nodiscard]] std::string Custom600Headers()
const override;
1191 std::string
const &Desc, std::string
const &ShortDesc,
1192 std::string
const &DestDir=
"", std::string
const &DestFilename=
"",
1193 bool const IsIndexFile=
false);
1199 pkgAcquire::Item *
const Owner;
1200 pkgAcquire::Worker *
const Worker;
1201 unsigned long long MaximumSize;
1204 void Failed(std::string
const &Message, pkgAcquire::MethodConfig
const * Cnf)
override;
1205 void Done(std::string
const &Message,
HashStringList const &CalcHashes,
1206 pkgAcquire::MethodConfig
const *Cnf)
override;
1207 [[nodiscard]] std::string Custom600Headers()
const override;
1208 void Finished()
override;
1210 pkgAcqAuxFile(pkgAcquire::Item *
const Owner, pkgAcquire::Worker *
const Worker,
1211 std::string
const &ShortDesc, std::string
const &Desc, std::string
const &
URI,
Information about an index file.
Definition indexfile.h:39
std::string URI
A URI from which the index file can be downloaded.
Definition indexfile.h:42
An item that is responsible for fetching a package file. {{{.
Definition acquire-item.h:949
pkgRecords * Recs
A package records object, used to look up the file corresponding to each version of the package.
Definition acquire-item.h:967
pkgCache::VerIterator Version
The package version being fetched.
Definition acquire-item.h:957
bool Trusted
true if this version file is being downloaded from a trusted source.
Definition acquire-item.h:977
std::string & StoreFilename
A location in which the actual filename of the package should be stored.
Definition acquire-item.h:972
pkgSourceList * Sources
The list of sources from which to pick archives to download this package from.
Definition acquire-item.h:962
Definition acquire-item.h:1198
Common base class for all classes that deal with fetching indexes {{{.
Definition acquire-item.h:601
Definition acquire-item.cc:3640
Retrieve the changelog for the given version {{{.
Definition acquire-item.h:1026
An item that is responsible for fetching an index file of {{{ package list diffs and starting the pac...
Definition acquire-item.h:711
bool Debug
If true, debugging information will be written to std::clog.
Definition acquire-item.h:719
Retrieve an arbitrary file to the current directory. {{{.
Definition acquire-item.h:1142
An item that is responsible for fetching server-merge patches {{{ that need to be applied to a given ...
Definition acquire-item.h:853
std::vector< DiffInfo > available_patches
Definition acquire-item.h:895
DiffState
Definition acquire-item.h:899
@ StateFetchDiff
The diff is currently being fetched.
Definition acquire-item.h:901
bool Debug
If true, debugging output will be written to std::clog.
Definition acquire-item.h:885
An item that is responsible for fetching client-merge patches {{{ that need to be applied to a given ...
Definition acquire-item.h:778
std::vector< pkgAcqIndexMergeDiffs * > const *const allPatches
list of all download items for the patches
Definition acquire-item.h:790
DiffState
Definition acquire-item.h:794
@ StateApplyDiff
The diff is currently being applied.
Definition acquire-item.h:799
@ StateFetchDiff
The diff is currently being fetched.
Definition acquire-item.h:796
@ StateDoneDiff
the work with this diff is done
Definition acquire-item.h:802
bool Debug
If true, debugging output will be written to std::clog.
Definition acquire-item.h:784
An acquire item that is responsible for fetching an index {{{ file (e.g., Packages or Sources).
Definition acquire-item.h:622
std::string CompressionExtensions
The compression-related file extensions that are being added to the downloaded file one by one if fir...
Definition acquire-item.h:654
void InitByHashIfNeeded()
Do the changes needed to fetch via AptByHash (if needed)
std::string CurrentCompressionExtension
The actual compression extension currently used.
Definition acquire-item.h:657
AllStages
The stages the method goes through.
Definition acquire-item.h:632
std::string EraseFileName
If set, this partially downloaded file will be removed when the download completes.
Definition acquire-item.h:649
baseclass for the indexes files to manage them all together
Definition acquire-item.h:370
pkgAcqMetaClearSig *const TransactionManager
TransactionManager.
Definition acquire-item.h:384
std::string PartialFile
storge name until a transaction is finished
Definition acquire-item.h:381
Represents the process by which a pkgAcquire object should retrieve a file or a collection of files.
Definition acquire-item.h:59
virtual bool HashesRequired() const
Definition acquire-item.h:270
bool RenameOnError(RenameOnErrorState const state)
Rename failed file and set error.
int APT_HIDDEN Priority()
The priority of the item, used for queuing.
virtual bool VerifyDone(std::string const &Message, pkgAcquire::MethodConfig const *const Cnf)
Invoked by the acquire worker to check if the successfully fetched object is also the objected we wan...
virtual void Done(std::string const &Message, HashStringList const &Hashes, pkgAcquire::MethodConfig const *const Cnf)
Invoked by the acquire worker when the object was fetched successfully.
unsigned int QueueCounter
The number of fetch queues into which this item has been inserted.
Definition acquire-item.h:138
std::string HashSum() const
virtual void Finished()
Invoked by the worker when the download is completely done.
unsigned long long PartialSize
How much of the object was already fetched.
Definition acquire-item.h:99
unsigned int Retries
Number of retries.
Definition acquire-item.h:156
virtual bool QueueURI(ItemDesc &Item)
Insert this item into its owner's queue.
virtual void Start(std::string const &Message, unsigned long long const Size)
Invoked when the worker starts to fetch this object.
unsigned int ExpectedAdditionalItems
The number of additional fetch items that are expected once this item is done.
Definition acquire-item.h:148
std::string ActiveSubprocess
contains the name of the subprocess that is operating on this object (for instance,...
Definition acquire-item.h:104
pkgAcquire::ItemDesc Desc
The item that is currently being downloaded.
Definition acquire-item.h:313
virtual std::string Custom600Headers() const
Custom headers to be sent to the fetch process.
void Dequeue()
Remove this item from its owner's queue.
virtual ~Item()
Remove this item from its owner's queue by invoking pkgAcquire::Remove.
bool Rename(std::string const &From, std::string const &To)
Rename a file without modifying its timestamp.
unsigned long ID
A client-supplied unique identifier.
Definition acquire-item.h:113
void APT_HIDDEN FetchAfter(time_point FetchAfter)
internal clock definitions to avoid typing all that all over the place
virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const *const Cnf)
Invoked by the acquire worker when the object couldn't be fetched.
unsigned long long FileSize
The size of the object to fetch.
Definition acquire-item.h:96
bool Complete
If true, the entire object has been successfully fetched.
Definition acquire-item.h:119
virtual std::string ShortDesc() const
Short item description.
virtual HashStringList GetExpectedHashes() const =0
bool Local
If true, the URI of this object is "local".
Definition acquire-item.h:126
virtual std::string GetFinalFilename() const
Get the full pathname of the final file for the current URI.
Item(pkgAcquire *const Owner)
Initialize an item.
std::string ErrorText
Contains a textual description of the error encountered if ItemState is StatError or StatAuthError.
Definition acquire-item.h:93
std::string DestFile
The name of the file into which the retrieved object will be written.
Definition acquire-item.h:153
virtual bool IsTrusted() const
ItemState
The current status of this item.
Definition acquire-item.h:64
@ StatAuthError
The item was downloaded but its authenticity could not be verified.
Definition acquire-item.h:82
@ StatFetching
The item is currently being downloaded.
Definition acquire-item.h:69
@ StatTransientNetworkError
The item was could not be downloaded because of a transient network error (e.g. network down)
Definition acquire-item.h:87
@ StatError
An error was encountered while downloading this item.
Definition acquire-item.h:77
@ StatDone
The item has been successfully downloaded.
Definition acquire-item.h:72
@ StatIdle
The item is waiting to be downloaded.
Definition acquire-item.h:66
pkgAcquire *const Owner
The acquire object with which this item is associated.
Definition acquire-item.h:310
virtual std::string DescURI() const =0
A "descriptive" URI-like string.
void SetActiveSubprocess(std::string const &subprocess)
Set the name of the current active subprocess.
pkgAcquire * GetOwner() const
Definition pkgrecords.h:28
Definition sourcelist.h:43
pkgCache - Structure definitions for the cache file
Definition acquire-item.h:687
HashStringList patch_hashes
Definition acquire-item.h:695
HashStringList result_hashes
Definition acquire-item.h:692
HashStringList download_hashes
Definition acquire-item.h:698
std::string file
Definition acquire-item.h:689