requires.PL

filter: Statementstmt 17.8% 10 / 56 Branchbran 10.0% 4 / 40 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 15.5% 16 / 103 CC 2 SCAR 8.1
CC
2
Cov
14%
END
2.9
BEGIN
1.0
CRAP 2.2
« blib/lib/LWP/Auth_UA.pm ↑ Summary blib/script/check-page »
1 1 ▶use FileHandle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 =head1 NAME
4  
5 requires.PL - work out which RPMs are being used by Link_Controller.
6  
7 =head1 DESCRIPTION
8  
9 Based on the bundle file this works out the list of RPMs that are
10 required to install Link_Controller
11  
12 =head1 BUGS
13  
14 This is rather carless about running RPM on systems which don't have
15 it but should result in an empty output file anyway.
16  
17 =cut
18  
19  
20 1 ▶END {
Subroutine END: called CC=2 SCAR=10.5
21 1 ▶ $? && do {
Branch: 1 branch
BranchTrueFalseTotal
$? and do { print STDERR "requires.PL tried to give non zero exit status: $?. Exiting zero\ninstead. This allows build to proceed even if RPM isn't present. You\nprobably don't need to worry about this unless you were trying to\nbuild an RPM of this software\n"; $? = 0 } 0 1 1
22 0 print STDERR <<EOF;
23 requires.PL tried to give non zero exit status: $?. Exiting zero
24 instead. This allows build to proceed even if RPM isn't present. You
25 probably don't need to worry about this unless you were trying to
26 build an RPM of this software
27 EOF
28 0 $? = 0;
29 };
30 }
31  
32 1 $found=0;
33 1 DIRCHECK: foreach (split /:/, $ENV{"PATH"}) {
34 10 ▶ -x $_ . '/' . 'cdbmake' && do {
Branch: 1 branch
BranchTrueFalseTotal
-x $_ . '/' . "cdbmake" and do { $found = 1; last DIRCHECK } 0 10 10
35 0 $found=1;
36 0 last DIRCHECK;
37 };
38 }
39 1 ▶unless ($found) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 1 0 1
40 1 ▶ print STDERR <<EOF unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 1 0 1
41 No rpm program found so we won't try to generate dependency file
42 EOF
43 1 exit 0;
44 }
45  
46 #It would be nice to implement this using the functions from CPAN
47 #which read the contents of a bundle but they don't seem to be
48 #stable.
49 #
50  
51 0 $bfile="lib/Bundle/Link_Controller.pm";
52 0 $verbose=0;
53 0 @result=();
54  
55 0 my $fh = FileHandle->new;
56 0 ▶open($fh,$bfile) or die "Could not open '$bfile': $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $bfile or die "Could not open '${bfile}': $!" 0 0 0
57  
58 #straight from CPAN module
59 0 ▶while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
60 0 ▶ $inpod = m/^=(?!head1\s+CONTENTS)/ ? 0 :
Branch: 2 branches
BranchTrueFalseTotal
/^=(?!head1\s+CONTENTS)/ ? : 0 0 0
/^=head1\s+CONTENTS/ ? : 0 0 0
61 m/^=head1\s+CONTENTS/ ? 1 : $inpod;
62 0 ▶ next unless $inpod;
Branch: 1 branch
BranchTrueFalseTotal
unless $inpod 0 0 0
63 0 ▶ next if /^=/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=/ 0 0 0
64 0 ▶ next if /^\s+$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s+$/ 0 0 0
65 0 chomp;
66 0 push @result, (split " ", $_, 2)[0];
67 }
68 0 close $fh;
69  
70 0 $rfile = "pkg-data-rpm/requires";
71 0 my $rfh = FileHandle->new;
72 0 ▶open($rfh,"> $rfile") or die "Could not open '$bfile': $!";
Branch: 1 branch
BranchTrueFalseTotal
open $rfh, "> $rfile" or die "Could not open '${bfile}': $!" 0 0 0
73  
74 0 my @foundrpm=();
75  
76 0 MOD: foreach my $mod (@result) {
77 0 $mod=~ s,::,/,g;
78 0 $mod .= ".pm";
79 0 foreach my $ldir (@INC) {
80 0 my $modf=$ldir . '/' . $mod;
81 0 ▶ print "try $modf\n" if $verbose & 8;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose & 8 0 0 0
82 0 ▶ -e $modf or next;
Branch: 1 branch
BranchTrueFalseTotal
-e $modf or next 0 0 0
83 0 my $pkg = `rpm -qf $modf`;
84 0 chomp $pkg;
85 0 ▶ $pkg =~ m/\s/ and do {
Branch: 1 branch
BranchTrueFalseTotal
$pkg =~ /\s/ and do { warn "didn't expect a space from rpm"; print "rpm gave $pkg\n" if $verbose & 2; next } 0 0 0
86 0 warn "didn't expect a space from rpm";
87 0 ▶ print "rpm gave $pkg\n" if $verbose & 2;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose & 2 0 0 0
88 0 next;
89 };
90 0 ▶ print "was in $pkg\n" if $verbose & 2;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose & 2 0 0 0
91 0 $pkg =~ s/-[^-]+-[^-]+$//;
92 0 ▶ $pkg && ( push @foundrpm, $pkg ) or
Branch: 1 branch
BranchTrueFalseTotal
$pkg and push @foundrpm, $pkg or warn "File $modf doesn't belong to an rpm" 0 0 0
Condition0%0/3
$pkg and push @foundrpm, $pkg
!ll&&!rl&&r
000
MC/DC0%0/2
$pkg and push @foundrpm, $pkg
$pkg push @foundrpm, $pkg
Truth table0%0/3
A and B
A= $pkgB= push @foundrpm, $pkg
ABresult
0X0
100
111
93 warn "File $modf doesn't belong to an rpm";
94 0 next MOD;
95 }
96 }
97  
98 0 push @foundrpm,
99 "cdb";
100  
101 0 my @reqrpm=sort @foundrpm;
102 0 push @reqrpm, ""; #terminator
103  
104 0 ▶for(my $i=0; $i < $#reqrpm; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#reqrpm) 0 0 0
105 0 my $reps=1;
106 0 ▶ $reps++ while ( $reqrpm[$i] eq $reqrpm[$i+$reps] );
Branch: 1 branch
BranchTrueFalseTotal
$reqrpm[$i] eq $reqrpm[$i + $reps] and do { ++$reps } 0 0 0
107 0 splice (@reqrpm, $i+1, ($reps - 1) );
108 }
109  
110 0 print $rfh join("\n", @reqrpm );
111  
« blib/lib/LWP/Auth_UA.pm ↑ Summary blib/script/check-page »