if (State == StateFetchDiff)
return patch.download_hashes;
else if (State == StateApplyDiff)
- return GetExpectedHashesFor(Target->MetaKey);
+ return GetExpectedHashesFor(Target.MetaKey);
return HashStringList();
}
}
std::string pkgAcqIndex::GetFinalFilename() const
{
- std::string const FinalFile = GetFinalFileNameFromURI(Target->URI);
- return GetCompressedFileName(Target->URI, FinalFile, CurrentCompressionExtension);
+ std::string const FinalFile = GetFinalFileNameFromURI(Target.URI);
+ return GetCompressedFileName(Target.URI, FinalFile, CurrentCompressionExtension);
}
std::string pkgAcqMetaSig::GetFinalFilename() const
{
- return GetFinalFileNameFromURI(Target->URI);
+ return GetFinalFileNameFromURI(Target.URI);
}
std::string pkgAcqBaseIndex::GetFinalFilename() const
{
- return GetFinalFileNameFromURI(Target->URI);
+ return GetFinalFileNameFromURI(Target.URI);
}
std::string pkgAcqMetaBase::GetFinalFilename() const
{
- return GetFinalFileNameFromURI(DataTarget.URI);
+ return GetFinalFileNameFromURI(Target.URI);
}
std::string pkgAcqArchive::GetFinalFilename() const
{
// pkgAcqTransactionItem::GetMetaKey and specialisations for child classes /*{{{*/
std::string pkgAcqTransactionItem::GetMetaKey() const
{
- return Target->MetaKey;
+ return Target.MetaKey;
}
std::string pkgAcqIndex::GetMetaKey() const
{
if (Stage == STAGE_DECOMPRESS_AND_VERIFY || CurrentCompressionExtension == "uncompressed")
- return Target->MetaKey;
- return Target->MetaKey + "." + CurrentCompressionExtension;
+ return Target.MetaKey;
+ return Target.MetaKey + "." + CurrentCompressionExtension;
}
std::string pkgAcqDiffIndex::GetMetaKey() const
{
- return Target->MetaKey + ".diff/Index";
+ return Target.MetaKey + ".diff/Index";
}
/*}}}*/
//pkgAcqTransactionItem::TransactionState and specialisations for child classes /*{{{*/
case TransactionCommit:
break;
case TransactionAbort:
- std::string const Partial = GetPartialFileNameFromURI(Target->URI);
+ std::string const Partial = GetPartialFileNameFromURI(Target.URI);
unlink(Partial.c_str());
break;
}
reach its done state to prevent cleanup deleting the mentioned file.
Handy in cases in which we know we have the file already, like IMS-Hits. */
{
- IndexTarget const * const Target;
+ IndexTarget const Target;
public:
- virtual std::string DescURI() const {return Target->URI;};
+ virtual std::string DescURI() const {return Target.URI;};
virtual HashStringList GetExpectedHashes() const {return HashStringList();};
- NoActionItem(pkgAcquire * const Owner, IndexTarget const * const Target) :
+ NoActionItem(pkgAcquire * const Owner, IndexTarget const Target) :
pkgAcquire::Item(Owner), Target(Target)
{
Status = StatDone;
- DestFile = GetFinalFileNameFromURI(Target->URI);
+ DestFile = GetFinalFileNameFromURI(Target.URI);
}
};
/*}}}*/
/*}}}*/
pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/
- pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target) :
+ pkgAcqMetaBase * const TransactionManager, IndexTarget const Target) :
pkgAcquire::Item(Owner), Target(Target), TransactionManager(TransactionManager)
{
if (TransactionManager != this)
// AcqMetaBase - Constructor /*{{{*/
pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- std::vector<IndexTarget*> const * const IndexTargets,
+ std::vector<IndexTarget> const IndexTargets,
IndexTarget const &DataTarget,
indexRecords * const MetaIndexParser)
-: pkgAcqTransactionItem(Owner, TransactionManager, NULL), DataTarget(DataTarget),
+: pkgAcqTransactionItem(Owner, TransactionManager, DataTarget),
MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL), IndexTargets(IndexTargets),
AuthPass(false), IMSHit(false)
{
// at this point the real Items are loaded in the fetcher
ExpectedAdditionalItems = 0;
- vector <IndexTarget*>::const_iterator Target;
- for (Target = IndexTargets->begin();
- Target != IndexTargets->end();
+ for (std::vector <IndexTarget>::const_iterator Target = IndexTargets.begin();
+ Target != IndexTargets.end();
++Target)
{
bool trypdiff = _config->FindB("Acquire::PDiffs", true);
if (verify == true)
{
- if (TransactionManager->MetaIndexParser->Exists((*Target)->MetaKey) == false)
+ if (TransactionManager->MetaIndexParser->Exists(Target->MetaKey) == false)
{
// optional targets that we do not have in the Release file are skipped
- if ((*Target)->IsOptional)
+ if (Target->IsOptional)
continue;
Status = StatAuthError;
- strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+ strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), Target->MetaKey.c_str());
return;
}
- if (RealFileExists(GetFinalFileNameFromURI((*Target)->URI)))
+ if (RealFileExists(GetFinalFileNameFromURI(Target->URI)))
{
if (TransactionManager->LastMetaIndexParser != NULL)
{
- HashStringList const newFile = GetExpectedHashesFromFor(TransactionManager->MetaIndexParser, (*Target)->MetaKey);
- HashStringList const oldFile = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, (*Target)->MetaKey);
+ HashStringList const newFile = GetExpectedHashesFromFor(TransactionManager->MetaIndexParser, Target->MetaKey);
+ HashStringList const oldFile = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target->MetaKey);
if (newFile == oldFile)
{
// we have the file already, no point in trying to acquire it again
trypdiff = false; // no file to patch
// check if we have patches available
- trypdiff &= TransactionManager->MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index");
+ trypdiff &= TransactionManager->MetaIndexParser->Exists(Target->MetaKey + ".diff/Index");
}
// if we have no file to patch, no point in trying
- trypdiff &= RealFileExists(GetFinalFileNameFromURI((*Target)->URI));
+ trypdiff &= RealFileExists(GetFinalFileNameFromURI(Target->URI));
// no point in patching from local sources
if (trypdiff)
{
- std::string const proto = (*Target)->URI.substr(0, strlen("file:/"));
+ std::string const proto = Target->URI.substr(0, strlen("file:/"));
if (proto == "file:/" || proto == "copy:/" || proto == "cdrom:")
trypdiff = false;
}
// the download progress display (e.g. 7d 3h 42min 1s)
_("Release file for %s is expired (invalid since %s). "
"Updates for this repository will not be applied."),
- DataTarget.URI.c_str(), TimeToStr(invalid_since).c_str());
+ Target.URI.c_str(), TimeToStr(invalid_since).c_str());
if (ErrorText.empty())
ErrorText = errmsg;
return _error->Error("%s", errmsg.c_str());
pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner, /*{{{*/
IndexTarget const &ClearsignedTarget,
IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget,
- const vector<IndexTarget*>* const IndexTargets,
+ std::vector<IndexTarget> const IndexTargets,
indexRecords * const MetaIndexParser) :
pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets, MetaIndexParser),
ClearsignedTarget(ClearsignedTarget),
DetachedDataTarget(DetachedDataTarget), DetachedSigTarget(DetachedSigTarget)
{
// index targets + (worst case:) Release/Release.gpg
- ExpectedAdditionalItems = IndexTargets->size() + 2;
+ ExpectedAdditionalItems = IndexTargets.size() + 2;
TransactionManager->Add(this);
}
/*}}}*/
// We got an InRelease file IMSHit, but we haven't one, which means
// we had a valid Release/Release.gpg combo stepping in, which we have
// to 'acquire' now to ensure list cleanup isn't removing them
- new NoActionItem(Owner, &DetachedDataTarget);
- new NoActionItem(Owner, &DetachedSigTarget);
+ new NoActionItem(Owner, DetachedDataTarget);
+ new NoActionItem(Owner, DetachedSigTarget);
}
}
}
pkgAcqMetaBase * const TransactionManager,
IndexTarget const &DataTarget,
IndexTarget const &DetachedSigTarget,
- vector<IndexTarget*> const * const IndexTargets,
+ vector<IndexTarget> const IndexTargets,
indexRecords * const MetaIndexParser) :
pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget, MetaIndexParser),
DetachedSigTarget(DetachedSigTarget)
Desc.URI = DataTarget.URI;
// we expect more item
- ExpectedAdditionalItems = IndexTargets->size();
+ ExpectedAdditionalItems = IndexTargets.size();
QueueURI(Desc);
}
/*}}}*/
// we have a Release file, now download the Signature, all further
// verify/queue for additional downloads will be done in the
// pkgAcqMetaSig::Done() code
- new pkgAcqMetaSig(Owner, TransactionManager, &DetachedSigTarget, this);
+ new pkgAcqMetaSig(Owner, TransactionManager, DetachedSigTarget, this);
}
}
/*}}}*/
_error->Warning(_("The repository '%s' does not have a Release file. "
"This is deprecated, please contact the owner of the "
- "repository."), DataTarget.Description.c_str());
+ "repository."), Target.Description.c_str());
// No Release file was present so fall
// back to queueing Packages files without verification
/*}}}*/
std::string pkgAcqMetaIndex::DescURI() const /*{{{*/
{
- return DataTarget.URI;
+ return Target.URI;
}
/*}}}*/
// AcqMetaSig::AcqMetaSig - Constructor /*{{{*/
pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target,
+ IndexTarget const Target,
pkgAcqMetaIndex * const MetaIndex) :
pkgAcqTransactionItem(Owner, TransactionManager, Target), MetaIndex(MetaIndex)
{
- DestFile = GetPartialFileNameFromURI(Target->URI);
+ DestFile = GetPartialFileNameFromURI(Target.URI);
// remove any partial downloaded sig-file in partial/.
// it may confuse proxies and is too small to warrant a
<< TransactionManager << std::endl;
// Create the item
- Desc.Description = Target->Description;
+ Desc.Description = Target.Description;
Desc.Owner = this;
- Desc.ShortDesc = Target->ShortDesc;
- Desc.URI = Target->URI;
+ Desc.ShortDesc = Target.ShortDesc;
+ Desc.URI = Target.URI;
// If we got a hit for Release, we will get one for Release.gpg too (or obscure errors),
// so we skip the download step and go instantly to verification
{
std::string downgrade_msg;
strprintf(downgrade_msg, _("The repository '%s' is no longer signed."),
- MetaIndex->DataTarget.Description.c_str());
+ MetaIndex->Target.Description.c_str());
if(_config->FindB("Acquire::AllowDowngradeToInsecureRepositories"))
{
// meh, the users wants to take risks (we still mark the packages
else
_error->Warning(_("The data from '%s' is not signed. Packages "
"from that repository can not be authenticated."),
- MetaIndex->DataTarget.Description.c_str());
+ MetaIndex->Target.Description.c_str());
// ensures that a Release.gpg file in the lists/ is removed by the transaction
TransactionManager->TransactionStageRemoval(this, DestFile);
// AcqBaseIndex - Constructor /*{{{*/
pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target)
+ IndexTarget const Target)
: pkgAcqTransactionItem(Owner, TransactionManager, Target)
{
}
*/
pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target)
+ IndexTarget const Target)
: pkgAcqBaseIndex(Owner, TransactionManager, Target)
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
Desc.Owner = this;
- Desc.Description = Target->Description + ".diff/Index";
- Desc.ShortDesc = Target->ShortDesc;
- Desc.URI = Target->URI + ".diff/Index";
+ Desc.Description = Target.Description + ".diff/Index";
+ Desc.ShortDesc = Target.ShortDesc;
+ Desc.URI = Target.URI + ".diff/Index";
DestFile = GetPartialFileNameFromURI(Desc.URI);
return false;
}
- std::string const CurrentPackagesFile = GetFinalFileNameFromURI(Target->URI);
- HashStringList const TargetFileHashes = GetExpectedHashesFor(Target->MetaKey);
+ std::string const CurrentPackagesFile = GetFinalFileNameFromURI(Target.URI);
+ HashStringList const TargetFileHashes = GetExpectedHashesFor(Target.MetaKey);
if (TargetFileHashes.usable() == false || ServerHashes != TargetFileHashes)
{
if (Debug == true)
HashStringList LocalHashes;
// try avoiding calculating the hash here as this is costly
if (TransactionManager->LastMetaIndexParser != NULL)
- LocalHashes = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target->MetaKey);
+ LocalHashes = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target.MetaKey);
if (LocalHashes.usable() == false)
{
FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
*/
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target,
+ IndexTarget const Target,
vector<DiffInfo> const &diffs)
: pkgAcqBaseIndex(Owner, TransactionManager, Target),
available_patches(diffs)
{
- DestFile = GetPartialFileNameFromURI(Target->URI);
+ DestFile = GetPartialFileNameFromURI(Target.URI);
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
Desc.Owner = this;
- Description = Target->Description;
- Desc.ShortDesc = Target->ShortDesc;
+ Description = Target.Description;
+ Desc.ShortDesc = Target.ShortDesc;
if(available_patches.empty() == true)
{
// we are done (yeah!), check hashes against the final file
- DestFile = GetFinalFileNameFromURI(Target->URI);
+ DestFile = GetFinalFileNameFromURI(Target.URI);
Finish(true);
}
else
{
// patching needs to be bootstrapped with the 'old' version
- std::string const PartialFile = GetPartialFileNameFromURI(Target->URI);
+ std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
if (RealFileExists(PartialFile) == false)
{
if (symlink(GetFinalFilename().c_str(), PartialFile.c_str()) != 0)
if(Debug)
std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
<< "Falling back to normal index file acquire" << std::endl;
- DestFile = GetPartialFileNameFromURI(Target->URI);
+ DestFile = GetPartialFileNameFromURI(Target.URI);
RenameOnError(PDiffError);
std::string const patchname = GetDiffsPatchFileName(DestFile);
if (RealFileExists(patchname))
bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
{
// calc sha1 of the just patched file
- std::string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+ std::string const FinalFile = GetPartialFileNameFromURI(Target.URI);
if(!FileExists(FinalFile))
{
if(Debug)
std::clog << "QueueNextDiff: " << FinalFile << " (" << LocalHashes.find(NULL)->toStr() << ")" << std::endl;
- HashStringList const TargetFileHashes = GetExpectedHashesFor(Target->MetaKey);
+ HashStringList const TargetFileHashes = GetExpectedHashesFor(Target.MetaKey);
if (unlikely(LocalHashes.usable() == false || TargetFileHashes.usable() == false))
{
Failed("Local/Expected hashes are not usable", NULL);
}
// queue the right diff
- Desc.URI = Target->URI + ".diff/" + available_patches[0].file + ".gz";
+ Desc.URI = Target.URI + ".diff/" + available_patches[0].file + ".gz";
Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
- DestFile = GetPartialFileNameFromURI(Target->URI + ".diff/" + available_patches[0].file);
+ DestFile = GetPartialFileNameFromURI(Target.URI + ".diff/" + available_patches[0].file);
if(Debug)
std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
Item::Done(Message, Hashes, Cnf);
- std::string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+ std::string const FinalFile = GetPartialFileNameFromURI(Target.URI);
std::string const PatchFile = GetDiffsPatchFileName(FinalFile);
// success in downloading a diff, enter ApplyDiff state
// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/
pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target,
+ IndexTarget const Target,
DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
: pkgAcqBaseIndex(Owner, TransactionManager, Target),
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
Desc.Owner = this;
- Description = Target->Description;
- Desc.ShortDesc = Target->ShortDesc;
+ Description = Target.Description;
+ Desc.ShortDesc = Target.ShortDesc;
- Desc.URI = Target->URI + ".diff/" + patch.file + ".gz";
+ Desc.URI = Target.URI + ".diff/" + patch.file + ".gz";
Desc.Description = Description + " " + patch.file + string(".pdiff");
- DestFile = GetPartialFileNameFromURI(Target->URI + ".diff/" + patch.file);
+ DestFile = GetPartialFileNameFromURI(Target.URI + ".diff/" + patch.file);
if(Debug)
std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;
State = StateErrorDiff;
if (Debug)
std::clog << "Falling back to normal index file acquire" << std::endl;
- DestFile = GetPartialFileNameFromURI(Target->URI);
+ DestFile = GetPartialFileNameFromURI(Target.URI);
RenameOnError(PDiffError);
std::string const patchname = GetMergeDiffsPatchFileName(DestFile, patch.file);
if (RealFileExists(patchname))
Item::Done(Message, Hashes, Cnf);
- string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+ string const FinalFile = GetPartialFileNameFromURI(Target.URI);
if (State == StateFetchDiff)
{
Rename(DestFile, GetMergeDiffsPatchFileName(FinalFile, patch.file));
for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
I != allPatches->end(); ++I)
{
- std::string const PartialFile = GetPartialFileNameFromURI(Target->URI);
+ std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
std::string const patch = GetMergeDiffsPatchFileName(PartialFile, (*I)->patch.file);
unlink(patch.c_str());
}
// AcqIndex::AcqIndex - Constructor /*{{{*/
pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
pkgAcqMetaBase * const TransactionManager,
- IndexTarget const * const Target)
+ IndexTarget const Target)
: pkgAcqBaseIndex(Owner, TransactionManager, Target)
{
// autoselect the compression method
AutoSelectCompression();
- Init(Target->URI, Target->Description, Target->ShortDesc);
+ Init(Target.URI, Target.Description, Target.ShortDesc);
if(_config->FindB("Debug::Acquire::Transaction", false) == true)
std::clog << "New pkgIndex with TransactionManager "
{
std::vector<std::string> types = APT::Configuration::getCompressionTypes();
CompressionExtensions = "";
- if (TransactionManager->MetaIndexParser != NULL && TransactionManager->MetaIndexParser->Exists(Target->MetaKey))
+ if (TransactionManager->MetaIndexParser != NULL && TransactionManager->MetaIndexParser->Exists(Target.MetaKey))
{
for (std::vector<std::string>::const_iterator t = types.begin();
t != types.end(); ++t)
{
- std::string CompressedMetaKey = string(Target->MetaKey).append(".").append(*t);
+ std::string CompressedMetaKey = string(Target.MetaKey).append(".").append(*t);
if (*t == "uncompressed" ||
TransactionManager->MetaIndexParser->Exists(CompressedMetaKey) == true)
CompressionExtensions.append(*t).append(" ");
if (stat(Final.c_str(),&Buf) == 0)
msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
- if(Target->IsOptional)
+ if(Target.IsOptional)
msg += "\nFail-Ignore: true";
return msg;
{
if (CompressionExtensions.empty() == false)
{
- Init(Target->URI, Desc.Description, Desc.ShortDesc);
+ Init(Target.URI, Desc.Description, Desc.ShortDesc);
Status = StatIdle;
return;
}
}
- if(Target->IsOptional && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
+ if(Target.IsOptional && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
Status = StatDone;
else
TransactionManager->AbortTransaction();
{
// update destfile to *not* include the compression extension when doing
// a reverify (as its uncompressed on disk already)
- DestFile = GetCompressedFileName(Target->URI, GetPartialFileNameFromURI(Target->URI), CurrentCompressionExtension);
+ DestFile = GetCompressedFileName(Target.URI, GetPartialFileNameFromURI(Target.URI), CurrentCompressionExtension);
// copy FinalFile into partial/ so that we check the hash again
string FinalFile = GetFinalFilename();
// If we have compressed indexes enabled, queue for hash verification
if (_config->FindB("Acquire::GzipIndexes",false))
{
- DestFile = GetPartialFileNameFromURI(Target->URI + '.' + CurrentCompressionExtension);
+ DestFile = GetPartialFileNameFromURI(Target.URI + '.' + CurrentCompressionExtension);
EraseFileName = "";
Stage = STAGE_DECOMPRESS_AND_VERIFY;
Desc.URI = "copy:" + FileName;