diff options
-rw-r--r-- | apt-pkg/acquire-item.cc | 35 | ||||
-rw-r--r-- | apt-pkg/init.cc | 1 | ||||
-rw-r--r-- | apt-private/private-download.cc | 2 | ||||
-rwxr-xr-x | test/integration/test-apt-get-changelog | 23 | ||||
-rw-r--r-- | vendor/ubuntu/apt.conf-01-vendor-ubuntu | 1 |
5 files changed, 60 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()) diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index c35477bf6..0dfb10978 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -120,6 +120,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.CndSet("Acquire::Changelogs::URI::Origin::Tanglu", "http://metadata.tanglu.org/changelogs/@CHANGEPATH@_changelog"); Cnf.CndSet("Acquire::Changelogs::URI::Origin::Ubuntu", "http://changelogs.ubuntu.com/changelogs/pool/@CHANGEPATH@/changelog"); Cnf.CndSet("Acquire::Changelogs::URI::Origin::Ultimedia", "http://packages.ultimediaos.com/changelogs/pool/@CHANGEPATH@/changelog.txt"); + Cnf.CndSet("Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu", true); bool Res = true; diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 6f672635f..89d0a50c7 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -246,6 +246,8 @@ bool DoChangelog(CommandLine &CmdL) bool const downOnly = _config->FindB("APT::Get::Download-Only", false); bool const printOnly = _config->FindB("APT::Get::Print-URIs", false); + if (printOnly) + _config->CndSet("Acquire::Changelogs::AlwaysOnline", true); aptAcquireWithTextStatus Fetcher; for (APT::VersionList::const_iterator Ver = verset.begin(); diff --git a/test/integration/test-apt-get-changelog b/test/integration/test-apt-get-changelog index 01b81c737..3de1c5c5c 100755 --- a/test/integration/test-apt-get-changelog +++ b/test/integration/test-apt-get-changelog @@ -7,6 +7,7 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" setupenvironment configarchitecture 'native' +buildsimplenativepackage 'dpkg' 'native' '42' 'stable' buildsimplenativepackage 'foo' 'all' '1.0' 'stable' buildsimplenativepackage 'libbar' 'all' '1.0' 'stable' @@ -105,3 +106,25 @@ testfailure test -e foo.changelog testequal "E: Failed to fetch http://localhost:${APTHTTPPORT}/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found) " aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/does/not/exist/@CHANGEPATH@/change.txt" testfailure test -e foo.changelog +cd .. + +testdpkgnotinstalled 'foo' +testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" apt changelog foo --print-uris -o Acquire::Changelogs::AlwaysOnline=false +testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" apt changelog foo --print-uris -o Acquire::Changelogs::AlwaysOnline=true + +testsuccess apt install dpkg -y +# at this moment, we still have the Releasefile claim to be origin:ubuntu +echo 'Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu "false";' >> rootdir/etc/apt/apt.conf.d/nooriginchangelogs +testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris +testsuccessequal "'gzip:///usr/share/doc/dpkg/changelog.Debian.gz' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false +testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=true +testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false -o Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu=true +testsuccessequal "'gzip:///usr/share/doc/dpkg/changelog.Debian.gz' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false -o Acquire::Changelogs::AlwaysOnline::Origin::Debian=true + +cd downloaded +testsuccess apt changelog dpkg -d +testfilestats 'dpkg.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644" +head -n 3 dpkg.changelog > dpkg.change +testfileequal 'dpkg.change' "$(apthelper cat-file '/usr/share/doc/dpkg/changelog.Debian.gz' | head -n 3)" +rm -f dpkg.change dpkg.changelog +cd .. diff --git a/vendor/ubuntu/apt.conf-01-vendor-ubuntu b/vendor/ubuntu/apt.conf-01-vendor-ubuntu index e69de29bb..44e684710 100644 --- a/vendor/ubuntu/apt.conf-01-vendor-ubuntu +++ b/vendor/ubuntu/apt.conf-01-vendor-ubuntu @@ -0,0 +1 @@ +Acquire::Changelogs::AlwaysOnline "true"; |