3 # compare: a tool to compare kernel config files
5 # Marc E. Fiuczynski <mef@cs.princeton.edu>
6 # Copyright (C) 2006 The Trustees of Princeton University
8 # $Id: kompare,v 1.1 2006/11/30 16:41:09 mef Exp $
16 for line in file.readlines():
19 if len(iline)==0: continue
23 offset=iline.find(" is not set")
25 config = line[line.find("CONFIG"):offset].strip()
26 if CONFIGS.has_key(config): print "duplicate entry %s" % config
27 CONFIGS[config]="is not set"
30 # skip over comments that do not contain the "is not set" string
34 offset = iline.find('=')
36 config = line[line.find("CONFIG"):offset].strip()
37 if CONFIGS.has_key(config): print "duplicate entry %s" % config
38 CONFIGS[config] = line[offset+1:].strip()
41 return (CONFIGS,ORDER)
47 name = os.path.basename(sys.argv[0])
48 print "USAGE: %s [options] from.config to.config" % name
51 -a Show all differences
54 ADD Added config (exists in to.config, but not in from.config)
55 REM Removed config (exists in from.config, but not in to.config)
66 (old,oldorder)= process(open(args[0]))
67 (new,neworder)= process(open(args[1]))
69 newstate = {None:'REM',"is not set":'DIS','y':'BLT','m':'MOD'}
74 if n==o and not showall: continue
75 print "%6s -> %6s : %s" % (newstate.get(o,o),newstate.get(n,n),key)
77 # not sure we care about what options have been removed
78 # from from.config file
80 oldstate = {None:'A',"is not set":'D','y':'B','m':'M'}
85 if n == -1 and not showall:
86 print "%c -> %c : %s" % (oldstate[o],oldstate[n],key)