diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-02-11 21:07:56 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-02-11 21:07:56 +0100 |
commit | b5aba9096e371a5f8612aff05384aca54ccc5acd (patch) | |
tree | e38b65b43b2ca80f460a69686f7eef36dffda218 /apt-pkg/acquire-item.cc | |
parent | 29f80b30c7c5a0da8544ebde6e7eb54c41171360 (diff) |
use local changelog from /usr/share/doc if possible
If pkgAcqChangelog is told to acquire the changelog for a version it
will check first if this version is installed on the disk and if so will
use the local changelog in /usr/share/doc (possibily/likely gz
compressed) instead of downloading the file from the web.
An option is provided to disable this, which is enabled by default for
the Ubuntu vendor as they truncate the local changelogs – and for apts
--print-uris action.
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r-- | apt-pkg/acquire-item.cc | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 446551cc2..2057b7287 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -3149,16 +3149,47 @@ void pkgAcqChangelog::Init(std::string const &DestDir, std::string const &DestFi /*}}}*/ std::string pkgAcqChangelog::URI(pkgCache::VerIterator const &Ver) /*{{{*/ { + std::string const confOnline = "Acquire::Changelogs::AlwaysOnline"; + bool AlwaysOnline = _config->FindB(confOnline, false); + if (AlwaysOnline == false) + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) + { + pkgCache::PkgFileIterator const PF = VF.File(); + if (PF.Flagged(pkgCache::Flag::NotSource) || PF->Release == 0) + continue; + pkgCache::RlsFileIterator const RF = PF.ReleaseFile(); + if (RF->Origin != 0 && _config->FindB(confOnline + "::Origin::" + RF.Origin(), false)) + { + AlwaysOnline = true; + break; + } + } + if (AlwaysOnline == false) + { + 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 debianname = basename + ".Debian"; + if (FileExists(debianname)) + return "copy://" + debianname; + else if (FileExists(debianname + ".gz")) + return "gzip://" + debianname + ".gz"; + else if (FileExists(basename)) + return "copy://" + basename; + else if (FileExists(basename + ".gz")) + return "gzip://" + basename + ".gz"; + } + } + char const * const SrcName = Ver.SourcePkgName(); char const * const SrcVersion = Ver.SourceVerStr(); - pkgCache::PkgFileIterator PkgFile; // find the first source for this version which promises a changelog for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) { pkgCache::PkgFileIterator const PF = VF.File(); if (PF.Flagged(pkgCache::Flag::NotSource) || PF->Release == 0) continue; - PkgFile = PF; pkgCache::RlsFileIterator const RF = PF.ReleaseFile(); std::string const uri = URI(RF, PF.Component(), SrcName, SrcVersion); if (uri.empty()) |