Producer/SimnowKernel.pm

filter: Statementstmt 35.4% 17 / 48 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 3 / 3 totaltotal 34.2% 25 / 73 CC 9 SCAR 29.5
CC
9
Cov
27%
get_version
30.0
produce
30.0
younger
2.0
CRAP 19.2
« Producer/Kernel.pm ↑ Summary Producer/DummyProducer.pm »
1 ## no critic (RequireUseStrict)
2 package Tapper::Producer::SimnowKernel;
3 1 our $AUTHORITY = 'cpan:TAPPER';
4 # ABSTRACT: produce preconditions for simnow kernel testing
5 1 $Tapper::Producer::SimnowKernel::VERSION = '5.0.1';
6 1 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶ use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶ use aliased 'Tapper::Config';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶ use File::stat;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 0 ▶ sub younger { stat($a)->mtime() <=> stat($b)->mtime() }
Subroutine younger: not called CC=1 SCAR=6.9
Pod documented
16  
17  
18 0 ▶ sub get_version {
Subroutine get_version: not called CC=5 SCAR=34.0
Pod documented
19 0 my ($self, $kernelbuild) = @_;
20  
21 0 my @files;
22 0 ▶ if ($kernelbuild =~ m/gz$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kernelbuild =~ /gz$/) { } 0 0 0
elsif ($kernelbuild =~ /bz2$/) { } 0 0 0
23 0 @files = qx(tar -tzf $kernelbuild);
24 } elsif ($kernelbuild =~ m/bz2$/) {
25 0 @files = qx(tar -tjf $kernelbuild);
26 } else {
27 0 die 'Can not detect type of file $kernelbuild. Supported types are tar.gz and tar.bz2';
28 }
29 0 chomp @files;
30 0 foreach my $file (@files) {
31 0 ▶ if ($file =~m|boot/vmlinuz-(.+)$|) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ m[boot/vmlinuz-(.+)$]) 0 0 0
32 0 return {version => $1};
33 }
34 }
35 }
36  
37  
38 0 ▶ sub produce {
Subroutine produce: not called CC=5 SCAR=34.0
Pod documented
39 0 my ($self, $job, $produce) = @_;
40  
41 0 my $pkg_dir = Config->subconfig->{paths}{package_dir};
42 0 my $arch = 'simnow';
43 0 my $kernel_path = $pkg_dir."/kernel";
44 0 my $version = '*';
45 0 ▶ $version .= "$produce->{version}*" if $produce->{version};
Branch: 1 branch
BranchTrueFalseTotal
if $produce->{"version"} 0 0 0
46  
47 0 my @kernelfiles = sort younger <$kernel_path/$arch/$version>;
48 0 ▶ die 'No kernel files found' if not @kernelfiles;
Branch: 1 branch
BranchTrueFalseTotal
unless @kernelfiles 0 0 0
49 0 my $kernelbuild = pop @kernelfiles;
50 0 my $retval = $self->get_version($kernelbuild);
51  
52 0 my $kernel_version = $retval->{version};
53 0 my ($kernel_major_version) = $kernel_version =~ m/(2\.\d{1,2}\.\d{1,2})/;
54 0 ($kernelbuild) = $kernelbuild =~ m|$pkg_dir/(kernel/$arch/.+)$|;
55  
56  
57 0 $retval = [
58 {
59 precondition_type => 'package',
60 filename => $kernelbuild,
61 mountfile => '/tmp/images/openSUSE11.1.hdd',
62 mountpartition => 'p1',
63 },
64 {
65 precondition_type => 'exec',
66 filename => '/bin/gen_initrd_simnow.sh',
67 options => [ $kernel_version ],
68 mountfile => '/tmp/images/openSUSE11.1.hdd',
69 mountpartition => 'p1',
70 }
71 ];
72 0 my $topic = $produce->{topic};
73 0 ▶ if (not defined $topic) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $topic) 0 0 0
74 0 $topic = "Simnow-kernel-";
75 0 ▶ $topic .= $produce->{version}."-" if $produce->{version};
Branch: 1 branch
BranchTrueFalseTotal
if $produce->{"version"} 0 0 0
76 0 $topic .= $kernel_major_version;
77 }
78 return {
79  
80 0 topic => $topic,
81 precondition_yaml => Dump(@$retval),
82 };
83 }
84  
85 1 1;
86  
87 __END__
« Producer/Kernel.pm ↑ Summary Producer/DummyProducer.pm »