#! /bin/sh /usr/share/dpatch/dpatch-run
## 04_changelog.dpatch by  <egon@localhost.localdomain>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

--- a/src/apt_options.cc
+++ b/src/apt_options.cc
@@ -302,7 +302,7 @@ option_item misc_options[]={
 		 "should only need to change this if the changelogs move "
 		 "to a different URL."),
 	      "APT::Changelogs::Server",
-	      "http://metadata.ftp-master.debian.org/changelogs"),
+	      "http://changelogs.ubuntu.com/changelogs"),
   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 "
--- a/src/cmdline/cmdline_changelog.cc
+++ b/src/cmdline/cmdline_changelog.cc
@@ -292,7 +292,7 @@ void do_cmdline_changelog(const vector<s
 
   if(access("/usr/bin/sensible-pager", X_OK)!=0)
     {
-      _error->Warning(_("Can't execute sensible-pager, is this a working Debian system?"));
+      _error->Warning(_("Can't execute sensible-pager, is this a working Ubuntu system?"));
 
       pager=getenv("PAGER");
 
--- a/src/generic/apt/pkg_changelog.cc
+++ b/src/generic/apt/pkg_changelog.cc
@@ -582,14 +582,14 @@ namespace aptitude
 
 		  // WATCH: apt/cmdline/apt-get.cc(DownloadChangelog)
 		  string server = aptcfg->Find("APT::Changelogs::Server",
-					       "http://metadata.ftp-master.debian.org/changelogs");
-		  string path = cw::util::ssprintf("%s/%s/%s/%s_%s",
+                                           "http://changelogs.ubuntu.com/changelogs");
+		  string path = cw::util::ssprintf("pool/%s/%s/%s/%s_%s",
 						   realsection.c_str(),
 						   prefix.c_str(),
 						   source_package.c_str(),
 						   source_package.c_str(),
 						   realver.c_str());
-		  uri = cw::util::ssprintf("%s/%s_changelog",
+		  uri = cw::util::ssprintf("%s/%s/changelog",
 					   server.c_str(),
 					   path.c_str());
 		}
@@ -688,8 +688,7 @@ bool check_valid_origin(const pkgCache::
     {
       if (!vf.File().end() &&
 	  vf.File().Origin() &&
-	  (string("Debian") == vf.File().Origin() ||
-	   string("Debian Backports") == vf.File().Origin()))
+	  (string("Ubuntu") == vf.File().Origin()))
 	{
 	  return true;
 	}
--- a/src/view_changelog.cc
+++ b/src/view_changelog.cc
@@ -275,7 +275,7 @@ static void do_view_changelog(const stri
   string menulabel =
     ssprintf(_("Changelog of %s"), pkgname.c_str());
   string tablabel = ssprintf(_("%s changes"), pkgname.c_str());
-  string desclabel = _("View the list of changes made to this Debian package.");
+  string desclabel = _("View the list of changes made to this Ubuntu package.");
 
   cw::util::ref_ptr<aptitude::apt::changelog> changelog(aptitude::apt::parse_changelog(filename));
   cw::fragment *f = changelog.valid() ? render_changelog(changelog, curverstr) : NULL;
--- a/src/generic/apt/download_queue.cc
+++ b/src/generic/apt/download_queue.cc
@@ -870,7 +870,8 @@ namespace aptitude
 
 	if (req.get_uri().find("/changelogs/") != std::string::npos)
 	  {
-	    std::string uri_filename = req.get_uri().substr(req.get_uri().find_last_of("/") + 1);
+            auto last_slash = req.get_uri().find_last_of("/");
+	    std::string uri_filename = req.get_uri().substr(req.get_uri().find_last_of("/", last_slash - 1) + 1);
 
 	    std::regex underscore_regex("[^_]+");
 	    auto elem_begin = std::sregex_iterator(uri_filename.begin(), uri_filename.end(), underscore_regex);
