| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
|
2
|
|
|
|
|
|
|
package Tapper::Producer::Kernel; |
|
3
|
|
|
|
|
|
|
BEGIN { |
|
4
|
1
|
|
|
1
|
|
1571
|
$Tapper::Producer::Kernel::AUTHORITY = 'cpan:TAPPER'; |
|
5
|
|
|
|
|
|
|
} |
|
6
|
|
|
|
|
|
|
{ |
|
7
|
|
|
|
|
|
|
$Tapper::Producer::Kernel::VERSION = '4.1.3'; |
|
8
|
|
|
|
|
|
|
} |
|
9
|
|
|
|
|
|
|
# ABSTRACT: produce preconditions for a kernel package |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
441
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use YAML; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use 5.010; |
|
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
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# project may be x86_64, stable/x86_64, ... |
|
49
|
|
|
|
|
|
|
my $project = $produce->{arch} // 'x86_64'; |
|
50
|
|
|
|
|
|
|
my $kernel_path = $pkg_dir."/kernel"; |
|
51
|
|
|
|
|
|
|
$project = "stable/$project" if $produce->{stable}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $version = '*'; |
|
55
|
|
|
|
|
|
|
$version .= "$produce->{version}*" if $produce->{version}; |
|
56
|
|
|
|
|
|
|
my @kernelfiles = sort younger <$kernel_path/$project/$version>; |
|
57
|
|
|
|
|
|
|
die 'No kernel files found' if not @kernelfiles; |
|
58
|
|
|
|
|
|
|
my $kernelbuild = pop @kernelfiles; |
|
59
|
|
|
|
|
|
|
my $retval = $self->get_version($kernelbuild); |
|
60
|
|
|
|
|
|
|
my $kernel_version = $retval->{version}; |
|
61
|
|
|
|
|
|
|
my ($kernel_major_version) = $kernel_version =~ m/(2\.\d{1,2}\.\d{1,2})/; |
|
62
|
|
|
|
|
|
|
($kernelbuild) = $kernelbuild =~ m|$pkg_dir/(kernel/$project/.+)$|; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$retval = [ |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
precondition_type => 'package', |
|
68
|
|
|
|
|
|
|
filename => $kernelbuild, |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
|
|
|
|
|
|
precondition_type => 'exec', |
|
72
|
|
|
|
|
|
|
filename => '/bin/gen_initrd.sh', |
|
73
|
|
|
|
|
|
|
options => [ $kernel_version ], |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
]; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return { |
|
78
|
|
|
|
|
|
|
topic => $produce->{topic} // "kernel-$kernel_major_version-reboot", |
|
79
|
|
|
|
|
|
|
precondition_yaml => Dump(@$retval), |
|
80
|
|
|
|
|
|
|
}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding utf-8 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Tapper::Producer::Kernel - produce preconditions for a kernel package |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 younger |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Comparator for files by mtime. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 get_version |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Try to get the kernel version by reading the files in the packet. This |
|
101
|
|
|
|
|
|
|
approach works since that way the kernel_version required by gen_initrd |
|
102
|
|
|
|
|
|
|
even if other approaches would report different version strings. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 produce |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Produce resulting precondition. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Advanced Micro Devices, Inc.. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This is free software, licensed under: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |