3 # Copyright (C) 2015-2016 Ian Jackson
5 # Some bits stolen from the proper Dpkg::Changelog::Parse
6 # (from dpkg-dev 1.16.16):
8 # Copyright (C) 2005, 2007 Frank Lichtenheld <frank@lichtenheld.de>
9 # Copyright (C) 2009 Raphael Hertzog <hertzog@debian.org>
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.
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.
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/>.
24 package Dpkg::Changelog::Parse;
29 our $VERSION = "1.00";
31 use Dpkg::Control::Changelog;
33 use base qw(Exporter);
34 our @EXPORT = qw(changelog_parse);
36 die +(join " ", %ENV)." ?" if $ENV{'DGIT_NO_TSTUNT_CLPARSE'};
39 my (%options) = @_; # largely ignored
42 #print STDERR "CLOG PARSE ", Dumper(\%options);
44 # We can't do this because lots of things use `since' which
45 # we don't implement, and it's the test cases that arrange that
46 # the since value happens to be such that we are to print one output.
48 # foreach my $k (keys %options) {
49 # my $v = $options{$k};
50 # if ($k eq 'file') { }
51 # elsif ($k eq 'offset') { die "$v ?" unless $v <= 1; } # wtf, 1==0 ?
52 # elsif ($k eq 'count') { die "$v ?" unless $v == 1; }
53 # else { die "$k ?"; }
56 $options{'file'} //= 'debian/changelog';
58 open P, "dpkg-parsechangelog -l$options{'file'} |" or die $!;
60 my $fields = Dpkg::Control::Changelog->new();
61 $fields->parse(\*P, "output of stunt changelog parser");
63 close P or die "$! $?";