line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# debian-package-html -> generates HTML output for Debian packages and sources |
4
|
|
|
|
|
|
|
# originally written by Jose Parrella |
5
|
|
|
|
|
|
|
# this program is free for anyone to use it and modify it |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Debian::Package::HTML; |
8
|
|
|
|
|
|
|
$VERSION = "0.1"; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
49577
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
495
|
use HTML::Template; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor |
16
|
|
|
|
|
|
|
sub new { |
17
|
|
|
|
|
|
|
my ($class, @args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Bless my anonymous hash, please |
20
|
|
|
|
|
|
|
my $object = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Default null values |
23
|
|
|
|
|
|
|
%$object = ( |
24
|
|
|
|
|
|
|
"binary" => "", |
25
|
|
|
|
|
|
|
"control" => "", |
26
|
|
|
|
|
|
|
"source" => "", |
27
|
|
|
|
|
|
|
"diff" => "", |
28
|
|
|
|
|
|
|
"changes" => "" |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Get input from the constructor |
32
|
|
|
|
|
|
|
while (@args) { |
33
|
|
|
|
|
|
|
$object->{$args[0]} = $args[1] if defined($args[1]); |
34
|
|
|
|
|
|
|
shift @args; shift @args; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
die "At least a DSC file is needed!\n" unless defined($object->{control}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $object; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Main execution |
43
|
|
|
|
|
|
|
sub output { |
44
|
|
|
|
|
|
|
my ($object, @args) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Context default values |
47
|
|
|
|
|
|
|
my %context = ( |
48
|
|
|
|
|
|
|
"briefing" => "0", |
49
|
|
|
|
|
|
|
"charset" => "ISO-8859-1", |
50
|
|
|
|
|
|
|
"resultTemplate" => "result.tmpl", |
51
|
|
|
|
|
|
|
"pageStyle" => "", |
52
|
|
|
|
|
|
|
"doChecks" => "0", |
53
|
|
|
|
|
|
|
"dump" => "index.html" |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Get input from the constructor |
57
|
|
|
|
|
|
|
while (@args) { |
58
|
|
|
|
|
|
|
$context{$args[0]} = $args[1] if defined($args[1]); |
59
|
|
|
|
|
|
|
shift @args; shift @args; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my ($packageName, $packageVersion, $maintainerName, $maintainerMail); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @packageVars = parseControl ($object); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if ($context{doChecks}) { |
67
|
|
|
|
|
|
|
system("linda -v -i $object->{control} > $packageVars[0]-checks.txt"); |
68
|
|
|
|
|
|
|
system("lintian -v -i $object->{control} >> $packageVars[0]-checks.txt"); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
doTheOutput ($object, @packageVars, %context); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# parseControl: Parses control file |
75
|
|
|
|
|
|
|
sub parseControl { |
76
|
|
|
|
|
|
|
my $packageFiles = shift; |
77
|
|
|
|
|
|
|
my ($packageName, $packageVersion, $maintainerName, $maintainerMail); |
78
|
|
|
|
|
|
|
die "Couldn't FIND a proper DSC file\n" unless defined($packageFiles->{"control"}); |
79
|
|
|
|
|
|
|
open (CONTROL, $packageFiles->{"control"}) or die "Couldn't OPEN a proper DSC file\n"; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
while () { |
82
|
|
|
|
|
|
|
chomp; |
83
|
|
|
|
|
|
|
$packageName = $1 if ($_ =~ /^Source: ([\w-]+)/); |
84
|
|
|
|
|
|
|
$packageVersion = $1 if ($_ =~ /^Version: (.*)/ && !defined($packageVersion)); |
85
|
|
|
|
|
|
|
$maintainerName = $1 if ( ($_ =~ /^Maintainer: ([\w ]+) .*/) && !defined($maintainerName) ); |
86
|
|
|
|
|
|
|
$maintainerMail = $1 if ( ($_ =~ /^Maintainer: [\w ]+ \<(.+)\>/) && !defined($maintainerMail) ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
close CONTROL; |
90
|
|
|
|
|
|
|
return ($packageName, $packageVersion, $maintainerName, $maintainerMail); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# doTheOutput: Outputs HTML |
94
|
|
|
|
|
|
|
sub doTheOutput { |
95
|
|
|
|
|
|
|
my($packageFiles, $packageName, $packageVersion, $maintainerName, $maintainerMail, %context) = @_; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Call to the constructor method on $resultTemplate |
98
|
|
|
|
|
|
|
my $template = HTML::Template->new(filename => $context{resultTemplate}); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $currentDate = `date +%c`; |
101
|
|
|
|
|
|
|
chomp $currentDate; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $maintainerPlus = maintainerInfo($maintainerName); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub maintainerInfo { |
106
|
|
|
|
|
|
|
my $maintainerName = @_; |
107
|
|
|
|
|
|
|
my @maintainerParts = split(" ", $maintainerName); |
108
|
|
|
|
|
|
|
return join("+", @maintainerParts); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my @packagef; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
for (keys(%$packageFiles)) { |
114
|
|
|
|
|
|
|
push @packagef, |
115
|
|
|
|
|
|
|
{ packagefile => $packageFiles->{$_} } |
116
|
|
|
|
|
|
|
if (defined($packageFiles->{$_}) && $packageFiles->{$_} ne ""); |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$template->param( |
120
|
|
|
|
|
|
|
packageName => $packageName, |
121
|
|
|
|
|
|
|
packageVersion => $packageVersion, |
122
|
|
|
|
|
|
|
maintainerName => $maintainerName, |
123
|
|
|
|
|
|
|
maintainerMail => $maintainerMail, |
124
|
|
|
|
|
|
|
maintainerPlus => $maintainerPlus, |
125
|
|
|
|
|
|
|
pageCharset => $context{pageCharset}, |
126
|
|
|
|
|
|
|
pageStyle => $context{pageStyle}, |
127
|
|
|
|
|
|
|
packagef => \@packagef, |
128
|
|
|
|
|
|
|
date => $currentDate, |
129
|
|
|
|
|
|
|
doChecks => $context{doChecks}, |
130
|
|
|
|
|
|
|
briefing => $context{briefing} |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if (defined($context{dump}) && $context{dump} ne "") { |
134
|
|
|
|
|
|
|
no warnings; |
135
|
|
|
|
|
|
|
local *DUMPIT; |
136
|
|
|
|
|
|
|
open (DUMPIT, ">", "$context{dump}") or die "Couldn't open $context{dump} for write.\n"; |
137
|
|
|
|
|
|
|
print $template->output(print_to => *DUMPIT); |
138
|
|
|
|
|
|
|
close DUMPIT; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else { |
141
|
|
|
|
|
|
|
die "Weird argument in context's dump option. No output will be produced\n"; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Documentation |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 Debian::Package::HTML |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Debian::Package::HTML - Generates a webpage information (and Linda/Lintian checks) about a Debian binary or source package using HTML::Template |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
use strict; |
156
|
|
|
|
|
|
|
use Debian::Package::HTML; |
157
|
|
|
|
|
|
|
my $package = Debian::Package::HTML->new(%packageHash); |
158
|
|
|
|
|
|
|
$package->output(%contextHash); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 REQUIRES |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
HTML::Template |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 EXPORTS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Nothing |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 DESCRIPTION |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This module outputs a webpage using HTML::Template templates which |
171
|
|
|
|
|
|
|
resumes the information of a normal build environment for a package |
172
|
|
|
|
|
|
|
in Debian (source files, binary packages and changelogs) using |
173
|
|
|
|
|
|
|
Linda/Lintian for sanity checks. It is useful for making unified presentation |
174
|
|
|
|
|
|
|
webpages for those packages which are being sponsorized by someone in Debian. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 METHODS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 Constructor |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=over 4 |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * $object->new(%packageHash) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Constructs an $object with all information concerning the |
185
|
|
|
|
|
|
|
package, including location for binary/source files, changelogs, |
186
|
|
|
|
|
|
|
diffs, pristine sources, as well as templates, charsets and other |
187
|
|
|
|
|
|
|
settings. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Possible elements for the hash are: |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
"binary", "control", "source", "diff", "changes", each one of |
192
|
|
|
|
|
|
|
them specifying one of the five possible files generated by a |
193
|
|
|
|
|
|
|
package building process in Debian. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
"control" is mandatory. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 Output |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=over 4 |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item * $object->output(%contextHash) |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Does the actual XHTML output. Possible elements for the hash are: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
"briefing" (boolean): if TRUE, WebInfo will look for a briefing.html |
208
|
|
|
|
|
|
|
in the current directory, and will include the content in the resulting |
209
|
|
|
|
|
|
|
output. Useful for introducing commentaries without touching the final |
210
|
|
|
|
|
|
|
HTML. Defaults to FALSE. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
"charset": determines the output charset. Defaults to "ISO-8859-1". |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
"resultTemplate": specifies the location of an HTML::Template style |
215
|
|
|
|
|
|
|
template for output. This is mandatory, and defaults to "result.tmpl" |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
"pageStyle": specifies the location of a CSS file which might be |
218
|
|
|
|
|
|
|
included. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
"doChecks" (boolean): if TRUE, WebInfo will run linda and lintian over |
221
|
|
|
|
|
|
|
the control file and will generate a ${packageName}-checks.txt file which |
222
|
|
|
|
|
|
|
will be included in the final output. Defaults to FALSE. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
"dump": determines where to put the resulting HTML output. Defaults to |
225
|
|
|
|
|
|
|
index.html |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 No DSC could be found/open |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
You need to specify a DSC control file using the "control" parameter for the |
232
|
|
|
|
|
|
|
new() method. If you don't, WebInfo can't do much. The package will inform if |
233
|
|
|
|
|
|
|
the file could not be FOUND or could not be OPEN. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Please report the bugs, I'd love to work on them. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 CUSTOMIZATION |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 Template customization |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
You can customize the final output using your own HTML::Template template |
242
|
|
|
|
|
|
|
file and specifying it as a parameter for the output() method. The following |
243
|
|
|
|
|
|
|
template variable names are honored by WebInfo: |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
packageName: the name of the package |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
packageVersion: the version of the package |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
maintainerName: the name of the maintainer |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
maintainerMail: the e-mail address of the maintainer |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
maintainerPlus: a "+" separated name/surname for the maintainer (useful for |
254
|
|
|
|
|
|
|
URL searching) |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
pageCharset: the page charset (customizable in the output() method) |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
pageStyle: the CSS file (customizable in the output() method) |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
packagef: the available package files as an array reference, so HTML::Template |
261
|
|
|
|
|
|
|
should iterate over the "packagefile" variable. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
date: the date specified by the current locale |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
doChecks: a boolean variable specifying if Linda/Lintian checks were made |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
briefing: a boolean variable specifying if a briefing.html file should be included |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head2 Example template |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
An example template is in: |
272
|
|
|
|
|
|
|
http://debian.bureado.com.ve/package-info/result.tmpl |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
HTML outputs with that template and no CSS look like: |
275
|
|
|
|
|
|
|
http://debian.bureado.com.ve/falselogin/ |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=head1 EXAMPLES |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 Only a control file |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#!/usr/bin/perl |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
use strict; |
284
|
|
|
|
|
|
|
use warnings; |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
use Debian::Package::HTML; |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
my $package = Debian::Package::HTML->new( "control" => "falselogin.dsc" ); |
289
|
|
|
|
|
|
|
$package->output ( "resultTemplate" => "result.tmpl", "dump" => "index.html" ); |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head2 A complete building environment |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
#!/usr/bin/perl |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
use strict; |
296
|
|
|
|
|
|
|
use warnings; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
use Debian::Package::HTML; |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
my $package = Debian::Package::HTML->new("control" => "falselogin.dsc", |
301
|
|
|
|
|
|
|
"binary" => "falselogin.deb", |
302
|
|
|
|
|
|
|
"diff" => "falselogin.diff.gz", |
303
|
|
|
|
|
|
|
"source" => "falselogin.orig.tar.gz", |
304
|
|
|
|
|
|
|
"changes" => "falselogin.changes" |
305
|
|
|
|
|
|
|
; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
$package -> output ( "resultTemplate" => "anotherTemplate.tmpl", |
308
|
|
|
|
|
|
|
"style" => "groovy-style.css", |
309
|
|
|
|
|
|
|
"charset" => "UTF-8", |
310
|
|
|
|
|
|
|
"doChecks" => "1", |
311
|
|
|
|
|
|
|
"dump" => "firstPackage.html" |
312
|
|
|
|
|
|
|
); |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head2 Some ideas |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Well, throw the files generated by your compilations (dpkg-buildpackage, i.e.) |
317
|
|
|
|
|
|
|
in a /var/www/ served by your webserver of choice and run a small |
318
|
|
|
|
|
|
|
program using Debian::Package::HTML and a nice CSS/Template. You will have a great webpage |
319
|
|
|
|
|
|
|
for all your Debian packages, really useful if you're not yet a Developer and need |
320
|
|
|
|
|
|
|
to handle several packages with your sponsors. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 AUTHOR |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Jose Parrella (joseparrella@cantv.net) wrote the original code, then modularized and OOed the code. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Thanks go to Christian Sánchez (csanchez@unplug.org.ve) who helped with the original HTML::Template'ing |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head1 COPYRIGHT |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Copyright 2006 Jose Parrella. All rights reserved. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
333
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=head1 SEE ALSO |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
perl(1), HTML::Template. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |