r3296 - branches/kernel-image-2.6.11/debian/bin
Jurij Smakov
jurij-guest@costa.debian.org
Fri, 03 Jun 2005 03:50:18 +0000
Author: jurij-guest
Date: 2005-06-03 03:50:17 +0000 (Fri, 03 Jun 2005)
New Revision: 3296
Added:
branches/kernel-image-2.6.11/debian/bin/split.py
Log:
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.
Added: branches/kernel-image-2.6.11/debian/bin/split.py
===================================================================
--- branches/kernel-image-2.6.11/debian/bin/split.py 2005-06-02 00:57:40 UTC (rev 3295)
+++ branches/kernel-image-2.6.11/debian/bin/split.py 2005-06-03 03:50:17 UTC (rev 3296)
@@ -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.'
Property changes on: branches/kernel-image-2.6.11/debian/bin/split.py
___________________________________________________________________
Name: svn:executable
+ *