]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/kernel.py
Generated configuration is now fully stored to database
[linux-conf-perf.git] / scripts / kernel.py
1 import os
2 import sys
3 import subprocess
4 import shutil
5 import tempfile
6
7 from conf import conf
8 from conf import sf
9 import exceptions
10 import utils
11
12 def config(txtconfig):
13         "Apply text configuration to kernel folder"
14         infile = tempfile.NamedTemporaryFile()
15         infile.write(bytes(txtconfig, sys.getdefaultencoding()))
16         wd = os.getcwd()
17         os.chdir(sf(conf.linux_sources))
18         try:
19                 utils.callsubprocess('write_config', [sf(conf.write_config), infile],
20                         conf.kernel_config_output, env=utils.get_kernel_env())
21         except exceptions.ProcessFailed:
22                 raise exceptions.ConfigurationError("some configs mismatch")
23         os.chdir(wd)
24
25 #def config_noprogram():
26 #       # Executing old linux config
27 #       env = dict(os.environ)
28 #       wd = os.getcwd()
29 #       os.chdir(sf(conf.linux_sources))
30 #       if conf.kernel_config_output:
31 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
32 #                       env=utils.get_kernel_env())
33 #       else:
34 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
35 #                       stdout=subprocess.DEVNULL, env=utils.get_kernel_env())
36 #       os.chdir(wd)
37
38 def make(confhash):
39         wd = os.getcwd()
40         os.chdir(sf(conf.linux_sources))
41         if conf.kernel_make_output:
42                 subprocess.call(conf.build_command, env=utils.get_kernel_env())
43         else:
44                 subprocess.call(conf.build_command, stdout=subprocess.DEVNULL,
45                                 env=utils.get_kernel_env())
46         jobimage = os.path.join(sf(conf.build_folder), confhash + '_linux.img')
47         shutil.move(sf(conf.linux_image), jobimage)
48         os.chdir(wd)
49         return confhash + '_linux.img'