Browse Source

get pdiff files from the same mirror as the index

In ad9416611a we fall back to asking the
original mirror (e.g. a redirector) if we do not get the expected
result. This works for the indexes, but patches are a different beast
and much simpler. Adding this fallback code here seems like overkill as
they are usually right along their Index file, so actually forward the
relevant settings to the patch items which fixes pdiff support combined
with a redirector and partial mirrors as in such a situation the pdiff
patches would be 404 and the complete index would be downloaded.
debian/1.8.y
David Kalnischkies 6 years ago
parent
commit
5832913a49
  1. 52
      apt-pkg/acquire-item.cc
  2. 34
      apt-pkg/acquire-item.h
  3. 2
      apt-pkg/acquire.cc

52
apt-pkg/acquire-item.cc

@ -1021,9 +1021,7 @@ bool pkgAcquire::Item::IsRedirectionLoop(std::string const &NewURI) /*{{{*/
return false;
}
/*}}}*/
/*}}}*/
int pkgAcquire::Item::Priority() /*{{{*/
int pkgAcquire::Item::Priority() /*{{{*/
{
// Stage 1: Meta indices and diff indices
// - those need to be fetched first to have progress reporting working
@ -2039,7 +2037,7 @@ void pkgAcqDiffIndex::QueueOnIMSHit() const /*{{{*/
{
// list cleanup needs to know that this file as well as the already
// present index is ours, so we create an empty diff to save it for us
new pkgAcqIndexDiffs(Owner, TransactionManager, Target);
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, Target.URI);
}
/*}}}*/
static bool RemoveFileForBootstrapLinking(bool const Debug, std::string const &For, std::string const &Boot)/*{{{*/
@ -2415,14 +2413,26 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
}
}
std::string indexURI = Desc.URI;
auto const byhashidx = indexURI.find("/by-hash/");
if (byhashidx != std::string::npos)
indexURI = indexURI.substr(0, byhashidx - strlen(".diff"));
else
{
auto end = indexURI.length() - strlen(".diff/Index");
if (CurrentCompressionExtension != "uncompressed")
end -= (1 + CurrentCompressionExtension.length());
indexURI = indexURI.substr(0, end);
}
if (pdiff_merge == false)
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, available_patches);
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, indexURI, available_patches);
else
{
diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
for(size_t i = 0; i < available_patches.size(); ++i)
(*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, TransactionManager,
Target,
Target, UsedMirror, indexURI,
available_patches[i],
diffs);
}
@ -2492,8 +2502,9 @@ pkgAcqDiffIndex::~pkgAcqDiffIndex()
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
std::string const &indexUsedMirror, std::string const &indexURI,
vector<DiffInfo> const &diffs)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL),
: pkgAcqBaseIndex(Owner, TransactionManager, Target), indexURI(indexURI),
available_patches(diffs)
{
DestFile = GetKeepCompressedFileName(GetPartialFileNameFromURI(Target.URI), Target);
@ -2504,6 +2515,12 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
Description = Target.Description;
Desc.ShortDesc = Target.ShortDesc;
UsedMirror = indexUsedMirror;
if (UsedMirror == "DIRECT")
UsedMirror.clear();
else if (UsedMirror.empty() == false && Description.find(" ") != string::npos)
Description.replace(0, Description.find(" "), UsedMirror);
if(available_patches.empty() == true)
{
// we are done (yeah!), check hashes against the final file
@ -2618,7 +2635,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
}
// queue the right diff
Desc.URI = Target.URI + ".diff/" + available_patches[0].file + ".gz";
Desc.URI = indexURI + ".diff/" + available_patches[0].file + ".gz";
Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
DestFile = GetKeepCompressedFileName(GetPartialFileNameFromURI(Target.URI + ".diff/" + available_patches[0].file), Target);
@ -2671,7 +2688,7 @@ void pkgAcqIndexDiffs::Done(string const &Message, HashStringList const &Hashes,
// see if there is more to download
if(available_patches.empty() == false)
{
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, available_patches);
new pkgAcqIndexDiffs(Owner, TransactionManager, Target, UsedMirror, indexURI, available_patches);
Finish();
} else {
DestFile = PatchedFile;
@ -2700,19 +2717,26 @@ pkgAcqIndexDiffs::~pkgAcqIndexDiffs() {}
pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
std::string const &indexUsedMirror, std::string const &indexURI,
DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), d(NULL),
patch(patch), allPatches(allPatches), State(StateFetchDiff)
: pkgAcqBaseIndex(Owner, TransactionManager, Target), indexURI(indexURI),
patch(patch), allPatches(allPatches), State(StateFetchDiff)
{
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
Desc.Owner = this;
Description = Target.Description;
UsedMirror = indexUsedMirror;
if (UsedMirror == "DIRECT")
UsedMirror.clear();
else if (UsedMirror.empty() == false && Description.find(" ") != string::npos)
Description.replace(0, Description.find(" "), UsedMirror);
Desc.Owner = this;
Desc.ShortDesc = Target.ShortDesc;
Desc.URI = Target.URI + ".diff/" + patch.file + ".gz";
Desc.URI = indexURI + ".diff/" + patch.file + ".gz";
Desc.Description = Description + " " + patch.file + ".pdiff";
DestFile = GetPartialFileNameFromURI(Desc.URI);
DestFile = GetPartialFileNameFromURI(Target.URI + ".diff/" + patch.file + ".gz");
if(Debug)
std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;

34
apt-pkg/acquire-item.h

@ -779,7 +779,7 @@ struct APT_HIDDEN DiffInfo { /*{{{*/
*/
class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
{
void * const d;
std::string const indexURI;
protected:
@ -830,23 +830,19 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
/** \brief Create an index merge-diff item.
*
* \param Owner The pkgAcquire object that owns this item.
*
* \param URI The URI of the package index file being
* reconstructed.
*
* \param URIDesc A long description of this item.
*
* \param ShortDesc A brief description of this item.
*
* \param TransactionManager responsible for this item
* \param Target we intend to built via pdiff patching
* \param baseURI is the URI used for the Index, but stripped down to Target
* \param DiffInfo of the patch in question
* \param patch contains infos about the patch this item is supposed
* to download which were read from the index
*
* \param allPatches contains all related items so that each item can
* check if it was the last one to complete the download step
*/
pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target, DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches) APT_NONNULL(2, 3, 6);
IndexTarget const &Target, std::string const &indexUsedMirror,
std::string const &indexURI, DiffInfo const &patch,
std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches) APT_NONNULL(2, 3, 8);
virtual ~pkgAcqIndexMergeDiffs();
};
/*}}}*/
@ -863,7 +859,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
*/
class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
{
void * const d;
std::string const indexURI;
private:
@ -943,20 +939,16 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
* \a diffs is empty, or QueueNextDiff() otherwise.
*
* \param Owner The pkgAcquire object that owns this item.
*
* \param URI The URI of the package index file being
* reconstructed.
*
* \param URIDesc A long description of this item.
*
* \param ShortDesc A brief description of this item.
*
* \param TransactionManager responsible for this item
* \param Target we want to built via pdiff patching
* \param baseURI is the URI used for the Index, but stripped down to Target
* \param diffs The remaining diffs from the index of diffs. They
* should be ordered so that each diff appears before any diff
* that depends on it.
*/
pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
IndexTarget const &Target,
std::string const &indexUsedMirror, std::string const &indexURI,
std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>()) APT_NONNULL(2, 3);
virtual ~pkgAcqIndexDiffs();
};

2
apt-pkg/acquire.cc

@ -1154,7 +1154,7 @@ APT_PURE unsigned long long pkgAcquire::Queue::QItem::GetMaximumSize() const /*{
return Maximum;
}
/*}}}*/
APT_PURE int pkgAcquire::Queue::QItem::GetPriority() const /*{{{*/
APT_PURE int pkgAcquire::Queue::QItem::GetPriority() const /*{{{*/
{
int Priority = 0;
for (auto const &O: Owners)

Loading…
Cancel
Save