]> git.sur5r.net Git - kconfig-frontends/commitdiff
misc: add diffconfig script
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun, 26 Feb 2012 10:59:05 +0000 (11:59 +0100)
committerYann E. MORIN" <yann.morin.1998@free.fr>
Sun, 26 Feb 2012 10:59:05 +0000 (11:59 +0100)
Add diffconfig, a handy tool to pretty-print the differences
between two .config files.

Sort the sync-file by destination; sync up with linux-3.3-rc5.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
.version
misc/diffconfig [new file with mode: 0755]
misc/kernel2kfrontends.list

index 5f8bcb39a07e4c1486726225510f97c837786950..1c6d4704bb4a2bdcd88a0ad15150621bc63d6cbe 100644 (file)
--- a/.version
+++ b/.version
@@ -1,2 +1,2 @@
-3.3.0-rc3 d65b4e98d7ea3038b767b70fe8be959b2913f16d Saber-toothed Squirrel
+3.3.0-rc5 6b21d18ed50c7d145220b0724ea7f2613abf0f95 Saber-toothed Squirrel
 hg
diff --git a/misc/diffconfig b/misc/diffconfig
new file mode 100755 (executable)
index 0000000..b91f3e3
--- /dev/null
@@ -0,0 +1,129 @@
+#!/usr/bin/python
+#
+# diffconfig - a tool to compare .config files.
+#
+# originally written in 2006 by Matt Mackall
+#  (at least, this was in his bloatwatch source code)
+# last worked on 2008 by Tim Bird
+#
+
+import sys, os
+
+def usage():
+    print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
+
+Diffconfig is a simple utility for comparing two .config files.
+Using standard diff to compare .config files often includes extraneous and
+distracting information.  This utility produces sorted output with only the
+changes in configuration values between the two files.
+
+Added and removed items are shown with a leading plus or minus, respectively.
+Changed items show the old and new values on a single line.
+
+If -m is specified, then output will be in "merge" style, which has the
+changed and new values in kernel config option format.
+
+If no config files are specified, .config and .config.old are used.
+
+Example usage:
+ $ diffconfig .config config-with-some-changes
+-EXT2_FS_XATTR  n
+-EXT2_FS_XIP  n
+ CRAMFS  n -> y
+ EXT2_FS  y -> n
+ LOG_BUF_SHIFT  14 -> 16
+ PRINTK_TIME  n -> y
+"""
+    sys.exit(0)
+
+# returns a dictionary of name/value pairs for config items in the file
+def readconfig(config_file):
+    d = {}
+    for line in config_file:
+        line = line[:-1]
+        if line[:7] == "CONFIG_":
+            name, val = line[7:].split("=", 1)
+            d[name] = val
+        if line[-11:] == " is not set":
+            d[line[9:-11]] = "n"
+    return d
+
+def print_config(op, config, value, new_value):
+    global merge_style
+
+    if merge_style:
+        if new_value:
+            if new_value=="n":
+                print "# CONFIG_%s is not set" % config
+            else:
+                print "CONFIG_%s=%s" % (config, new_value)
+    else:
+        if op=="-":
+            print "-%s %s" % (config, value)
+        elif op=="+":
+            print "+%s %s" % (config, new_value)
+        else:
+            print " %s %s -> %s" % (config, value, new_value)
+
+def main():
+    global merge_style
+
+    # parse command line args
+    if ("-h" in sys.argv or "--help" in sys.argv):
+       usage()
+
+    merge_style = 0
+    if "-m" in sys.argv:
+        merge_style = 1
+        sys.argv.remove("-m")
+
+    argc = len(sys.argv)
+    if not (argc==1 or argc == 3):
+        print "Error: incorrect number of arguments or unrecognized option"
+        usage()
+
+    if argc == 1:
+        # if no filenames given, assume .config and .config.old
+        build_dir=""
+        if os.environ.has_key("KBUILD_OUTPUT"):
+            build_dir = os.environ["KBUILD_OUTPUT"]+"/"
+
+        configa_filename = build_dir + ".config.old"
+        configb_filename = build_dir + ".config"
+    else:
+        configa_filename = sys.argv[1]
+        configb_filename = sys.argv[2]
+
+    a = readconfig(file(configa_filename))
+    b = readconfig(file(configb_filename))
+
+    # print items in a but not b (accumulate, sort and print)
+    old = []
+    for config in a:
+        if config not in b:
+            old.append(config)
+    old.sort()
+    for config in old:
+        print_config("-", config, a[config], None)
+        del a[config]
+
+    # print items that changed (accumulate, sort, and print)
+    changed = []
+    for config in a:
+        if a[config] != b[config]:
+            changed.append(config)
+        else:
+            del b[config]
+    changed.sort()
+    for config in changed:
+        print_config("->", config, a[config], b[config])
+        del b[config]
+
+    # now print items in b but not in a
+    # (items from b that were in a were removed above)
+    new = b.keys()
+    new.sort()
+    for config in new:
+        print_config("+", config, None, b[config])
+
+main()
index 78a7829ceaba7080a59c03c9efdff3e252579937..caafef761c50b9e58f28054a4c23631a4c8c6292 100644 (file)
@@ -1,29 +1,30 @@
-scripts/kconfig/menu.c                            -->  libs/parser/menu.c
 scripts/kconfig/conf.c                            -->  frontends/conf/conf.c
-scripts/kconfig/symbol.c                          -->  libs/parser/symbol.c
-scripts/kconfig/streamline_config.pl              -->  misc/streamline_config.pl
-scripts/kconfig/lkc_proto.h                       -->  libs/parser/lkc_proto.h
-scripts/kconfig/util.c                            -->  libs/parser/util.c
-scripts/kconfig/nconf.c                           -->  frontends/nconf/nconf.c
-scripts/kconfig/confdata.c                        -->  libs/parser/confdata.c
-scripts/kconfig/qconf.h                           -->  frontends/qconf/qconf.h
-scripts/kconfig/kxgettext.c                       -->  misc/kxgettext.c
-scripts/kconfig/gconf.glade                       -->  frontends/gconf/gconf.glade
 scripts/kconfig/gconf.c                           -->  frontends/gconf/gconf.c
-scripts/kconfig/expr.h                            -->  libs/parser/expr.h
-scripts/kconfig/nconf.gui.c                       -->  frontends/nconf/nconf.gui.c
-scripts/kconfig/merge_config.sh                   -->  misc/merge_config.sh
-scripts/kconfig/expr.c                            -->  libs/parser/expr.c
+scripts/kconfig/gconf.glade                       -->  frontends/gconf/gconf.glade
 scripts/kconfig/mconf.c                           -->  frontends/mconf/mconf.c
+scripts/kconfig/nconf.c                           -->  frontends/nconf/nconf.c
+scripts/kconfig/nconf.gui.c                       -->  frontends/nconf/nconf.gui.c
+scripts/kconfig/nconf.h                           -->  frontends/nconf/nconf.h
 scripts/kconfig/qconf.cc                          -->  frontends/qconf/qconf.cc
+scripts/kconfig/qconf.h                           -->  frontends/qconf/qconf.h
+scripts/kconfig/images.c                          -->  libs/images/images.h
+scripts/kconfig/lxdialog/BIG.FAT.WARNING          -->  libs/lxdialog/BIG.FAT.WARNING
+scripts/kconfig/lxdialog/checklist.c              -->  libs/lxdialog/checklist.c
+scripts/kconfig/lxdialog/dialog.h                 -->  libs/lxdialog/dialog.h
 scripts/kconfig/lxdialog/inputbox.c               -->  libs/lxdialog/inputbox.c
+scripts/kconfig/lxdialog/menubox.c                -->  libs/lxdialog/menubox.c
 scripts/kconfig/lxdialog/textbox.c                -->  libs/lxdialog/textbox.c
 scripts/kconfig/lxdialog/util.c                   -->  libs/lxdialog/util.c
-scripts/kconfig/lxdialog/checklist.c              -->  libs/lxdialog/checklist.c
-scripts/kconfig/lxdialog/BIG.FAT.WARNING          -->  libs/lxdialog/BIG.FAT.WARNING
 scripts/kconfig/lxdialog/yesno.c                  -->  libs/lxdialog/yesno.c
-scripts/kconfig/lxdialog/menubox.c                -->  libs/lxdialog/menubox.c
-scripts/kconfig/lxdialog/dialog.h                 -->  libs/lxdialog/dialog.h
-scripts/kconfig/nconf.h                           -->  frontends/nconf/nconf.h
-scripts/kconfig/images.c                          -->  libs/images/images.h
+scripts/kconfig/confdata.c                        -->  libs/parser/confdata.c
+scripts/kconfig/expr.c                            -->  libs/parser/expr.c
+scripts/kconfig/expr.h                            -->  libs/parser/expr.h
 scripts/kconfig/lkc.h                             -->  libs/parser/lkc.h
+scripts/kconfig/lkc_proto.h                       -->  libs/parser/lkc_proto.h
+scripts/kconfig/menu.c                            -->  libs/parser/menu.c
+scripts/kconfig/symbol.c                          -->  libs/parser/symbol.c
+scripts/kconfig/util.c                            -->  libs/parser/util.c
+scripts/diffconfig                                -->  misc/diffconfig
+scripts/kconfig/kxgettext.c                       -->  misc/kxgettext.c
+scripts/kconfig/merge_config.sh                   -->  misc/merge_config.sh
+scripts/kconfig/streamline_config.pl              -->  misc/streamline_config.pl