summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hartwig <mandyke@gmail.com>2012-06-28 17:33:01 +0800
committerDaniel Hartwig <mandyke@gmail.com>2012-06-28 17:33:01 +0800
commitfaedc8178b90b77e030344dfc368e3fa3d88f050 (patch)
treea0eb7cd923421fc40644fda6ed01892fefd8b594
parentfcda1a118830b468929ef27a25a95d9e72939a8e (diff)
downloadaptitude-faedc8178b90b77e030344dfc368e3fa3d88f050.tar.gz
Merge changelog URI construction from apt-get
* src/generic/apt/pkg_changelog.cc: - use up-to-date changelog uri construction from apt-get using APT::Changelogs::Server * src/apt_options.cc: - drop disused Aptitude::Changelog-URL-Template * src/cmdline/cmdline_changelog.cc: - remove extraneous guess-work with source packages, which happened to also download the wrong changelog sometimes (Closes: #631464) - changelog download works with no deb-src lines, so we don't need to instruct the user to add any (Closes: #587775, #537393)
-rw-r--r--NEWS13
-rw-r--r--src/apt_options.cc7
-rw-r--r--src/cmdline/cmdline_changelog.cc60
-rw-r--r--src/generic/apt/pkg_changelog.cc51
-rw-r--r--src/generic/apt/pkg_changelog.h12
5 files changed, 36 insertions, 107 deletions
diff --git a/NEWS b/NEWS
index b14ba4f0..9362657b 100644
--- a/NEWS
+++ b/NEWS
@@ -154,6 +154,19 @@ behaviour is desirable for two reasons:
where 'any' would select only the first such
package.
+ * [all]: use up-to-date changelog uri construction from apt-get
+ using APT::Changelogs::Server
+
+ * [all]: drop disused Aptitude::Changelog-URL-Template
+
+ * [cmdline]: update to changelog logic:
+ - remove extraneous guess-work with source packages,
+ which happened to also download the wrong changelog
+ sometimes (Closes: #631464)
+ - changelog download works with no deb-src lines, so
+ we don't need to instruct the user to add any
+ (Closes: #587775, #537393)
+
- Internal changes:
* Unified the way packages are selected from command line
diff --git a/src/apt_options.cc b/src/apt_options.cc
index bfeeda5f..4f9c3ca6 100644
--- a/src/apt_options.cc
+++ b/src/apt_options.cc
@@ -290,13 +290,6 @@ option_item misc_options[]={
"cache any package files that can no longer be "
"downloaded from any archive in sources.list."),
PACKAGE "::AutoClean-After-Update", false),
- option_item(N_("URL to use to download changelogs"),
- N_("This option controls the template that's used to "
- "download changelogs from the Debian Web site. You "
- "should only need to change this if the changelogs move "
- "to a different URL."),
- PACKAGE "::Changelog-URL-Template",
- "http://cgi.debian.org/cgi-bin/get-changelog?package=%s"),
option_item(N_("Display a preview of what will be done before doing it"),
N_("If this option is enabled, then when you ask "
"aptitude to perform an install run, it will "
diff --git a/src/cmdline/cmdline_changelog.cc b/src/cmdline/cmdline_changelog.cc
index 5615cfd2..966b9273 100644
--- a/src/cmdline/cmdline_changelog.cc
+++ b/src/cmdline/cmdline_changelog.cc
@@ -331,39 +331,8 @@ void do_cmdline_changelog(const vector<string> &packages,
_error->Error(_("%s is not an official Debian package, cannot display its changelog."), input.c_str());
continue;
}
- }
-
- aptitude::cmdline::source_package p =
- aptitude::cmdline::find_source_package(package,
- source,
- sourcestr);
- // Use the source package if one was found; otherwise try to
- // use an explicit version.
- if(p.valid())
- {
- get_changelog_from_source(p.get_package(),
- p.get_version(),
- p.get_section(),
- pkg.Name(),
- filename,
- term_metrics);
- }
- else
- {
- // Fall back to string-based guessing if the version is
- // invalid.
- if(ver.end())
- {
- if(source == cmdline_version_version)
- filename = changelog_by_version(package, sourcestr, term_metrics);
- // If we don't even have a version string, leave
- // filename blank; we'll fail below.
- }
- else
- {
- get_changelog(ver, filename, term_metrics);
- }
+ get_changelog(ver, filename, term_metrics);
}
}
else
@@ -382,33 +351,6 @@ void do_cmdline_changelog(const vector<string> &packages,
filename,
term_metrics);
}
- else
- {
- // We couldn't find a real or source package with the
- // given name and version.
- //
- // If the user didn't specify a version or selected a
- // candidate and we couldn't find anything, we have no
- // recourse. But if they passed a version number, we
- // can fall back to just blindly guessing that the
- // version exists.
-
- switch(source)
- {
- case cmdline_version_cand:
- break;
-
- case cmdline_version_curr_or_cand:
- break;
-
- case cmdline_version_archive:
- break;
-
- case cmdline_version_version:
- filename = changelog_by_version(package, sourcestr, term_metrics);
- break;
- }
- }
}
if(!filename.valid())
diff --git a/src/generic/apt/pkg_changelog.cc b/src/generic/apt/pkg_changelog.cc
index 9b1caf33..d425a260 100644
--- a/src/generic/apt/pkg_changelog.cc
+++ b/src/generic/apt/pkg_changelog.cc
@@ -39,6 +39,8 @@
#include <sigc++/bind.h>
#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
#include <cwidget/generic/util/ssprintf.h>
@@ -86,12 +88,12 @@ namespace aptitude
boost::shared_ptr<changelog_info>
changelog_info::create(const std::string &source_package,
const std::string &source_version,
- const std::string &section,
+ const std::string &path,
const std::string &display_name)
{
return boost::make_shared<changelog_info>(source_package,
source_version,
- section,
+ path,
display_name);
}
@@ -117,14 +119,18 @@ namespace aptitude
const string source_version =
rec.SourceVer().empty() ? ver.VerStr() : rec.SourceVer();
+ string path;
+ path = flNotFile(rec.FileName());
+ path += source_package + "_" + StripEpoch(source_version);
+
LOG_TRACE(Loggers::getAptitudeChangelog(),
"For " << ver.ParentPkg().Name()
<< " " << ver.VerStr() << ", getting the changelog of the source package "
- << source_package << " " << source_version);
+ << source_package << " " << source_version << " from " << path);
return boost::make_shared<changelog_info>(source_package,
source_version,
- ver.Section(),
+ path,
ver.ParentPkg().Name());
}
@@ -385,8 +391,8 @@ namespace aptitude
<< req.get_info()->get_source_package()
<< ", source_version = "
<< req.get_info()->get_source_version()
- << ", section = "
- << req.get_info()->get_section()
+ << ", path = "
+ << req.get_info()->get_path()
<< ", display_name = "
<< req.get_info()->get_display_name()
<< ", download = 0x"
@@ -436,7 +442,7 @@ namespace aptitude
const string source_package(info.get_source_package());
const string source_version(info.get_source_version());
- const string section(info.get_section());
+ const string path(info.get_path());
const string name(info.get_display_name());
const string short_description = cw::util::ssprintf(_("Changelog of %s"), name.c_str());
@@ -520,34 +526,9 @@ namespace aptitude
}
}
- string realsection;
-
- if(section.find('/') != section.npos)
- realsection.assign(section, 0, section.find('/'));
- else
- realsection.assign("main");
-
- string prefix;
-
- if(source_package.size() > 3 &&
- source_package[0] == 'l' && source_package[1] == 'i' && source_package[2] == 'b')
- prefix = std::string("lib") + source_package[3];
- else
- prefix = source_package[0];
-
- string realver;
-
- if(source_version.find(':') != source_version.npos)
- realver.assign(source_version, source_version.find(':') + 1, source_version.npos);
- else
- realver = source_version;
-
- string uri = cw::util::ssprintf("http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog",
- realsection.c_str(),
- prefix.c_str(),
- source_package.c_str(),
- source_package.c_str(),
- realver.c_str());
+ string server = _config->Find("APT::Changelogs::Server",
+ "http://packages.debian.org/changelogs");
+ string uri = cw::util::ssprintf("%s/%s/changelog", server.c_str(), path.c_str());
LOG_TRACE(logger,
"Adding " << uri
<< " as a URI for the changelog of " << source_package << " " << source_version);
diff --git a/src/generic/apt/pkg_changelog.h b/src/generic/apt/pkg_changelog.h
index c79407f5..a0748177 100644
--- a/src/generic/apt/pkg_changelog.h
+++ b/src/generic/apt/pkg_changelog.h
@@ -56,7 +56,7 @@ namespace aptitude
{
const std::string source_package;
const std::string source_version;
- const std::string section;
+ const std::string path;
const std::string display_name;
public:
@@ -66,11 +66,11 @@ namespace aptitude
*/
changelog_info(const std::string &_source_package,
const std::string &_source_version,
- const std::string &_section,
+ const std::string &_path,
const std::string &_display_name)
: source_package(_source_package),
source_version(_source_version),
- section(_section),
+ path(_path),
display_name(_display_name)
{
}
@@ -78,7 +78,7 @@ namespace aptitude
static boost::shared_ptr<changelog_info>
create(const std::string &source_package,
const std::string &source_version,
- const std::string &section,
+ const std::string &path,
const std::string &display_name);
/** \brief Create a changelog_info structure that describes the
@@ -94,8 +94,8 @@ namespace aptitude
const std::string &get_source_package() const { return source_package; }
/** \brief Retrieve the name of the changelog's source version. */
const std::string &get_source_version() const { return source_version; }
- /** \brief Retrieve the section that the package is in. */
- const std::string &get_section() const { return section; }
+ /** \brief Retrieve the path string for changelog url construction. */
+ const std::string &get_path() const { return path; }
/** \brief Retrieve the display name of the changelog's package.
*
* This is the name that should be displayed to the user when,