From 158653da512d7ace39e3cacc796e95ad8a4bbaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 24 Mar 2015 22:42:56 +0100 Subject: Implement requirement generation from kernel .config --- scripts/initialize.py | 27 ++++++++++++++------------- scripts/solution.py | 4 ++++ 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/initialize.py b/scripts/initialize.py index 87a98b4..2fc7d54 100644 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -25,22 +25,23 @@ def gen_requred(): "Generates required depenpency from required file." utils.build_symbol_map() srmap = {value:key for key, value in utils.smap.items()} - - if not os.path.isfile(conf.required): - raise MissingFile(conf.required, None) try: os.remove(conf.required_file) + os.remove(conf.dot_config_file) except OSError: pass - with open(conf.required_file, 'w') as fout: - with open(conf.required, 'r') as f: - for line in f: - for word in line.rstrip().split(): - if word[0] == '-': - fout.write('-') - word = word[1:] - fout.write(srmap[word] + " ") - fout.write("\n") - + with open(conf.linux_sources + '/.config', 'r') as f: + with open(conf.required_file, 'w') as freq: + with open(conf.dot_config_file, 'w') as fconf: + for line in f: + if (line[0] == '#') or (not '=' in line): + continue + indx = line.index('=') + if (line[indx + 1] == 'y' or line[indx + 1] == 'm'): + freq.write(srmap[line[7:indx]] + "\n") + elif (line[indx + 1] == 'n'): + freq.write("-" + srmap[line[7:indx]] + "\n") + else: + fconf.write(line); diff --git a/scripts/solution.py b/scripts/solution.py index 969219e..fd6aa23 100644 --- a/scripts/solution.py +++ b/scripts/solution.py @@ -90,6 +90,10 @@ def apply(): # Write solution to .config file in linux source folder with open(conf.linux_sources + '/.config', 'w') as f: + with open(conf.dot_config_file, 'r') as fconf: + for line in fconf: + f.write(line) + for txt in solut: if txt[0] == '-': nt = True -- cgit v1.2.3