chiark / gitweb /
4d797af3c99017042012ff3a46feeeb3521f30e0
[dgit.git] / tests / tstunt / Dpkg / Changelog / Parse.pm
1 # -*- perl -*-
2 #
3 # Copyright (C) 2015       Ian Jackson
4 #
5 # Some bits stolen from the proper Dpkg::Changelog::Parse
6 # (from dpkg-dev 1.16.16):
7 #
8 # Copyright (C) 2005, 2007 Frank Lichtenheld <frank@lichtenheld.de>
9 # Copyright (C) 2009       Raphael Hertzog <hertzog@debian.org>
10 #
11 #    This program is free software; you can redistribute it and/or modify
12 #    it under the terms of the GNU General Public License as published by
13 #    the Free Software Foundation; either version 3 of the License, or
14 #    (at your option) any later version.
15 #
16 #    This program is distributed in the hope that it will be useful,
17 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 #    GNU General Public License for more details.
20 #
21 #    You should have received a copy of the GNU General Public License
22 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24 package Dpkg::Changelog::Parse;
25
26 use strict;
27 use warnings;
28
29 our $VERSION = "1.00";
30
31 use Dpkg::Control::Changelog;
32
33 use base qw(Exporter);
34 our @EXPORT = qw(changelog_parse);
35
36 sub changelog_parse {
37     my (%options) = @_; # ignored
38
39     $options{'file'} //= 'debian/changelog';
40
41     open P, "dpkg-parsechangelog -l$options{'file'} |" or die $!;
42
43     my $fields = Dpkg::Control::Changelog->new();
44     $fields->parse(\*P, "output of stunt changelog parser");
45
46     close P or die "$! $?";
47
48     return $fields;
49 }