blib/lib/CPANPLUS/Dist/Mageia.pm

filter: Statementstmt 19.9% 57 / 286 Branchbran 0.0% 0 / 60 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 56.6% 17 / 30 Podpod 100% 5 / 5 totaltotal 20.2% 79 / 391 CC 39 SCAR 42.1
CC
39
Cov
16%
prepare
210.0
_module_summary
90.0
format_available
42.0
CRAP 67.2
↑ Summary Build »
1 #
2 # This file is part of CPANPLUS-Dist-Mageia
3 #
4 # This software is copyright (c) 2011 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package CPANPLUS::Dist::Mageia;
14 # ABSTRACT: a cpanplus backend to build mageia rpms
15 1 $CPANPLUS::Dist::Mageia::VERSION = '2.102';
16 1 ▶use base 'CPANPLUS::Dist::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use CPANPLUS::Error; # imported subs: error(), msg()
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use File::Basename qw{ basename dirname };
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use File::Copy qw{ copy };
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use File::ShareDir qw{ dist_dir };
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use File::Slurp qw{ slurp };
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use IPC::Cmd qw{ run can_run };
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use List::Util qw{ first };
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use List::MoreUtils qw{ uniq };
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Pod::POM;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Pod::POM::View::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32  
33 1 my @RPMSUBDIRS = qw{ build rpm source spec srcrpm };
34 1 my %RPMDIR = map {do { chomp(my $d=qx[ rpm --eval %_${_}dir ]); $_, $d; }} @RPMSUBDIRS ;
35  
36 # -- class methods
37  
38  
39 sub format_available {
40 # check mageia release file
41 0 ▶ if ( ! -f '/etc/mageia-release' ) {
Subroutine format_available: not called CC=6 SCAR=37.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless (-f "/etc/mageia-release") 0 0 0
42 0 error( 'not on a mageia system' );
43 0 return;
44 }
45  
46 0 my $flag;
47  
48 # check rpm tree structure
49 0 foreach my $subdir ( keys %RPMDIR ) {
50 0 my $dir = "$RPMDIR{$subdir}";
51 0 ▶ next if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 0 0 0
52 0 error( "missing directory '$dir'" );
53 0 $flag++;
54 }
55  
56 # check prereqs
57 0 for my $prog ( qw[ rpm rpmbuild gcc ] ) {
58 0 ▶ next if can_run($prog);
Branch: 1 branch
BranchTrueFalseTotal
if can_run($prog) 0 0 0
59 0 error( "'$prog' is a required program to build mageia packages" );
60 0 $flag++;
61 }
62  
63 0 return not $flag;
64 }
65  
66  
67 # -- public methods
68  
69  
70 sub init {
71 0 ▶ my ($self) = @_;
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
72 0 my $status = $self->status; # an Object::Accessor
73 # distname: Foo-Bar
74 # distvers: 1.23
75 # extra_files: qw[ /bin/foo /usr/bin/bar ]
76 # rpmname: perl-Foo-Bar
77 # rpmpath: $RPMDIR/RPMS/noarch/perl-Foo-Bar-1.23-1mga2008.0.noarch.rpm
78 # rpmvers: 1
79 # srpmpath: $RPMDIR/SRPMS/perl-Foo-Bar-1.23-1mga2008.0.src.rpm
80 # specpath: $RPMDIR/SPECS/perl-Foo-Bar.spec
81 0 $status->mk_accessors(qw[ distname distvers extra_files rpmname rpmpath
82 rpmvers srpmpath specpath ]);
83  
84 0 return 1;
85 }
86  
87  
88  
89 sub prepare {
90 0 ▶ my ($self, %args) = @_;
Subroutine prepare: not called CC=14 SCAR=53.5
Pod documented
91 0 my $status = $self->status; # private hash
92 0 my $module = $self->parent; # CPANPLUS::Module
93 0 my $intern = $module->parent; # CPANPLUS::Internals
94 0 my $conf = $intern->configure_object; # CPANPLUS::Configure
95 0 my $distmm = $module->status->dist_cpan; # CPANPLUS::Dist::MM
96  
97 # parse args.
98 0 my %opts = (
99 force => $conf->get_conf('force'), # force rebuild
100 perl => $^X,
101 verbose => $conf->get_conf('verbose'),
102 %args,
103 );
104  
105 # dry-run with makemaker: find build prereqs.
106 0 msg( "dry-run prepare with makemaker..." );
107 0 $self->SUPER::prepare( %args );
108  
109 # compute & store package information
110 0 my $distname = $module->package_name;
111 0 $status->distname( $distname );
112 0 my $distvers = $module->package_version;
113 0 my $distext = $module->package_extension;
114 0 my $distsummary = _module_summary($module);
115 0 my $distdescr = _module_description($module);
116 #my $distlicense =
117 0 my ($disttoplevel) = $module->name=~ /([^:]+)::/;
118 0 my @reqs = sort keys %{ $module->status->prereqs };
119  
120 0 my ($distbuild, $distmaker, $distinstall);
121 0 ▶ if (-e _path_to_makefile_pl($module)) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e _path_to_makefile_pl($module)) { } 0 0 0
122 0 ▶ push @reqs, 'Module::Build::Compat' if _is_module_build_compat($module);
Branch: 1 branch
BranchTrueFalseTotal
if _is_module_build_compat($module) 0 0 0
123 0 $distbuild = "%{__perl} Makefile.PL INSTALLDIRS=vendor\n";
124 0 $distmaker = "%make";
125 0 $distinstall = "%makeinstall_std";
126 } else {
127 # module::build only distribution
128 # The double dashes ("--") are for Module::Build::Tiny compatibility:
129 # * https://rt.cpan.org/Ticket/Display.html?id=86240
130 # * https://wiki.mageia.org/en/Perl_policy
131 0 push @reqs, 'Module::Build';
132 0 $distbuild = "%{__perl} Build.PL --installdirs=vendor\n";
133 0 $distmaker = "./Build";
134 0 $distinstall = "./Build install --destdir=%{buildroot}";
135 }
136 0 my $distbreqs = join "\n", map { "BuildRequires: perl($_)" }
137 0 grep { $_ ne "perl" } @reqs;
138 my @docfiles =
139 uniq
140 grep {
141 0 ▶ ( /^[A-Z.]+$/ && !/^MANIFEST/ ) ||
Branch: 1 branch
BranchTrueFalseTotal
/^[A-Z.]+$/ and not /^MANIFEST/ or /^(Change(s|log)|META.(json|yml)|(ex|s)amples?|e[gx]|demos?)$/i 0 0 0
Condition0%0/3
/^[A-Z.]+$/ and not /^MANIFEST/
!ll&&!rl&&r
000
MC/DC0%0/2
/^[A-Z.]+$/ and not /^MANIFEST/
/^[A-Z.]+$/ not /^MANIFEST/
Truth table0%0/3
A and not(B)
A= /^[A-Z.]+$/B= not /^MANIFEST/
ABresult
0X0
100
111
142 m{^(Change(s|log)|META.(json|yml)|(ex|s)amples?|e[gx]|demos?)$}i
143 }
144 0 map { basename $_ }
145 0 grep { m!^[^/]+/[^/]+$! } # only interested in root files
146 0 @{ $module->status->files };
147 my $distarch =
148 0 ▶ defined( first { /\.(c|xs)$/i } @{ $module->status->files } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined &first(sub { /\.(c|xs)$/i; } , @{$module->status->files;}) ? : 0 0 0
149 ? 'BuildRequires: perl-devel'
150 : 'BuildArch: noarch';
151  
152 0 my $rpmname = _mk_pkg_name($distname);
153 0 $status->rpmname( $rpmname );
154  
155  
156 # check whether package has been build.
157 0 ▶ if ( my $pkg = $self->_has_been_build($rpmname, $distvers) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pkg = $self->_has_been_build($rpmname, $distvers)) { } 0 0 0
158 0 my $modname = $module->module;
159 0 msg( "already created package for '$modname' at '$pkg'" );
160  
161 0 ▶ if ( not $opts{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"force"}) 0 0 0
162 0 msg( "won't re-spec package since --force isn't in use" );
163 # c::d::mga store
164 0 $status->rpmpath($pkg); # store the path of rpm
165 # cpanplus api
166 0 $status->prepared(1);
167 0 $status->created(1);
168 0 $status->dist($pkg);
169 0 return $pkg;
170 # XXX check if it works
171 }
172  
173 0 msg( '--force in use, re-specing anyway' );
174 # FIXME: bump rpm version
175 } else {
176 0 msg( "writing specfile for '$distname'..." );
177 }
178  
179 # compute & store path of specfile.
180 0 my $spec = "$RPMDIR{spec}/$rpmname.spec";
181 0 $status->specpath($spec);
182  
183 0 my $vers = $module->version;
184  
185 # writing the spec file.
186 0 my $tmpl = _template_spec_file_path();
187 0 ▶ open my $tmplfh, '<', $tmpl or die "can't open '$tmpl': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $tmplfh, "<", $tmpl or die "can't open '${tmpl}': $!" 0 0 0
188  
189 0 POSIX::setlocale(&POSIX::LC_ALL, 'C');
190 0 my $specfh;
191 0 ▶ if ( not open $specfh, '>', $spec ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $specfh, ">", $spec) 0 0 0
192 0 error( "can't open '$spec': $!" );
193 0 return;
194 }
195 0 ▶ while ( defined( my $line = <$tmplfh> ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $tmplfh)) 0 0 0
196 0 ▶ last if $line =~ /^__END__$/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^__END__$/ 0 0 0
197  
198 0 $line =~ s/DISTNAME/$distname/;
199 0 $line =~ s/DISTVERS/$distvers/g;
200 0 $line =~ s/DISTSUMMARY/$distsummary/;
201 0 $line =~ s/DISTEXTENSION/$distext/;
202 0 $line =~ s/DISTBUILDBUILDER/$distbuild/;
203 0 $line =~ s/DISTINSTALL/$distinstall/;
204 0 $line =~ s/DISTARCH/$distarch/;
205 0 $line =~ s/DISTMAKER/$distmaker/;
206 0 $line =~ s/DISTBUILDREQUIRES/$distbreqs/;
207 0 $line =~ s/DISTDESCR/$distdescr/;
208 0 ▶ $line =~ s/DISTDOC/@docfiles ? "%doc @docfiles" : ''/e;
Branch: 1 branch
BranchTrueFalseTotal
@docfiles ? : 0 0 0
209 0 $line =~ s/DISTTOPLEVEL/$disttoplevel/;
210 0 ▶ $line =~ s/DISTEXTRA/join( "\n", @{ $status->extra_files || [] })/e;
Branch: 1 branch
BranchTrueFalseTotal
$status->extra_files or [] 0 0 0
211 0 $line =~ s/DISTDATE/POSIX::strftime("%a %b %d %Y", localtime())/e;
212  
213 0 print $specfh $line;
214 }
215 0 close $specfh;
216  
217 # copy package.
218 0 my $basename = basename $module->status->fetch;
219 0 my $tarball = "$RPMDIR{source}/$basename";
220 0 copy( $module->status->fetch, $tarball );
221  
222 0 msg( "specfile for '$distname' written" );
223 # return success
224 0 $status->prepared(1);
225 0 return 1;
226 }
227  
228  
229  
230 sub create {
231 0 ▶ my ($self, %args) = @_;
Subroutine create: not called CC=6 SCAR=37.4
Pod documented
232 0 my $status = $self->status; # private hash
233 0 my $module = $self->parent; # CPANPLUS::Module
234 0 my $intern = $module->parent; # CPANPLUS::Internals
235 0 my $conf = $intern->configure_object; # CPANPLUS::Configure
236 0 my $distmm = $module->status->dist_cpan; # CPANPLUS::Dist::MM
237  
238 # parse args.
239 0 my %opts = (
240 force => $conf->get_conf('force'), # force rebuild
241 perl => $^X,
242 verbose => $conf->get_conf('verbose'),
243 %args,
244 );
245  
246 # check if we need to rebuild package.
247 0 ▶ if ( $status->created && defined $status->dist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status->created and defined $status->dist) 0 0 0
Condition0%0/3
$status->created and defined $status->dist
!ll&&!rl&&r
000
MC/DC0%0/2
$status->created and defined $status->dist
$status->created defined $status->dist
Truth table0%0/3
A and B
A= $status->createdB= defined $status->dist
ABresult
0X0
100
111
248 0 ▶ if ( not $opts{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"force"}) 0 0 0
249 0 msg( "won't re-build package since --force isn't in use" );
250 0 return $status->dist;
251 }
252 0 msg( '--force in use, re-building anyway' );
253 }
254  
255 RPMBUILD: {
256 # dry-run with makemaker: handle prereqs.
257 0 msg( 'dry-run build with makemaker...' );
258 0 $self->SUPER::create( %args );
259  
260  
261 0 my $spec = $status->specpath;
262 0 my $distname = $status->distname;
263 0 my $rpmname = $status->rpmname;
264  
265 0 msg( "building '$distname' from specfile..." );
266  
267 # dry-run, to see if we forgot some files
268 0 my ($buffer, $success);
269 DRYRUN: {
270 0 local $ENV{LC_ALL} = 'C';
271 $success = run(
272 command => "rpmbuild -ba --quiet $spec",
273 verbose => $opts{verbose},
274 0 buffer => \$buffer,
275 );
276 }
277  
278 # check if the dry-run finished correctly
279 0 ▶ if ( $success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) 0 0 0
280 0 my ($rpm) = (sort glob "$RPMDIR{rpm}/*/$rpmname-*.rpm")[0];
281 0 my ($srpm) = (sort glob "$RPMDIR{srcrpm}/$rpmname-*.src.rpm")[-1];
282 0 msg( "rpm created successfully: $rpm" );
283 0 msg( "srpm available: $srpm" );
284 # c::d::mga store
285 0 $status->rpmpath($rpm);
286 0 $status->srpmpath($srpm);
287 # cpanplus api
288 0 $status->created(1);
289 0 $status->dist($rpm);
290 0 return $rpm;
291 }
292  
293 # unknown error, aborting.
294 0 ▶ if ( not $buffer =~ /^\s+Installed .but unpackaged. file.s. found:\n(.*)\z/ms ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer =~ /^\s+Installed .but unpackaged. file.s. found:\n(.*)\z/ms) 0 0 0
295 0 error( "failed to create mageia package for '$distname': $buffer" );
296 # cpanplus api
297 0 $status->created(0);
298 0 return;
299 }
300  
301 # additional files to be packaged
302 0 msg( "extra files installed, fixing spec file" );
303 0 my $files = $1;
304 0 $files =~ s/^\s+//mg; # remove spaces
305 0 my @files = split /\n/, $files;
306 0 $status->extra_files( \@files );
307 0 $self->prepare( %opts, force => 0 );
308 0 msg( 'restarting build phase' );
309 0 redo RPMBUILD;
310 }
311 }
312  
313  
314  
315 sub install {
316 0 ▶ my ($self, %args) = @_;
Subroutine install: not called CC=3 SCAR=24.8
Pod documented
317 0 my $status = $self->status; # private hash
318 0 my $module = $self->parent; # CPANPLUS::Module
319 0 my $intern = $module->parent; # CPANPLUS::Internals
320 0 my $conf = $intern->configure_object; # CPANPLUS::Configure
321 0 my $distmm = $module->status->dist_cpan; # CPANPLUS::Dist::MM
322  
323 # parse args.
324 0 my %opts = (
325 verbose => $conf->get_conf('verbose'),
326 %args,
327 );
328  
329  
330 0 my $rpm = $self->status->rpmpath;
331 0 msg( "installing $rpm" );
332  
333 # install the rpm
334 # sudo is used, which means sudoers should be properly configured.
335 0 my ($buffer, $success);
336 INSTALL: {
337 0 local $ENV{LC_ALL} = 'C';
338 0 ▶ my $sudo = $> == 0 ? '' : 'sudo';
Branch: 1 branch
BranchTrueFalseTotal
$> == 0 ? : 0 0 0
339 $success = run(
340 command => "$sudo rpm -Uv $rpm",
341 verbose => $opts{verbose},
342 0 buffer => \$buffer,
343 );
344 }
345  
346 # check if the install finished correctly
347 0 ▶ if ( $success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) { } 0 0 0
348 0 msg("successfully installed $rpm");
349 0 $status->installed(1);
350 } else {
351 0 error("error while installing $rpm");
352 }
353 }
354  
355  
356 # -- private methods
357  
358 #
359 # my $bool = $self->_has_been_build;
360 #
361 # return true if there's already a package build for this module.
362 #
363 sub _has_been_build {
364 0 ▶ my ($self, $name, $vers) = @_;
Subroutine _has_been_build: not called CC=1 SCAR=6.9
365 0 my $pkg = ( sort glob "$RPMDIR{rpm}/*/$name-$vers-*.rpm" )[-1];
366 0 return $pkg;
367 # FIXME: should we check cooker?
368 }
369  
370  
371 # -- private subs
372  
373 #
374 # my $path = _path_to_makefile_pl();
375 #
376 # return the path to the extracted makefile.pl
377 #
378 sub _path_to_makefile_pl {
379 0 ▶ my $module = shift;
Subroutine _path_to_makefile_pl: not called CC=1 SCAR=6.9
380 0 return $module->_status->extract . '/Makefile.PL';
381 }
382  
383  
384 #
385 # my $bool = _is_module_build_compat();
386 #
387 # return true if shipped makefile.pl is auto-generated with
388 # module::build::compat usage.
389 #
390 sub _is_module_build_compat {
391 0 ▶ my ($module) = @_;
Subroutine _is_module_build_compat: not called CC=1 SCAR=6.9
392 0 my $makefile = _path_to_makefile_pl($module);
393 0 my $content = slurp($makefile);
394 0 return $content =~ /Module::Build::Compat/;
395 }
396  
397  
398 #
399 # my $path = _template_spec_file_path();
400 #
401 # return the absolute path where the template spec will be located.
402 #
403 sub _template_spec_file_path {
404 0 ▶ my $path = dist_dir('CPANPLUS-Dist-Mageia');
Subroutine _template_spec_file_path: not called CC=1 SCAR=6.9
405 0 return "$path/template.spec";
406 }
407  
408  
409 #
410 # my $name = _mk_pkg_name($dist);
411 #
412 # given a distribution name, return the name of the mageia rpm
413 # package. in most cases, it will be the same, but some pakcage name
414 # will be too long as a rpm name: we'll have to cut it.
415 #
416 sub _mk_pkg_name {
417 0 ▶ my ($dist) = @_;
Subroutine _mk_pkg_name: not called CC=1 SCAR=6.9
418 0 my $name = 'perl-' . $dist;
419 0 return $name;
420 }
421  
422  
423  
424 #
425 # my $description = _module_description($module);
426 #
427 # given a cpanplus::module, try to extract its description from the
428 # embedded pod in the extracted files. this would be the first paragraph
429 # of the DESCRIPTION head1.
430 #
431 sub _module_description {
432 0 ▶ my ($module) = @_;
Subroutine _module_description: not called CC=6 SCAR=37.4
433  
434 0 my $path = dirname $module->_status->extract; # where tarball has been extracted
435 my @docfiles =
436 0 map { "$path/$_" } # prepend extract directory
437 0 sort { length $a <=> length $b } # sort by length: we prefer top-level module description
438 0 grep { /\.(pod|pm)$/ } # filter out those that can contain pod
439 0 @{ $module->_status->files }; # list of embedded files
440  
441 # parse file, trying to find a header
442 0 my $parser = Pod::POM->new;
443 DOCFILE:
444 0 foreach my $docfile ( @docfiles ) {
445 0 my $pom = $parser->parse_file($docfile); # try to find some pod
446 0 ▶ next DOCFILE unless defined $pom; # the file may contain no pod, that's ok
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pom 0 0 0
447 HEAD1:
448 0 foreach my $head1 ($pom->head1) {
449 0 ▶ next HEAD1 unless $head1->title eq 'DESCRIPTION';
Branch: 1 branch
BranchTrueFalseTotal
unless $head1->title eq "DESCRIPTION" 0 0 0
450 0 my $pom = $head1->content; # get pod for DESCRIPTION paragraph
451 0 my $text = $pom->present('Pod::POM::View::Text'); # transform pod to text
452 0 my @paragraphs = split /\n\n/, $text; # split into paragraphs
453 0 ▶ splice @paragraphs, 3 if @paragraphs > 3; # only the 3 first paragraphs
Branch: 1 branch
BranchTrueFalseTotal
if @paragraphs > 3 0 0 0
454 0 return join "\n\n", @paragraphs;
455 }
456 }
457  
458 0 return '';
459 }
460  
461  
462 #
463 # my $summary = _module_summary($module);
464 #
465 # given a cpanplus::module, return its registered description (if any)
466 # or try to extract it from the embedded pod in the extracted files.
467 #
468 sub _module_summary {
469 0 ▶ my ($module) = @_;
Subroutine _module_summary: not called CC=9 SCAR=45.0
470  
471 # registered modules won't go farther...
472 0 my $summary = $module->description;
473  
474 0 ▶ if (!$summary) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($summary) 0 0 0
475 0 my $path = dirname $module->_status->extract; # where tarball has been extracted
476 my @docfiles =
477 0 map { "$path/$_" } # prepend extract directory
478 0 sort { length $a <=> length $b } # sort by length: we prefer top-level module summary
479 0 grep { /\.(pod|pm)$/ } # filter out those that can contain pod
480 0 @{ $module->_status->files }; # list of files embedded
481  
482 # parse file, trying to find a header
483 0 my $parser = Pod::POM->new;
484 DOCFILE:
485 0 foreach my $docfile ( @docfiles ) {
486 0 my $pom = $parser->parse_file($docfile); # try to find some pod
487 0 ▶ next unless defined $pom; # the file may contain no pod, that's ok
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pom 0 0 0
488 HEAD1:
489 0 foreach my $head1 ($pom->head1) {
490 # continue till we find '=head1 NAME'
491 0 my $title = $head1->title;
492 0 ▶ next HEAD1 unless $title eq 'NAME';
Branch: 1 branch
BranchTrueFalseTotal
unless $title eq "NAME" 0 0 0
493 # extract the description in NAME section
494 0 my $content = $head1->content;
495 0 ▶ next DOCFILE unless $content =~ /^[^-]+ - (.*)$/m;
Branch: 1 branch
BranchTrueFalseTotal
unless $content =~ /^[^-]+ - (.*)$/m 0 0 0
496 0 ▶ $summary = $1 if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
497 }
498 }
499 }
500  
501 0 ▶ if (!$summary) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($summary) 0 0 0
502 0 $summary = 'no summary found';
503 }
504  
505 # summary must begin with an uppercase, without any final dot
506 # (this is a rpmlint policy)
507 0 $summary =~ s/^(.)/\u$1/;
508 0 $summary =~ s/\.$//;
509  
510 0 return $summary;
511 }
512  
513 1 1;
514  
515 __END__
↑ Summary Build »