diff options
author | Karel Kočí <cynerd@email.cz> | 2015-04-27 21:31:03 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-04-27 21:31:03 +0200 |
commit | e89081c8ae3ba5cc42a7f387b267f02ea5a4e8f1 (patch) | |
tree | 26e139e120f19a928fe8e2ea1a4b21802ce8ef29 /scripts | |
parent | 99a8f39ae04baf1de67659a13d816eb3b89daa99 (diff) | |
download | linux-conf-perf-e89081c8ae3ba5cc42a7f387b267f02ea5a4e8f1.tar.gz linux-conf-perf-e89081c8ae3ba5cc42a7f387b267f02ea5a4e8f1.tar.bz2 linux-conf-perf-e89081c8ae3ba5cc42a7f387b267f02ea5a4e8f1.zip |
Chnage conf paths from absolute to relative
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/conf.py | 4 | ||||
-rw-r--r-- | scripts/initialize.py | 23 | ||||
-rw-r--r-- | scripts/iteration.py | 7 | ||||
-rw-r--r-- | scripts/kernel.py | 16 | ||||
-rw-r--r-- | scripts/phase.py | 5 | ||||
-rw-r--r-- | scripts/solution.py | 33 | ||||
-rw-r--r-- | scripts/utils.py | 7 |
7 files changed, 53 insertions, 42 deletions
diff --git a/scripts/conf.py b/scripts/conf.py index c2f891d..b3a0fee 100644 --- a/scripts/conf.py +++ b/scripts/conf.py @@ -5,3 +5,7 @@ import importlib.machinery confpy = os.path.dirname(__file__) + "/../conf.py" conf = importlib.machinery.SourceFileLoader("module.name", confpy).load_module() + +def sf(path): + return os.path.join(os.path.relpath(conf.absroot), path) + return '../' + path diff --git a/scripts/initialize.py b/scripts/initialize.py index 8b04610..8fb06df 100644 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -5,41 +5,42 @@ import shutil import utils from conf import conf +from conf import sf from exceptions import MissingFile def parse_kconfig(): "Execute parse_kconfig in linux_sources directory." env = dict(os.environ) wd = os.getcwd() - os.chdir(conf.linux_sources) + os.chdir(sf(conf.linux_sources)) if conf.parse_kconfig_output: - subprocess.call([conf.parse_kconfig, conf.linux_kconfig_head, conf.build_folder, "-v", "-v"], env=utils.get_kernel_env()) + subprocess.call([sf(conf.parse_kconfig), sf(conf.linux_kconfig_head), sf(conf.build_folder), "-v", "-v"], env=utils.get_kernel_env()) else: - subprocess.call([conf.parse_kconfig, conf.linux_kconfig_head, conf.build_folder], env=utils.get_kernel_env()) + subprocess.call([sf(conf.parse_kconfig), sf(conf.linux_kconfig_head), sf(conf.build_folder)], env=utils.get_kernel_env()) os.chdir(wd) def gen_requred(): "Generates required depenpency from .config file in linux source tree." - if not os.path.isfile(conf.linux_sources + '/.config'): - raise MissingFile(conf.linux_sources + '/.config', + if not os.path.isfile(sf(conf.linux_dot_config)): + raise MissingFile(sf(conf.linux_dot_config), 'Generate initial configuration. Execute make defconfig in linux folder. Or use make menuconfig and change configuration.') utils.build_symbol_map() # Ensure smap existence srmap = {value:key for key, value in utils.smap.items()} try: - os.remove(conf.required_file) - os.remove(conf.dot_config_fragment_file) + os.remove(sf(conf.required_file)) + os.remove(sf(conf.dot_config_fragment_file)) except OSError: pass - shutil.copy(conf.linux_dot_config, conf.dot_config_back_file) + shutil.copy(sf(conf.linux_dot_config), sf(conf.dot_config_back_file)) - with open(conf.linux_sources + '/.config', 'r') as f: - with open(conf.required_file, 'w') as freq: - with open(conf.dot_config_fragment_file, 'w') as fconf: + with open(sf(conf.linux_dot_config), 'r') as f: + with open(sf(conf.required_file), 'w') as freq: + with open(sf(conf.dot_config_fragment_file), 'w') as fconf: for line in f: if (line[0] == '#') or (not '=' in line): continue diff --git a/scripts/iteration.py b/scripts/iteration.py index f885b37..ef5a3f0 100644 --- a/scripts/iteration.py +++ b/scripts/iteration.py @@ -1,12 +1,13 @@ from conf import conf +from conf import sf def reset(): - with open(conf.iteration_file, 'w') as f: + with open(sf(conf.iteration_file), 'w') as f: f.write('0') def inc(): - with open(conf.iteration_file, 'r') as f: + with open(sf(conf.iteration_file), 'r') as f: it = int(f.read()) it += 1 - with open(conf.iteration_file, 'w') as f: + with open(sf(conf.iteration_file), 'w') as f: f.write(str(it)) diff --git a/scripts/kernel.py b/scripts/kernel.py index a95202f..d698e4c 100644 --- a/scripts/kernel.py +++ b/scripts/kernel.py @@ -3,19 +3,19 @@ import sys import subprocess from conf import conf +from conf import sf import utils def config(): - # Executing old linux config env = dict(os.environ) wd = os.getcwd() - os.chdir(conf.linux_sources) + os.chdir(sf(conf.linux_sources)) if conf.kernel_config_output: - sprc = subprocess.call([conf.write_config, conf.linux_kconfig_head, - conf.build_folder], env=utils.get_kernel_env()) + sprc = subprocess.call([sf(conf.write_config), sf(conf.linux_kconfig_head), + sf(conf.build_folder)], env=utils.get_kernel_env()) else: - sprc = subprocess.call([conf.write_config, conf.linux_kconfig_head, - conf.build_folder], stdout=subprocess.DEVNULL, + sprc = subprocess.call([sf(conf.write_config), sf(conf.linux_kconfig_head), + sf(conf.build_folder)], stdout=subprocess.DEVNULL, env=utils.get_kernel_env()) os.chdir(wd) @@ -23,7 +23,7 @@ def config_noprogram(): # Executing old linux config env = dict(os.environ) wd = os.getcwd() - os.chdir(conf.linux_sources) + os.chdir(sf(conf.linux_sources)) if conf.kernel_config_output: sprc = subprocess.call('yes "" | make oldconfig', shell=True, env=utils.get_kernel_env()) @@ -34,7 +34,7 @@ def config_noprogram(): def make(): wd = os.getcwd() - os.chdir(conf.linux_sources) + os.chdir(sf(conf.linux_sources)) if conf.kernel_make_output: subprocess.call(['make'] + conf.linux_make_args, env=utils.get_kernel_env()) diff --git a/scripts/phase.py b/scripts/phase.py index fe7b4b1..390087f 100644 --- a/scripts/phase.py +++ b/scripts/phase.py @@ -2,6 +2,7 @@ import os import sys from conf import conf +from conf import sf phases = ("Not Initialized", #0 "Initializing", #1 @@ -18,7 +19,7 @@ phases = ("Not Initialized", #0 def get(): try: - with open(conf.phase_file) as f: + with open(sf(conf.phase_file)) as f: txtPhase = f.readline().rstrip() if not txtPhase in phases: raise PhaseMismatch() @@ -27,7 +28,7 @@ def get(): return 0 def set(phs): - with open(conf.phase_file, 'w') as f: + with open(sf(conf.phase_file), 'w') as f: f.write(phases[phs]) def pset(str): diff --git a/scripts/solution.py b/scripts/solution.py index 21e1cea..3fddb6b 100644 --- a/scripts/solution.py +++ b/scripts/solution.py @@ -5,6 +5,7 @@ import subprocess import utils from conf import conf +from conf import sf from exceptions import NoSolution def generate(): @@ -18,29 +19,29 @@ def generate(): solution_file """ # Check if rules_file exist. If it was generated. - if not os.path.isfile(conf.rules_file): + if not os.path.isfile(sf(conf.rules_file)): raise Exception("Rules file missing. Run parse_kconfig and check ecistence of " + rules_file) w_file = tempfile.NamedTemporaryFile(delete=False) # Join files to one single temporary file lines = set() - with open(conf.rules_file, 'r') as f: - for lnn in open(conf.rules_file, 'r'): + with open(sf(conf.rules_file), 'r') as f: + for lnn in open(sf(conf.rules_file), 'r'): ln = lnn.rstrip() if ln not in lines: lines.add(ln) - if os.path.isfile(conf.solved_file): - for lnn in open(conf.solved_file, 'r'): + if os.path.isfile(sf(conf.solved_file)): + for lnn in open(sf(conf.solved_file), 'r'): ln = lnn.rstrip() if ln not in lines: lines.add(ln) - if os.path.isfile(conf.required_file): - for lnn in open(conf.required_file, 'r'): + if os.path.isfile(sf(conf.required_file)): + for lnn in open((conf.required_file), 'r'): ln = lnn.rstrip() if ln not in lines: lines.add(ln) - with open(conf.symbol_map_file) as f: + with open(sf(conf.symbol_map_file)) as f: for var_num, l in enumerate(f): pass var_num += 1 @@ -55,9 +56,9 @@ def generate(): # Execute minisat if conf.minisat_output: - subprocess.call(['minisat', w_file.name, conf.solution_file]) + subprocess.call(['minisat', w_file.name, sf(conf.solution_file)]) else: - subprocess.call(['minisat', w_file.name, conf.solution_file], stdout=subprocess.DEVNULL) + subprocess.call(['minisat', w_file.name, sf(conf.solution_file)], stdout=subprocess.DEVNULL) os.remove(w_file.name) @@ -65,20 +66,22 @@ def apply(): """Apply generated solution to kernel source. """ # Check if solution_file exist - if not os.path.isfile(conf.solution_file): - raise Exception("Solution file is missing. Run sat_solution and check existence of " + conf.solution_file) + if not os.path.isfile(sf(conf.solution_file)): + raise Exception("Solution file is missing. Run sat_solution and check existence of " + sf(conf.solution_file)) utils.build_symbol_map() # Ensure smap existence # Read solution if satisfiable - with open(conf.solution_file, 'r') as f: + with open(sf(conf.solution_file), 'r') as f: if not f.readline().rstrip() == 'SAT': raise NoSolution() solut = f.readline().split() solut.remove('0') # Remove 0 at the end + + # Write negotation solution to solver_file - with open(conf.solved_file, 'a') as f: + with open(sf(conf.solved_file), 'a') as f: for txt in solut: if txt[0] == '-': ntx = "" @@ -89,7 +92,7 @@ def apply(): f.write("\n") # Write solution to .config file in linux source folder - with open(conf.linux_sources + '/.config', 'w') as f: + with open(sf(conf.linux_dot_config), 'w') as f: for txt in solut: if txt[0] == '-': nt = True diff --git a/scripts/utils.py b/scripts/utils.py index 161ed8a..7f8e301 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,6 +1,7 @@ import os import sys from conf import conf +from conf import sf from exceptions import MissingFile def build_symbol_map(): @@ -12,11 +13,11 @@ def build_symbol_map(): smap except NameError: # Check if symbol_map_file exist - if not os.path.isfile(conf.symbol_map_file): - raise MissingFile(conf.symbol_map_file, "Run parse_kconfig to generate it.") + if not os.path.isfile(sf(conf.symbol_map_file)): + raise MissingFile(sf(conf.symbol_map_file), "Run parse_kconfig to generate it.") smap = dict() - with open(conf.symbol_map_file) as f: + with open(sf(conf.symbol_map_file)) as f: for lnn in f: w = lnn.rstrip().split(sep=':') smap[w[0]] = w[1] |