SOURCES: kernel-config-update.py - collect allarch from config and...

glen glen at pld-linux.org
Tue Jan 29 02:14:13 CET 2008


Author: glen                         Date: Tue Jan 29 01:14:13 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- collect allarch from config and turn lost symbols into other arch values

---- Files affected:
SOURCES:
   kernel-config-update.py (1.7 -> 1.8) 

---- Diffs:

================================================================
Index: SOURCES/kernel-config-update.py
diff -u SOURCES/kernel-config-update.py:1.7 SOURCES/kernel-config-update.py:1.8
--- SOURCES/kernel-config-update.py:1.7	Tue Jan 29 01:08:33 2008
+++ SOURCES/kernel-config-update.py	Tue Jan 29 02:14:08 2008
@@ -12,8 +12,8 @@
     sys.exit(1)
 
 arch = sys.argv[1]
-kernelconfig = sys.argv[2]
-inconfig = sys.argv[3]
+kernelconf = sys.argv[2]
+dotconfig = sys.argv[3]
 
 from UserDict import UserDict
 
@@ -72,8 +72,9 @@
 dict = odict()
 
 rc = 0
-f = open(kernelconfig, 'r')
+f = open(kernelconf, 'r')
 i = 0;
+allarch = {}
 for l in f:
     if l[:6] == 'CONFIG_':
         print "Omit CONFIG_ when specifing symbol name: %s" % l
@@ -100,28 +101,24 @@
     conf = dict[symbol] = odict()
     for item in c[1:]:
         (key, value) = item.split('=')
+        if not allarch.has_key(key):
+            allarch[key] = 1
         dict[symbol][key] = value
 
 #    print "Add symbol: %s = %s" % (symbol, dict[symbol])
 
 f.close()
+del allarch['all']
 #rc =1
 
 if not rc == 0:
     sys.exit(1)
 
-dict[i] = ""
-i += 1
-dict[i] = "#"
-i += 1
-dict[i] = "# New symbols"
-i += 1
-dict[i] = "#"
-i += 1
-
-f = open(inconfig, 'r')
+# read keys from .config
+f = open(dotconfig, 'r')
+dotdict = {}
 for l in f:
-    # yes, module and string, numeric values
+    # 'y'es, 'm'odule and string, numeric values
     m = re.match("^CONFIG_(.*)=(.*)$", l)
     if not m == None:
         symbol = m.group(1)
@@ -132,17 +129,35 @@
         if not m == None:
             symbol = m.group(1)
             value = "n"
-
-    # other data. perhaps comments
+    # other irrelevant data
     if m == None:
-#        print l.strip()
         continue
+    dotdict[symbol] = value
+f.close()
 
+dict[i] = ""
+i += 1
+dict[i] = "#"
+i += 1
+dict[i] = "# New symbols"
+i += 1
+dict[i] = "#"
+i += 1
+
+for symbol in dotdict.keys():
+    value = dotdict[symbol]
     if dict.has_key(symbol):
         c = dict[symbol]
+        # if we have arch key, we use regardless there's 'all' present
         if c.has_key('all') and c.has_key(arch):
             c[arch] = value
         elif c.has_key('all') and c['all'] != value:
+            # turn 'all' to separate arch values
+            for a in allarch:
+                c[a] = c['all']
+            del c['all']
+
+            # new value from this arch
             c[arch] = value
         elif c.has_key('all'):
             c['all'] = value # actualy same value
@@ -155,10 +170,9 @@
         c['all'] = value
         dict[symbol] = c
 #        dict[symbol] = ('all', value)
-
-
 f.close()
 
+# printout time
 for symbol in dict.keys():
     c = dict[symbol]
 #    print "s=%s, c=%s" % (type(symbol), type(c))
@@ -166,6 +180,22 @@
         print c
         continue
 
+    # go over symbols which no longer present in .config
+    # and remove from our arch.
+    if not dotdict.has_key(symbol):
+        c = dict[symbol]
+        # if there's 'all' key, expand it to avalable arch list
+        if c.has_key('all'):
+            value = c['all']
+            for a in allarch:
+                if not c.has_key(a):
+                    c[a] = value
+            del c['all']
+        if c.has_key(arch):
+            del c[arch]
+
+
+    # join arch=value into string back
     s = ''
     for k in c.keys():
         s += ' %s=%s' % (k, c[k])
@@ -175,9 +205,6 @@
     if symbol == "LOCALVERSION":
         # .specs updates this
         continue
-    if symbol == "DEFCONFIG_LIST":
-        # seems wrong
-        continue
 #    if symbol == "MATH_EMULATION":
 #        # .spec keeps updating this
 #        continue
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/kernel-config-update.py?r1=1.7&r2=1.8&f=u



More information about the pld-cvs-commit mailing list