From 2cee211e775372b48c274d0a79cfc8b5d706fe9a Mon Sep 17 00:00:00 2001 From: Jurij Smakov Date: Fri, 3 Jun 2005 03:50:17 +0000 Subject: [PATCH] A new script for splitting the kernel configs into common and flavour-specific parts. See source for description. Will need to be modified to be able to rebuild the configs after modifications. svn path=/branches/kernel-image-2.6.11/; revision=3296 --- debian/bin/split.py | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 debian/bin/split.py diff --git a/debian/bin/split.py b/debian/bin/split.py new file mode 100755 index 000000000..a397cfd1c --- /dev/null +++ b/debian/bin/split.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# +# Scans underlying directory structure for files with names config.ext +# where .ext is not .stub, .common or .default, and extracts a common +# set of config options from them. The resulting set of options is +# written into the config.common file. On the second pass each config.ext +# file is parsed to remove the common config options found in +# config.common, with the results written to config.ext.stub. +# +import os, string, sys + +common = [] +conffiles = [] + +def is_option(line): + result = (string.count(line, '#') > 0) + result = result or (len(string.strip(line)) == 0) + return not result + +def is_not_common(line): + return (line not in common) + +def read_list(fname): + inf = open(fname, 'r') + opts = filter(is_option, inf.readlines()) + inf.close() + return opts + +def merge_list(list): + global common + if len(common) == 0: + common = list[:] + else: + for opt in common: + if opt not in list: common.remove(opt) + +def write_out(list, fname): + outf = open(fname, 'w') + outf.write('#\n# Automatically generated by ' + sys.argv[0] + '\n#\n') + outf.writelines(list) + outf.close() + +def walk_callback(arg, dir, names): + if names.count('.svn'): names.remove('.svn') + for name in names: + base, ext = os.path.splitext(name) + if(base == 'config' and ext not in ('.default', '.stub', '.common')): + fname = os.path.join(dir,name) + conffiles.append(fname) + print 'Processing ' + fname + ' ... ', + s = read_list(fname) + merge_list(s) + print "done." +# +# Main routine +# +os.path.walk('.', walk_callback, None) +print 'Writing the config.common output file ... ', +write_out(common, 'config.common') +print 'done.' +for fname in conffiles: + print 'Writing the ' + fname + '.stub output file ... ', + s = filter(is_not_common, read_list(fname)) + write_out(s, fname + '.stub') + print 'done.'