From a1c7206ecdae8e3b33eef406be3ac9b44190b0d8 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Tue, 18 Oct 2016 23:55:28 +0200
Subject: [PATCH] Switch from libparse-debianchangelog-perl to libdpkg-perl

The former was merged into the latter some time ago, with the main
difference being the lack of some of the output formats that are not
being used by aptitude.

This seems to have been attempted in the past, but was reverted due to
performance problems. The performance from current libdpkg-perl should
be comparable.

We use the perl module directly to avoid pulling dpkg-dev and its
dependencies.
---
 debian/control                     |  2 +-
 src/generic/apt/changelog_parse.cc | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/debian/control b/debian/control
index c4a17d58..cd114861 100644
--- a/debian/control
+++ b/debian/control
@@ -41,7 +41,7 @@ Multi-Arch: foreign
 Depends: aptitude-common (= ${source:Version}),
          ${misc:Depends},
          ${shlibs:Depends}
-Recommends: libparse-debianchangelog-perl,
+Recommends: libdpkg-perl,
             sensible-utils
 Suggests: aptitude-doc-en | aptitude-doc,
           apt-xapian-index,
diff --git a/src/generic/apt/changelog_parse.cc b/src/generic/apt/changelog_parse.cc
index 9cf1ab5b..165efe5c 100644
--- a/src/generic/apt/changelog_parse.cc
+++ b/src/generic/apt/changelog_parse.cc
@@ -18,7 +18,7 @@
 //   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 //   Boston, MA 02110-1301, USA.
 //
-// At the moment this code uses parsechangelog to convert changelogs
+// At the moment this code uses Dpkg::Changelog::Parse to convert changelogs
 // into something easier to read.
 
 #include "changelog_parse.h"
@@ -327,17 +327,18 @@ namespace aptitude
 
       std::string version_fragment;
       if(from.empty())
-	version_fragment = "--all";
+	version_fragment = "all => undef";
       else
 	{
-	  version_fragment = "-f ";
+	  version_fragment = "from => '";
 	  // Note that escaping the version is *critical*, because
 	  // it is untrusted data.
 	  version_fragment += backslash_escape_nonalnum(from);
+	  version_fragment += "'";
 	}
 
       std::string cmd =
-	cw::util::ssprintf("/usr/bin/parsechangelog --format rfc822 %s -l %s > %s 2> /dev/null",
+	cw::util::ssprintf("perl -MDpkg::Changelog::Parse -e \"print changelog_parse(format => 'rfc822', file => '%s', %s);\" > %s 2> /dev/null",
 			   version_fragment.c_str(),
 			   filename.c_str(),
 			   rval.get_name().c_str());
@@ -432,7 +433,7 @@ namespace aptitude
        *  The purpose of the queue is to ensure that aptitude only
        *  parses one changelog at a time and doesn't waste a ton of time
        *  starting new changelog parse threads and spawning copies of
-       *  parsechangelog.
+       *  Dpkg::Changelog::Parse.
        *
        *  This is a self-terminating singleton thread.
        */
-- 
2.23.0.rc1.153.gdeed80330f

