| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Revision History: |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# 26-Nov-2002 Dick Munroe (munroe@csworks.com) |
|
6
|
|
|
|
|
|
|
# Initial Version Created. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# 18-May-2003 Dick Munroe (munroe@csworks.com) |
|
9
|
|
|
|
|
|
|
# Make sure package variables can't leak. |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# 19-May-2003 Dick Munroe (munroe@csworks.com) |
|
12
|
|
|
|
|
|
|
# Use Carp. |
|
13
|
|
|
|
|
|
|
# Isolate KIF related classes in a KIF namespace. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package KIF::Bootloader::aboot ; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
558
|
use vars qw($VERSION @ISA) ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = "1.03" ; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
4
|
use strict ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use Carp ; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
47
|
|
|
25
|
1
|
|
|
1
|
|
988
|
use File::Copy ; |
|
|
1
|
|
|
|
|
5347
|
|
|
|
1
|
|
|
|
|
76
|
|
|
26
|
1
|
|
|
1
|
|
6
|
use FileHandle ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
27
|
1
|
|
|
1
|
|
540
|
use KIF::Bootloader ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1045
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @ISA = qw(KIF::Bootloader) ; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
0
|
0
|
|
my $thePackage = shift ; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $theObject = $thePackage->SUPER::new() ; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if (-e "/etc/aboot.conf") |
|
|
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
|
|
|
$theObject->filename("/etc/aboot.conf") ; |
|
40
|
0
|
0
|
|
|
|
|
if (-e "/boot/etc/aboot.conf") |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
|
$theObject->synchedFilename("/boot/etc/aboot.conf") ; |
|
43
|
|
|
|
|
|
|
} ; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
elsif (-e "/boot/etc/aboot.conf") |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
|
|
|
|
|
$theObject->filename("/boot/etc/aboot.conf") ; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
else |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
0
|
|
|
|
|
|
croak "No aboot.conf file found" ; |
|
52
|
|
|
|
|
|
|
} ; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $theObject ; |
|
55
|
|
|
|
|
|
|
} ; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub synchedFilename |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
0
|
|
my $theObject = shift ; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
$theObject->{'synchedFilename'} = $_[0] if (defined($_[0])) ; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $theObject->{'synchedFilename'} ; |
|
64
|
|
|
|
|
|
|
} ; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub modify |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
0
|
0
|
|
my $theObject = shift ; |
|
69
|
0
|
|
|
|
|
|
my $theBuildObject = shift ; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# Modify the aboot.conf file only if we're not just rebuilding the |
|
73
|
|
|
|
|
|
|
# current default kernel. |
|
74
|
|
|
|
|
|
|
# |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $theCurrentKernel = readlink "/boot/vmlinuz" ; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$theCurrentKernel =~ s,.*/,, ; |
|
79
|
0
|
|
|
|
|
|
$theCurrentKernel =~ s,.*?-,, ; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
return if ($theCurrentKernel eq $theBuildObject->releaseTag); |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $theAbootFile = $theObject->_file($theObject->filename) ; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my @theAbootArray = $theAbootFile =~ m,(^\d+:\d+.*$),mg ; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
@theAbootArray = sort @theAbootArray ; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
foreach (@theAbootArray) |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
|
|
|
|
|
|
# |
|
92
|
|
|
|
|
|
|
# The current kernel is already in the aboot.conf file, so |
|
93
|
|
|
|
|
|
|
# we can safely not modify the file. |
|
94
|
|
|
|
|
|
|
# |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
return if (m,-$theCurrentKernel( |$),) ; |
|
97
|
|
|
|
|
|
|
} ; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# |
|
100
|
|
|
|
|
|
|
# At this point we know we have to modify the aboot.conf file |
|
101
|
|
|
|
|
|
|
# and we know that the aboot.conf file should have an available |
|
102
|
|
|
|
|
|
|
# place for a new entry, so we can safely modify things. |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $theIndex ; |
|
106
|
0
|
|
|
|
|
|
my $theLastItem = $theAbootArray[0] ; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
for ($theIndex = 1; $theIndex < 10; $theIndex++) |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
0
|
0
|
|
|
|
|
last if (!defined($theAbootArray[$theIndex])) ; |
|
111
|
0
|
|
|
|
|
|
$theLastItem = $theAbootArray[$theIndex] ; |
|
112
|
|
|
|
|
|
|
} ; |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $theNewEntry ; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
($theNewEntry = $theAbootArray[0]) =~ s/vmlinuz/vmlinuz-$theCurrentKernel/ ; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$theNewEntry =~ s/0/$theIndex/ ; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
$theAbootFile =~ s/^$theLastItem$/$theLastItem\n$theNewEntry/m ; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$theBuildObject->_print($theAbootFile, 3) ; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if (!$theBuildObject->testFlag) |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
0
|
|
|
|
|
|
move($theObject->filename(), $theObject->filename() . ".old") ; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$theBuildObject->_print("Moving " . $theObject->filename() . " => " . $theObject->filename() . ".old\n",1) ; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
my $theFileHandle = new FileHandle "> " . $theObject->filename() or croak "Can't open " . $theObject->filename() ; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$theFileHandle->print($theAbootFile) ; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$theBuildObject->_print("Writing " . $theObject->filename() . "\n",1) ; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
undef $theFileHandle ; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if (defined($theObject->synchedFilename())) |
|
139
|
|
|
|
|
|
|
{ |
|
140
|
0
|
|
|
|
|
|
move($theObject->synchedFilename(), $theObject->synchedFilename() . ".old") ; |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$theBuildObject->_print("Moving " . $theObject->synchedFilename() . " => " . $theObject->synchedFilename() . ".old\n",1) ; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
copy($theObject->filename(), $theObject->synchedFilename()) ; |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$theBuildObject->_print("Copying " . $theObject->filename() . " => " . $theObject->synchedFilename() . "\n",1) ; |
|
147
|
|
|
|
|
|
|
} ; |
|
148
|
|
|
|
|
|
|
} ; |
|
149
|
|
|
|
|
|
|
} ; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub validate |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
|
|
|
|
|
|
# |
|
154
|
|
|
|
|
|
|
# A valid aboot.conf has as it's initial entry the following: |
|
155
|
|
|
|
|
|
|
# |
|
156
|
|
|
|
|
|
|
# 0:[partition]/vmlinuz [kernel arguments] |
|
157
|
|
|
|
|
|
|
# |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
0
|
0
|
|
my $theObject = shift ; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $theBuildObject = shift ; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$theObject->SUPER::validate($theBuildObject) ; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $theFileName = $theObject->filename() ; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $theAbootFile = $theObject->_file($theFileName) ; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
if ($theAbootFile !~ m,^0:\d+/vmlinuz,m) |
|
170
|
|
|
|
|
|
|
{ |
|
171
|
0
|
|
|
|
|
|
print STDERR <<"EOT" ; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$theFileName must be in a standard form for ik to work properly. |
|
174
|
|
|
|
|
|
|
The "default" entry must of the form: |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
0:[partitionNumber]/vmlinuz [kernelParameters] |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Please add an appropriate line to $theFileName and rerun ik. |
|
179
|
|
|
|
|
|
|
EOT |
|
180
|
0
|
|
|
|
|
|
croak "$theFileName is invalid." ; |
|
181
|
|
|
|
|
|
|
} ; |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my $theCurrentKernel = readlink "/boot/vmlinuz" ; |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$theCurrentKernel =~ s,.*/,, ; |
|
186
|
0
|
|
|
|
|
|
$theCurrentKernel =~ s,.*?-,, ; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# |
|
189
|
|
|
|
|
|
|
# Bail if we're just rebuilding the current default kernel. |
|
190
|
|
|
|
|
|
|
# |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
0
|
|
|
|
|
return if ($theCurrentKernel eq $theBuildObject->releaseTag()) ; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# |
|
195
|
|
|
|
|
|
|
# Now check for either a spare hole in the aboot.conf file |
|
196
|
|
|
|
|
|
|
# for this kernel or that this kernel is ALREADY in the |
|
197
|
|
|
|
|
|
|
# aboot.conf file |
|
198
|
|
|
|
|
|
|
# |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my @theAbootArray = $theAbootFile =~ m,(^\d+:\d+.*$),mg ; |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
foreach (@theAbootArray) |
|
203
|
|
|
|
|
|
|
{ |
|
204
|
|
|
|
|
|
|
# |
|
205
|
|
|
|
|
|
|
# Done if the current kernel is already in the aboot configuration |
|
206
|
|
|
|
|
|
|
# file. |
|
207
|
|
|
|
|
|
|
# |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
0
|
|
|
|
|
return if (m/-$theCurrentKernel( |$)/) ; |
|
210
|
|
|
|
|
|
|
} ; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
0
|
|
|
|
|
if (scalar(@theAbootArray) >= 10) |
|
213
|
|
|
|
|
|
|
{ |
|
214
|
0
|
|
|
|
|
|
print STDERR << "EOT" ; |
|
215
|
|
|
|
|
|
|
Only 10 entries, numbered from 0 to 9, may exist in an aboot.conf |
|
216
|
|
|
|
|
|
|
file. 10 entries have been defined. You must remove one of these |
|
217
|
|
|
|
|
|
|
lines and rerun ik. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
EOT |
|
220
|
0
|
|
|
|
|
|
croak "No entries left in /etc/aboot.conf" ; |
|
221
|
|
|
|
|
|
|
} ; |
|
222
|
|
|
|
|
|
|
} ; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
1; |