line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
2
|
|
|
|
|
|
|
package Tapper::Producer::SimnowKernel; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
1413
|
$Tapper::Producer::SimnowKernel::AUTHORITY = 'cpan:TAPPER'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$Tapper::Producer::SimnowKernel::VERSION = '4.1.3'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: produce preconditions for simnow kernel testing |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
551
|
use YAML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use 5.010; |
14
|
|
|
|
|
|
|
use Moose; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use aliased 'Tapper::Config'; |
17
|
|
|
|
|
|
|
use File::stat; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub younger { stat($a)->mtime() <=> stat($b)->mtime() } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_version { |
24
|
|
|
|
|
|
|
my ($self, $kernelbuild) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my @files; |
27
|
|
|
|
|
|
|
if ($kernelbuild =~ m/gz$/) { |
28
|
|
|
|
|
|
|
@files = qx(tar -tzf $kernelbuild); |
29
|
|
|
|
|
|
|
} elsif ($kernelbuild =~ m/bz2$/) { |
30
|
|
|
|
|
|
|
@files = qx(tar -tjf $kernelbuild); |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
die 'Can not detect type of file $kernelbuild. Supported types are tar.gz and tar.bz2'; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
chomp @files; |
35
|
|
|
|
|
|
|
foreach my $file (@files) { |
36
|
|
|
|
|
|
|
if ($file =~m|boot/vmlinuz-(.+)$|) { |
37
|
|
|
|
|
|
|
return {version => $1}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub produce { |
44
|
|
|
|
|
|
|
my ($self, $job, $produce) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $pkg_dir = Config->subconfig->{paths}{package_dir}; |
47
|
|
|
|
|
|
|
my $arch = 'simnow'; |
48
|
|
|
|
|
|
|
my $kernel_path = $pkg_dir."/kernel"; |
49
|
|
|
|
|
|
|
my $version = '*'; |
50
|
|
|
|
|
|
|
$version .= "$produce->{version}*" if $produce->{version}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my @kernelfiles = sort younger <$kernel_path/$arch/$version>; |
53
|
|
|
|
|
|
|
die 'No kernel files found' if not @kernelfiles; |
54
|
|
|
|
|
|
|
my $kernelbuild = pop @kernelfiles; |
55
|
|
|
|
|
|
|
my $retval = $self->get_version($kernelbuild); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $kernel_version = $retval->{version}; |
58
|
|
|
|
|
|
|
my ($kernel_major_version) = $kernel_version =~ m/(2\.\d{1,2}\.\d{1,2})/; |
59
|
|
|
|
|
|
|
($kernelbuild) = $kernelbuild =~ m|$pkg_dir/(kernel/$arch/.+)$|; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$retval = [ |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
precondition_type => 'package', |
65
|
|
|
|
|
|
|
filename => $kernelbuild, |
66
|
|
|
|
|
|
|
mountfile => '/tmp/images/openSUSE11.1.hdd', |
67
|
|
|
|
|
|
|
mountpartition => 'p1', |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
precondition_type => 'exec', |
71
|
|
|
|
|
|
|
filename => '/bin/gen_initrd_simnow.sh', |
72
|
|
|
|
|
|
|
options => [ $kernel_version ], |
73
|
|
|
|
|
|
|
mountfile => '/tmp/images/openSUSE11.1.hdd', |
74
|
|
|
|
|
|
|
mountpartition => 'p1', |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
]; |
77
|
|
|
|
|
|
|
my $topic = $produce->{topic}; |
78
|
|
|
|
|
|
|
if (not defined $topic) { |
79
|
|
|
|
|
|
|
$topic = "Simnow-kernel-"; |
80
|
|
|
|
|
|
|
$topic .= $produce->{version}."-" if $produce->{version}; |
81
|
|
|
|
|
|
|
$topic .= $kernel_major_version; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
return { |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
topic => $topic, |
86
|
|
|
|
|
|
|
precondition_yaml => Dump(@$retval), |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding utf-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Tapper::Producer::SimnowKernel - produce preconditions for simnow kernel testing |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 younger |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Comparator for files by mtime. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 get_version |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Try to get the kernel version by reading the files in the packet. |
109
|
|
|
|
|
|
|
This approach works since that way the kernel_version required by |
110
|
|
|
|
|
|
|
gen_initrd even if other approaches would report different version |
111
|
|
|
|
|
|
|
strings. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 produce |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Produce resulting precondition. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Advanced Micro Devices, Inc.. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is free software, licensed under: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |