1 # Copyright 2007 Google Inc. Released under the GPL v2
4 This module defines the SourceKernel class
6 SourceKernel: an linux kernel built from source
10 from autotest_lib
.server
import kernel
, autotest
13 class SourceKernel(kernel
.Kernel
):
15 This class represents a linux kernel built from source.
17 It is used to obtain a built kernel or create one from source and
20 Implementation details:
21 This is a leaf class in an abstract class hierarchy, it must
22 implement the unimplemented methods in parent classes.
24 def __init__(self
, k
):
25 super(kernel
.Kernel
, self
).__init
__()
27 self
.__patch
_list
= []
28 self
.__config
_file
= None
29 self
.__autotest
= autotest
.Autotest()
32 def configure(self
, configFile
):
33 self
.__config
_file
= configFile
36 def patch(self
, patchFile
):
37 self
.__patch
_list
.append(patchFile
)
40 def build(self
, host
):
41 ctlfile
= self
.__control
_file
(self
.__kernel
, self
.__patch
_list
,
43 self
.__autotest
.run(ctlfile
, host
.get_tmp_dir(), host
)
46 def install(self
, host
):
47 self
.__autotest
.install(host
)
48 ctlfile
= ("testkernel = job.kernel('%s')\n"
49 "testkernel.install()\n"
50 "testkernel.add_to_bootloader()\n" %(self
.__kernel
))
51 self
.__autotest
.run(ctlfile
, host
.get_tmp_dir(), host
)
54 def __control_file(self
, kernel
, patch_list
, config
):
55 ctl
= ("testkernel = job.kernel('%s')\n" % kernel
)
58 patches
= ', '.join(["'%s'" % x
for x
in patch_list
])
59 ctl
+= "testkernel.patch(%s)\n" % patches
62 ctl
+= "testkernel.config('%s')\n" % config
64 ctl
+= "testkernel.config('', None, True)\n"
66 ctl
+= "testkernel.build()\n"