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
This commit is contained in:
parent
3939e2baef
commit
2cee211e77
|
@ -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.'
|
Loading…
Reference in New Issue