]> rtime.felk.cvut.cz Git - linux-conf-perf.git/blob - scripts/kernel.py
Write stderr to log file together with stdout
[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         infile.close()
24         os.chdir(wd)
25
26 #def config_noprogram():
27 #       # Executing old linux config
28 #       env = dict(os.environ)
29 #       wd = os.getcwd()
30 #       os.chdir(sf(conf.linux_sources))
31 #       if conf.kernel_config_output:
32 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
33 #                       env=utils.get_kernel_env())
34 #       else:
35 #               sprc = subprocess.call('yes "" | make oldconfig', shell=True,
36 #                       stdout=subprocess.DEVNULL, env=utils.get_kernel_env())
37 #       os.chdir(wd)
38
39 def make(confhash):
40         wd = os.getcwd()
41         os.chdir(sf(conf.linux_sources))
42         if conf.kernel_make_output:
43                 subprocess.call(conf.build_command, env=utils.get_kernel_env())
44         else:
45                 subprocess.call(conf.build_command, stdout=subprocess.DEVNULL,
46                                 env=utils.get_kernel_env())
47         jobimage = os.path.join(sf(conf.build_folder), confhash + '_linux.img')
48         shutil.move(sf(conf.linux_image), jobimage)
49         os.chdir(wd)
50         return confhash + '_linux.img'