X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/8757a0fdeee00ea6a7cc717188a0e129ad8a553c..422a2eba84361a8dfd84b549c13037512779c572:/apt-pkg/acquire-item.cc diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7238d692e..bf1c68d82 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include /*}}}*/ @@ -1018,6 +1019,28 @@ bool pkgAcquire::Item::IsRedirectionLoop(std::string const &NewURI) /*{{{*/ } /*}}}*/ + /*}}}*/ +int pkgAcquire::Item::Priority() /*{{{*/ +{ + // Stage 1: Meta indices and diff indices + // - those need to be fetched first to have progress reporting working + // for the rest + if (dynamic_cast(this) != nullptr + || dynamic_cast(this) != nullptr + || dynamic_cast(this) != nullptr) + return 1000; + // Stage 2: Diff files + // - fetch before complete indexes so we can apply the diffs while fetching + // larger files. + if (dynamic_cast(this) != nullptr || + dynamic_cast(this) != nullptr) + return 800; + + // Stage 3: The rest - complete index files and other stuff + return 500; +} + /*}}}*/ + pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/ pkgAcqMetaClearSig * const transactionManager, IndexTarget const &target) : pkgAcquire::Item(Owner), d(NULL), Target(target), TransactionManager(transactionManager) @@ -1340,6 +1363,23 @@ void pkgAcqMetaClearSig::QueueIndexes(bool const verify) /*{{{*/ if (hasReleaseFile && verify == false) hasHashes = std::any_of(IndexTargets.begin(), IndexTargets.end(), [&](IndexTarget const &Target) { return TransactionManager->MetaIndexParser->Exists(Target.MetaKey); }); + if (_config->FindB("Acquire::IndexTargets::Randomized", true) && likely(IndexTargets.empty() == false)) + { + /* For fallback handling and to have some reasonable progress information + we can't randomize everything, but at least the order in the same type + can be as we shouldn't be telling the mirrors (and everyone else watching) + which is native/foreign arch, specific order of preference of translations, … */ + auto range_start = IndexTargets.begin(); + std::random_device rd; + std::default_random_engine g(rd()); + do { + auto const type = range_start->Option(IndexTarget::CREATED_BY); + auto const range_end = std::find_if_not(range_start, IndexTargets.end(), + [&type](IndexTarget const &T) { return type == T.Option(IndexTarget::CREATED_BY); }); + std::shuffle(range_start, range_end, g); + range_start = range_end; + } while (range_start != IndexTargets.end()); + } for (auto&& Target: IndexTargets) { // if we have seen a target which is created-by a target this one here is declared a @@ -3279,9 +3319,8 @@ bool pkgAcqArchive::QueueNext() // Create the item Local = false; - QueueURI(Desc); - ++Vf; + QueueURI(Desc); return true; } return false; @@ -3440,7 +3479,7 @@ void pkgAcqChangelog::Init(std::string const &DestDir, std::string const &DestFi TemporaryDirectory = tmpname; ChangeOwnerAndPermissionOfFile("Item::QueueURI", TemporaryDirectory.c_str(), - SandboxUser.c_str(), "root", 0700); + SandboxUser.c_str(), ROOT_GROUP, 0700); DestFile = flCombine(TemporaryDirectory, DestFileName); if (DestDir.empty() == false) @@ -3488,7 +3527,8 @@ std::string pkgAcqChangelog::URI(pkgCache::VerIterator const &Ver) /*{{{*/ pkgCache::PkgIterator const Pkg = Ver.ParentPkg(); if (Pkg->CurrentVer != 0 && Pkg.CurrentVer() == Ver) { - std::string const basename = std::string("/usr/share/doc/") + Pkg.Name() + "/changelog"; + std::string const root = _config->FindDir("Dir"); + std::string const basename = root + std::string("usr/share/doc/") + Pkg.Name() + "/changelog"; std::string const debianname = basename + ".Debian"; if (FileExists(debianname)) return "copy://" + debianname;