Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/dpkg-dev/scripts/Dpkg/Changelog/Debian.pm

Issue 2411423002: Linux build: Use sysroot when calculating dependencies (Closed)
Patch Set: Update expected_deps Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright © 1996 Ian Jackson
2 # Copyright © 2005 Frank Lichtenheld <frank@lichtenheld.de>
3 # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
4 # Copyright © 2012-2013 Guillem Jover <guillem@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19 =encoding utf8
20
21 =head1 NAME
22
23 Dpkg::Changelog::Debian - parse Debian changelogs
24
25 =head1 DESCRIPTION
26
27 Dpkg::Changelog::Debian parses Debian changelogs as described in the Debian
28 policy (version 3.6.2.1 at the time of this writing). See section
29 L<"SEE ALSO"> for locations where to find this definition.
30
31 The parser tries to ignore most cruft like # or /* */ style comments,
32 CVS comments, vim variables, emacs local variables and stuff from
33 older changelogs with other formats at the end of the file.
34 NOTE: most of these are ignored silently currently, there is no
35 parser error issued for them. This should become configurable in the
36 future.
37
38 =head2 METHODS
39
40 =cut
41
42 package Dpkg::Changelog::Debian;
43
44 use strict;
45 use warnings;
46
47 our $VERSION = '1.00';
48
49 use Dpkg::Gettext;
50 use Dpkg::File;
51 use Dpkg::Changelog qw(:util);
52 use parent qw(Dpkg::Changelog);
53 use Dpkg::Changelog::Entry::Debian qw(match_header match_trailer);
54
55 use constant {
56 FIRST_HEADING => _g('first heading'),
57 NEXT_OR_EOF => _g('next heading or eof'),
58 START_CHANGES => _g('start of change data'),
59 CHANGES_OR_TRAILER => _g('more change data or trailer'),
60 };
61
62 =over 4
63
64 =item $c->parse($fh, $description)
65
66 Read the filehandle and parse a Debian changelog in it. Returns the number
67 of changelog entries that have been parsed with success.
68
69 =cut
70
71 sub parse {
72 my ($self, $fh, $file) = @_;
73 $file = $self->{reportfile} if exists $self->{reportfile};
74
75 $self->reset_parse_errors;
76
77 $self->{data} = [];
78 $self->set_unparsed_tail(undef);
79
80 my $expect = FIRST_HEADING;
81 my $entry = Dpkg::Changelog::Entry::Debian->new();
82 my @blanklines = ();
83 my $unknowncounter = 1; # to make version unique, e.g. for using as id
84
85 while (<$fh>) {
86 chomp;
87 if (match_header($_)) {
88 unless ($expect eq FIRST_HEADING || $expect eq NEXT_OR_EOF) {
89 $self->parse_error($file, $.,
90 sprintf(_g('found start of entry where expected %s'),
91 $expect), "$_");
92 }
93 unless ($entry->is_empty) {
94 push @{$self->{data}}, $entry;
95 $entry = Dpkg::Changelog::Entry::Debian->new();
96 last if $self->abort_early();
97 }
98 $entry->set_part('header', $_);
99 foreach my $error ($entry->check_header()) {
100 $self->parse_error($file, $., $error, $_);
101 }
102 $expect= START_CHANGES;
103 @blanklines = ();
104 } elsif (m/^(;;\s*)?Local variables:/io) {
105 last; # skip Emacs variables at end of file
106 } elsif (m/^vim:/io) {
107 last; # skip vim variables at end of file
108 } elsif (m/^\$\w+:.*\$/o) {
109 next; # skip stuff that look like a CVS keyword
110 } elsif (m/^\# /o) {
111 next; # skip comments, even that's not supported
112 } elsif (m{^/\*.*\*/}o) {
113 next; # more comments
114 } elsif (m/^(\w+\s+\w+\s+\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\s+[\w\s]*\d{4}) \s+(.*)\s+(<|\()(.*)(\)|>)/o
115 || m/^(\w+\s+\w+\s+\d{1,2},?\s*\d{4})\s+(.*)\s+(<|\()(.*)(\)|>) /o
116 || m/^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)\;?/io
117 || m/^([\w.+-]+)(-| )(\S+) Debian (\S+)/io
118 || m/^Changes from version (.*) to (.*):/io
119 || m/^Changes for [\w.+-]+-[\w.+-]+:?\s*$/io
120 || m/^Old Changelog:\s*$/io
121 || m/^(?:\d+:)?\w[\w.+~-]*:?\s*$/o) {
122 # save entries on old changelog format verbatim
123 # we assume the rest of the file will be in old format once we
124 # hit it for the first time
125 $self->set_unparsed_tail("$_\n" . file_slurp($fh));
126 } elsif (m/^\S/) {
127 $self->parse_error($file, $., _g('badly formatted heading line'), "$ _");
128 } elsif (match_trailer($_)) {
129 unless ($expect eq CHANGES_OR_TRAILER) {
130 $self->parse_error($file, $.,
131 sprintf(_g('found trailer where expected %s'), $expect), "$_ ");
132 }
133 $entry->set_part('trailer', $_);
134 $entry->extend_part('blank_after_changes', [ @blanklines ]);
135 @blanklines = ();
136 foreach my $error ($entry->check_trailer()) {
137 $self->parse_error($file, $., $error, $_);
138 }
139 $expect = NEXT_OR_EOF;
140 } elsif (m/^ \-\-/) {
141 $self->parse_error($file, $., _g('badly formatted trailer line'), "$ _");
142 } elsif (m/^\s{2,}(\S)/) {
143 unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) {
144 $self->parse_error($file, $., sprintf(_g('found change data' .
145 ' where expected %s'), $expect), "$_");
146 if ($expect eq NEXT_OR_EOF and not $entry->is_empty) {
147 # lets assume we have missed the actual header line
148 push @{$self->{data}}, $entry;
149 $entry = Dpkg::Changelog::Entry::Debian->new();
150 $entry->set_part('header', 'unknown (unknown' . ($unknowncou nter++) . ') unknown; urgency=unknown');
151 }
152 }
153 # Keep raw changes
154 $entry->extend_part('changes', [ @blanklines, $_ ]);
155 @blanklines = ();
156 $expect = CHANGES_OR_TRAILER;
157 } elsif (!m/\S/) {
158 if ($expect eq START_CHANGES) {
159 $entry->extend_part('blank_after_header', $_);
160 next;
161 } elsif ($expect eq NEXT_OR_EOF) {
162 $entry->extend_part('blank_after_trailer', $_);
163 next;
164 } elsif ($expect ne CHANGES_OR_TRAILER) {
165 $self->parse_error($file, $.,
166 sprintf(_g('found blank line where expected %s'), $expect));
167 }
168 push @blanklines, $_;
169 } else {
170 $self->parse_error($file, $., _g('unrecognized line'), "$_");
171 unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) {
172 # lets assume change data if we expected it
173 $entry->extend_part('changes', [ @blanklines, $_]);
174 @blanklines = ();
175 $expect = CHANGES_OR_TRAILER;
176 }
177 }
178 }
179
180 unless ($expect eq NEXT_OR_EOF) {
181 $self->parse_error($file, $., sprintf(_g('found eof where expected %s'),
182 $expect));
183 }
184 unless ($entry->is_empty) {
185 push @{$self->{data}}, $entry;
186 }
187
188 return scalar @{$self->{data}};
189 }
190
191 1;
192 __END__
193
194 =back
195
196 =head1 SEE ALSO
197
198 Dpkg::Changelog
199
200 Description of the Debian changelog format in the Debian policy:
201 L<http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog>.
202
203 =head1 AUTHORS
204
205 Frank Lichtenheld, E<lt>frank@lichtenheld.deE<gt>
206 Raphaël Hertzog, E<lt>hertzog@debian.orgE<gt>
207
208 =cut
OLDNEW
« no previous file with comments | « third_party/dpkg-dev/scripts/Dpkg/Changelog.pm ('k') | third_party/dpkg-dev/scripts/Dpkg/Changelog/Entry.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698