From c845d4ffaf1c2bedb43e1bcb16896d9722db735b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Nov 2010 14:25:29 +0100 Subject: doc/examples/configure-index: updated to include apt::changelogs::server --- doc/examples/configure-index | 97 ++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'doc/examples') diff --git a/doc/examples/configure-index b/doc/examples/configure-index index c4c2acb64..ef4cff8a1 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -114,54 +114,61 @@ APT // does a ExecFork) Keep-Fds {}; + Changelogs + { + // server the provides the changelogs, the code will automatically + // append "/changelogs/pool/%s/%s/%s/%s_%s/changelog" to the uri + Server "http://packages.debian.org/"; + }: + // control parameters for cron jobs by /etc/cron.daily/apt Periodic { - BackupArchiveInterval "0"; - // - Backup after n-days if archive contents changed.(0=disable) - - BackupLevel "3"; - // - Backup level.(0=disable), 1 is invalid. - - // APT::Archives::MaxAge "0"; (old, deprecated) - MaxAge "0"; // (new) - // - Set maximum allowed age of a cache package file. If a cache - // package file is older it is deleted (0=disable) - - // APT::Archives::MinAge "2"; (old, deprecated) - MinAge "2"; // (new) - // - Set minimum age of a package file. If a file is younger it - // will not be deleted (0=disable). Usefull to prevent races - // and to keep backups of the packages for emergency. - - // APT::Archives::MaxSize "0"; (old, deprecated) - MaxSize "0"; // (new) - // - Set maximum size of the cache in MB (0=disable). If the cache - // is bigger, cached package files are deleted until the size - // requirement is met (the biggest packages will be deleted - // first). - - Update-Package-Lists "0"; - // - Do "apt-get update" automatically every n-days (0=disable) - // - Download-Upgradeable-Packages "0"; - // - Do "apt-get upgrade --download-only" every n-days (0=disable) - // - Unattended-Upgrade "0"; - // - Run the "unattended-upgrade" security upgrade script - // every n-days (0=disabled) - // Requires the package "unattended-upgrades" and will write - // a log in /var/log/unattended-upgrades - // - AutocleanInterval "0"; - // - Do "apt-get autoclean" every n-days (0=disable) - - Verbose "0"; - // - Send report mail to root - // 0: no report (or null string) - // 1: progress report (actually any string) - // 2: + command outputs (remove -qq, remove 2>/dev/null, add -d) - // 3: + trace on + BackupArchiveInterval "0"; + // - Backup after n-days if archive contents changed.(0=disable) + + BackupLevel "3"; + // - Backup level.(0=disable), 1 is invalid. + + // APT::Archives::MaxAge "0"; (old, deprecated) + MaxAge "0"; // (new) + // - Set maximum allowed age of a cache package file. If a cache + // package file is older it is deleted (0=disable) + + // APT::Archives::MinAge "2"; (old, deprecated) + MinAge "2"; // (new) + // - Set minimum age of a package file. If a file is younger it + // will not be deleted (0=disable). Usefull to prevent races + // and to keep backups of the packages for emergency. + + // APT::Archives::MaxSize "0"; (old, deprecated) + MaxSize "0"; // (new) + // - Set maximum size of the cache in MB (0=disable). If the cache + // is bigger, cached package files are deleted until the size + // requirement is met (the biggest packages will be deleted + // first). + + Update-Package-Lists "0"; + // - Do "apt-get update" automatically every n-days (0=disable) + // + Download-Upgradeable-Packages "0"; + // - Do "apt-get upgrade --download-only" every n-days (0=disable) + // + Unattended-Upgrade "0"; + // - Run the "unattended-upgrade" security upgrade script + // every n-days (0=disabled) + // Requires the package "unattended-upgrades" and will write + // a log in /var/log/unattended-upgrades + // + AutocleanInterval "0"; + // - Do "apt-get autoclean" every n-days (0=disable) + + Verbose "0"; + // - Send report mail to root + // 0: no report (or null string) + // 1: progress report (actually any string) + // 2: + command outputs (remove -qq, remove 2>/dev/null, add -d) + // 3: + trace on }; }; -- cgit v1.2.3-70-g09d2 From a53b07bbef4917884a8e4d7740b4d0786f029f5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Nov 2010 11:47:49 +0100 Subject: refactor/simplify changelog fetching code --- cmdline/apt-get.cc | 83 ++++++++++++++++++++++++++++---------------- doc/examples/configure-index | 7 ++-- 2 files changed, 57 insertions(+), 33 deletions(-) (limited to 'doc/examples') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 01f850aa6..a1987b977 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2733,66 +2733,89 @@ bool DoBuildDep(CommandLine &CmdL) return true; } /*}}}*/ +// GetChangelogPath - return a path pointing to a changelog file or dir /*{{{*/ +// --------------------------------------------------------------------- +/* This returns a "path" string for the changelog url construction. + * Please note that its not complete, it either needs a "/changelog" + * appended (for the packages.debian.org/changelogs site) or a + * ".changelog" (for third party sites that store the changelog in the + * pool/ next to the deb itself) + * Example return: "pool/main/a/apt/apt_0.8.8ubuntu3" + */ +string GetChangelogPath(CacheFile &Cache, + pkgCache::PkgIterator Pkg, + pkgCache::VerIterator Ver) +{ + string path; + + pkgRecords Recs(Cache); + pkgRecords::Parser &rec=Recs.Lookup(Ver.FileList()); + string srcpkg = rec.SourcePkg().empty() ? Pkg.Name() : rec.SourcePkg(); + // FIXME: deal with cases like gcc-defaults (srcver != binver) + string srcver = StripEpoch(Ver.VerStr()); + path = flNotFile(rec.FileName()); + path += srcpkg + "_" + srcver; + return path; +} + /*}}}*/ // GuessThirdPartyChangelogUri - return url /*{{{*/ // --------------------------------------------------------------------- +/* Contruct a changelog file path for third party sites that do not use + * packages.debian.org/changelogs + * This simply uses the ArchiveURI() of the source pkg and looks for + * a .changelog file there, Example for "mediabuntu": + * apt-get changelog mplayer-doc: + * http://packages.medibuntu.org/pool/non-free/m/mplayer/mplayer_1.0~rc4~try1.dsfg1-1ubuntu1+medibuntu1.changelog + */ bool GuessThirdPartyChangelogUri(CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver, string &out_uri) { - pkgRecords Recs(Cache); - pkgSourceList *SrcList = Cache.GetSourceList(); - // get the binary deb server path - pkgRecords::Parser &rec=Recs.Lookup(Ver.FileList()); - string srcpkg = rec.SourcePkg().empty() ? Pkg.Name() : rec.SourcePkg(); - // FIXME: deal with cases like gcc-defaults (srcver != binver) - string srcver = StripEpoch(Ver.VerStr()); - pkgCache::VerFileIterator Vf = Ver.FileList(); if (Vf.end() == true) return false; pkgCache::PkgFileIterator F = Vf.File(); pkgIndexFile *index; + pkgSourceList *SrcList = Cache.GetSourceList(); if(SrcList->FindIndex(F, index) == false) return false; + // get archive uri for the binary deb - string deb_uri = index->ArchiveURI(rec.FileName()); + string path_without_dot_changelog = GetChangelogPath(Cache, Pkg, Ver); + out_uri = index->ArchiveURI(path_without_dot_changelog + ".changelog"); // now strip away the filename and add srcpkg_srcver.changelog - out_uri = flNotFile(deb_uri); - out_uri += srcpkg + "_" + srcver + ".changelog"; return true; } // DownloadChangelog - Download the changelog /*{{{*/ // --------------------------------------------------------------------- -bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, pkgCache::VerIterator V, string targetfile) +bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, + pkgCache::VerIterator Ver, string targetfile) +/* Download a changelog file for the given package version to + * targetfile. This will first try the server from Apt::Changelogs::Server + * (http://packages.debian.org/changelogs by default) and if that gives + * a 404 tries to get it from the archive directly (see + * GuessThirdPartyChangelogUri for details how) + */ { string srcpkg; - string prefix; + string path; string descr; - string verstr; string server; - string path; + string changelog_uri; // data structures we need - pkgRecords Recs(CacheFile); - pkgCache::PkgIterator Pkg = V.ParentPkg(); - pkgRecords::Parser &rec=Recs.Lookup(V.FileList()); + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - // we need the the source pkg, the source version and the pool prefix - srcpkg = rec.SourcePkg().empty() ? Pkg.Name() : rec.SourcePkg(); - verstr = StripEpoch(V.VerStr()); - prefix = flNotFile(rec.FileName()); - - // make the server configurable + // make the server root configurable server = _config->Find("Apt::Changelogs::Server", - "http://packages.debian.org/"); - // ... but not the format string to avoid all possible attacks - strprintf(path, "/changelogs/%s/%s_%s/changelog", prefix.c_str(), srcpkg.c_str(), verstr.c_str()); - // queue it - string changelog_uri = server+path; + "http://packages.debian.org/changelogs"); + path = GetChangelogPath(CacheFile, Pkg, Ver); + strprintf(changelog_uri, "%s/%s/changelog", server.c_str(), path.c_str()); strprintf(descr, _("Changelog for %s (%s)"), srcpkg.c_str(), changelog_uri.c_str()); + // queue it new pkgAcqFile(&Fetcher, changelog_uri, "", 0, descr, srcpkg, "ignored", targetfile); // try downloading it, if that fails, they third-party-changelogs location @@ -2801,7 +2824,7 @@ bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, pkgCache::VerI if (!FileExists(targetfile)) { string third_party_uri; - if (GuessThirdPartyChangelogUri(CacheFile, Pkg, V, third_party_uri)) + if (GuessThirdPartyChangelogUri(CacheFile, Pkg, Ver, third_party_uri)) { strprintf(descr, _("Changelog for %s (%s)"), srcpkg.c_str(), third_party_uri.c_str()); new pkgAcqFile(&Fetcher, third_party_uri, "", 0, descr, srcpkg, "ignored", targetfile); diff --git a/doc/examples/configure-index b/doc/examples/configure-index index ef4cff8a1..b87251103 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -116,9 +116,10 @@ APT Changelogs { - // server the provides the changelogs, the code will automatically - // append "/changelogs/pool/%s/%s/%s/%s_%s/changelog" to the uri - Server "http://packages.debian.org/"; + // server the provides the changelogs, the code will assume + // the changlogs are in the pool/ under a srcpkg_ver directory + // with the name "changelog" + Server "http://packages.debian.org/changelogs"; }: // control parameters for cron jobs by /etc/cron.daily/apt -- cgit v1.2.3-70-g09d2