]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/kernel.py
11dce0f7b00be77861a63a1a47d61eb609c66406
[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         for ln in txtconfig:
16                 infile.write(bytes(ln + '\n', sys.getdefaultencoding()))
17         wd = os.getcwd()
18         os.chdir(sf(conf.linux_sources))
19         try:
20                 utils.callsubprocess('write_config', [sf(conf.write_config), infile.name],
21                         conf.kernel_config_output, env=utils.get_kernel_env())
22         except exceptions.ProcessFailed:
23                 raise exceptions.ConfigurationError("some configs mismatch")
24         infile.close()
25         os.chdir(wd)
26
27 #def config_noprogram():
28 #       # Executing old linux config
29 #       env = dict(os.environ)
30 #       wd = os.getcwd()
31 #       os.chdir(sf(conf.linux_sources))
32 #       if conf.kernel_config_output:
33 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
34 #                       env=utils.get_kernel_env())
35 #       else:
36 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
37 #                       stdout=subprocess.DEVNULL, env=utils.get_kernel_env())
38 #       os.chdir(wd)
39
40 def make(confhash):
41         wd = os.getcwd()
42         os.chdir(sf(conf.linux_sources))
43         if conf.kernel_make_output:
44                 subprocess.call(conf.build_command, env=utils.get_kernel_env())
45         else:
46                 subprocess.call(conf.build_command, stdout=subprocess.DEVNULL,
47                                 env=utils.get_kernel_env())
48         jobimage = os.path.join(sf(conf.build_folder), confhash + '_linux.img')
49         shutil.move(sf(conf.linux_image), jobimage)
50         os.chdir(wd)
51         return confhash + '_linux.img'