* [PATCH] add diffconfig utility
@ 2008-06-10 19:41 Tim Bird
2008-06-10 21:02 ` Jörn Engel
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Tim Bird @ 2008-06-10 19:41 UTC (permalink / raw)
To: linux-embedded; +Cc: linux kernel
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.
I have found this handy for use in testing to
detect when option dependencies unexpectedly affect
other options.
To use, apply the patch and 'chmod a+x scripts/diffconfig'
Signed-off-by: Tim Bird <tim.bird@am.sony.com>
diffconfig | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+)
--- linux-2.6.24.orig/scripts/diffconfig 1969-12-31 16:00:00.000000000 -0800
+++ test-linux/scripts/diffconfig 2008-06-10 12:11:14.000000000 -0700
@@ -0,0 +1,90 @@
+#!/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)
+#
+# 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.
+#
+# Example usage:
+# $ diffconfig .config config-test-nfs-off
+# -LOCKD y
+# -LOCKD_V4 y
+# -NFS_COMMON y
+# -NFS_DIRECTIO n
+# -NFS_V3 y
+# -NFS_V3_ACL n
+# -NFS_V4 n
+# -ROOT_NFS y
+# -RPCSEC_GSS_KRB5 n
+# -RPCSEC_GSS_SPKM3 n
+# -SUNRPC y
+# -SUNRPC_BIND34 n
+# NFS_FS y -> n
+
+import sys, os
+
+if len(sys.argv) < 3:
+ print "Usage: diffconfig <config1> <config2>"
+ 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
+
+a = readconfig(file(sys.argv[1]))
+b = readconfig(file(sys.argv[2]))
+
+# 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 "-%s %s" % (config, a[config])
+ 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 " %s %s -> %s" % (config, a[config], b[config])
+ del b[config]
+
+# now print items in b but not in a
+
+# the items from b that were in a (either the same or that changed) were removed
+# the only items left were not in a
+new = b.keys()
+
+new.sort()
+
+for config in new:
+ print "+%s %s" % (config, b[config])
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 19:41 [PATCH] add diffconfig utility Tim Bird
@ 2008-06-10 21:02 ` Jörn Engel
2008-06-10 21:18 ` Sam Ravnborg
2008-06-10 21:21 ` [PATCH] add diffconfig utility Sam Ravnborg
` (2 subsequent siblings)
3 siblings, 1 reply; 18+ messages in thread
From: Jörn Engel @ 2008-06-10 21:02 UTC (permalink / raw)
To: Tim Bird; +Cc: linux-embedded, linux kernel
On Tue, 10 June 2008 12:41:54 -0700, Tim Bird wrote:
> Delivery-date: Tue, 10 Jun 2008 21:44:08 +0200
> From: Tim Bird <tim.bird@am.sony.com>
> To: linux-embedded <linux-embedded@vger.kernel.org>
> CC: linux kernel <linux-kernel@vger.kernel.org>
> Subject: [PATCH] add diffconfig utility
Neat. But I have one nagging question: who do you expect to merge this
patch? ;)
Jörn
--
Premature optimization is the root of all evil.
-- Donald Knuth
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 21:02 ` Jörn Engel
@ 2008-06-10 21:18 ` Sam Ravnborg
2008-06-10 21:33 ` execute bit on scripts (was Re: [PATCH] add diffconfig utility) Tim Bird
0 siblings, 1 reply; 18+ messages in thread
From: Sam Ravnborg @ 2008-06-10 21:18 UTC (permalink / raw)
To: Jörn Engel; +Cc: Tim Bird, linux-embedded, linux kernel
On Tue, Jun 10, 2008 at 11:02:18PM +0200, Jörn Engel wrote:
> On Tue, 10 June 2008 12:41:54 -0700, Tim Bird wrote:
> > Delivery-date: Tue, 10 Jun 2008 21:44:08 +0200
> > From: Tim Bird <tim.bird@am.sony.com>
> > To: linux-embedded <linux-embedded@vger.kernel.org>
> > CC: linux kernel <linux-kernel@vger.kernel.org>
> > Subject: [PATCH] add diffconfig utility
>
> Neat. But I have one nagging question: who do you expect to merge this
> patch? ;)
I will merge it if the feedabck is positive and eventual feedback
is dealt with. (And Tim reminds me to do so in a week or so).
I take most of the random scripts in scripts/ via kbuild.git.
Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 19:41 [PATCH] add diffconfig utility Tim Bird
2008-06-10 21:02 ` Jörn Engel
@ 2008-06-10 21:21 ` Sam Ravnborg
2008-06-11 0:25 ` Tim Bird
2008-06-10 22:07 ` [PATCH] add diffconfig utility David Woodhouse
2008-06-11 6:59 ` Holger Schurig
3 siblings, 1 reply; 18+ messages in thread
From: Sam Ravnborg @ 2008-06-10 21:21 UTC (permalink / raw)
To: Tim Bird; +Cc: linux-embedded, linux kernel
On Tue, Jun 10, 2008 at 12:41:54PM -0700, Tim Bird wrote:
> 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.
>
> I have found this handy for use in testing to
> detect when option dependencies unexpectedly affect
> other options.
>
> To use, apply the patch and 'chmod a+x scripts/diffconfig'
>
> Signed-off-by: Tim Bird <tim.bird@am.sony.com>
>
> diffconfig | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 90 insertions(+)
>
> --- linux-2.6.24.orig/scripts/diffconfig 1969-12-31 16:00:00.000000000 -0800
> +++ test-linux/scripts/diffconfig 2008-06-10 12:11:14.000000000 -0700
> @@ -0,0 +1,90 @@
> +#!/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)
> +#
> +# 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.
> +#
> +# Example usage:
> +# $ diffconfig .config config-test-nfs-off
> +# -LOCKD y
> +# -LOCKD_V4 y
> +# -NFS_COMMON y
> +# -NFS_DIRECTIO n
> +# -NFS_V3 y
> +# -NFS_V3_ACL n
> +# -NFS_V4 n
> +# -ROOT_NFS y
> +# -RPCSEC_GSS_KRB5 n
> +# -RPCSEC_GSS_SPKM3 n
> +# -SUNRPC y
> +# -SUNRPC_BIND34 n
> +# NFS_FS y -> n
> +
> +import sys, os
> +
> +if len(sys.argv) < 3:
> + print "Usage: diffconfig <config1> <config2>"
> + sys.exit(0)
I know this is unix style to be very short in usage - but then they
have man pages.
Could we add a bit more from the nice description above to usage?
> +
> +# 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
> +
> +a = readconfig(file(sys.argv[1]))
> +b = readconfig(file(sys.argv[2]))
> +
> +# 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 "-%s %s" % (config, a[config])
> + 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 " %s %s -> %s" % (config, a[config], b[config])
> + del b[config]
> +
> +# now print items in b but not in a
> +
> +# the items from b that were in a (either the same or that changed) were removed
> +# the only items left were not in a
> +new = b.keys()
> +
> +new.sort()
> +
> +for config in new:
> + print "+%s %s" % (config, b[config])
No feedback on the implmentation - I do not speak phython.
Sam
^ permalink raw reply [flat|nested] 18+ messages in thread
* execute bit on scripts (was Re: [PATCH] add diffconfig utility)
2008-06-10 21:18 ` Sam Ravnborg
@ 2008-06-10 21:33 ` Tim Bird
2008-06-10 22:26 ` Jan Engelhardt
0 siblings, 1 reply; 18+ messages in thread
From: Tim Bird @ 2008-06-10 21:33 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Jörn Engel, linux-embedded, linux kernel
Sam Ravnborg wrote:
> I will merge it if the feedabck is positive and eventual feedback
> is dealt with. (And Tim reminds me to do so in a week or so).
Thanks.
> I take most of the random scripts in scripts/ via kbuild.git.
OK - sounds like you're the right person to ask a question
that has been nagging me.
Is there a proper way to get the execute bit set in the git tree
on patches that contain scripts? I think patches
produced by git have something that sets the file permissions?
Is this something that can (or should) be hand-added to
a non-git patch? (I use quilt).
I put that blurb in the patch description about doing a
'chmod a+x', but that doesn't seem reliable.
-- Tim
=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 19:41 [PATCH] add diffconfig utility Tim Bird
2008-06-10 21:02 ` Jörn Engel
2008-06-10 21:21 ` [PATCH] add diffconfig utility Sam Ravnborg
@ 2008-06-10 22:07 ` David Woodhouse
2008-06-10 22:33 ` Tim Bird
2008-06-10 23:02 ` Arjan van de Ven
2008-06-11 6:59 ` Holger Schurig
3 siblings, 2 replies; 18+ messages in thread
From: David Woodhouse @ 2008-06-10 22:07 UTC (permalink / raw)
To: Tim Bird; +Cc: linux-embedded, linux kernel
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
On Tue, 2008-06-10 at 12:41 -0700, Tim Bird wrote:
> +# 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.
It'd be really nice if it could give its output in the same form as
the .config file itself -- so it'd look something like:
# CONFIG_FOO is not set
CONFIG_BAR=y
That can be used with this kind of tool too...
--
dwmw2
[-- Attachment #2: merge.pl --]
[-- Type: application/x-perl, Size: 1400 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: execute bit on scripts (was Re: [PATCH] add diffconfig utility)
2008-06-10 21:33 ` execute bit on scripts (was Re: [PATCH] add diffconfig utility) Tim Bird
@ 2008-06-10 22:26 ` Jan Engelhardt
0 siblings, 0 replies; 18+ messages in thread
From: Jan Engelhardt @ 2008-06-10 22:26 UTC (permalink / raw)
To: Tim Bird; +Cc: Sam Ravnborg, Jörn Engel, linux-embedded, linux kernel
On Tuesday 2008-06-10 23:33, Tim Bird wrote:
>
>> I take most of the random scripts in scripts/ via kbuild.git.
>
>OK - sounds like you're the right person to ask a question
>that has been nagging me.
>
>Is there a proper way to get the execute bit set in the git tree
>on patches that contain scripts? I think patches
>produced by git have something that sets the file permissions?
If the patch was produced with git it should have a line like
new file mode 100755
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 22:07 ` [PATCH] add diffconfig utility David Woodhouse
@ 2008-06-10 22:33 ` Tim Bird
2008-06-10 23:02 ` Arjan van de Ven
1 sibling, 0 replies; 18+ messages in thread
From: Tim Bird @ 2008-06-10 22:33 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-embedded, linux kernel
David Woodhouse wrote:
> On Tue, 2008-06-10 at 12:41 -0700, Tim Bird wrote:
>> +# 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.
>
> It'd be really nice if it could give its output in the same form as
> the .config file itself -- so it'd look something like:
>
> # CONFIG_FOO is not set
> CONFIG_BAR=y
Would an option for that style of output be OK?
The tool currently produces something similar
to a diff (but with changed lines compressed to
a single line for conciseness). It should be easy
to produce something that can be used with another
tool to transform one config into another.
It's unclear what to do with variables that are
supposed to be removed from the config (as opposed
to be set to "CONFIG_FOO is not set" Does merge.pl
handle this, or is this left to something like
'make oldconfig'?
-- Tim
=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 22:07 ` [PATCH] add diffconfig utility David Woodhouse
2008-06-10 22:33 ` Tim Bird
@ 2008-06-10 23:02 ` Arjan van de Ven
2008-06-10 23:10 ` David Woodhouse
1 sibling, 1 reply; 18+ messages in thread
From: Arjan van de Ven @ 2008-06-10 23:02 UTC (permalink / raw)
To: David Woodhouse; +Cc: Tim Bird, linux-embedded, linux kernel
On Tue, 10 Jun 2008 23:07:04 +0100
David Woodhouse <dwmw2@infradead.org> wrote:
> On Tue, 2008-06-10 at 12:41 -0700, Tim Bird wrote:
> > +# 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.
>
> It'd be really nice if it could give its output in the same form as
> the .config file itself -- so it'd look something like:
>
> # CONFIG_FOO is not set
> CONFIG_BAR=y
>
> That can be used with this kind of tool too...
>
the person who wrote that tool also wrote a similar diff tool ;)
but it's horrible perl I suspect.
--
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 23:02 ` Arjan van de Ven
@ 2008-06-10 23:10 ` David Woodhouse
0 siblings, 0 replies; 18+ messages in thread
From: David Woodhouse @ 2008-06-10 23:10 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Tim Bird, linux-embedded, linux kernel
On Tue, 2008-06-10 at 16:02 -0700, Arjan van de Ven wrote:
> the person who wrote that tool also wrote a similar diff tool ;)
> but it's horrible perl I suspect.
Yeah, but I can't find it in CVS right now for some reason.
--
dwmw2
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 21:21 ` [PATCH] add diffconfig utility Sam Ravnborg
@ 2008-06-11 0:25 ` Tim Bird
2008-06-11 11:28 ` Geert Uytterhoeven
0 siblings, 1 reply; 18+ messages in thread
From: Tim Bird @ 2008-06-11 0:25 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-embedded, linux kernel, David Woodhouse
Sam Ravnborg wrote:
> I know this is unix style to be very short in usage - but then they
> have man pages.
> Could we add a bit more from the nice description above to usage?
Good idea. Might as well make it visible.
David Woodhouse wrote:
> It'd be really nice if it could give its output in the same form as
> the .config file itself -- so it'd look something like:
>
> # CONFIG_FOO is not set
> CONFIG_BAR=y
OK, a new version is below. Right now, when printing in "merge" style,
the code omits items that are absent in the new config. These should get set
correctly (removed) if you do a 'make oldconfig'. It would be trivial
to have them output as well, if you think that would be better.
I am experimentally trying to attach a git-style file mode
to this patch. I did this by hand, so it might not work.
(The index line is totally made up). Let me know if there are problems.
Diffconfig is a simple utility for comparing two .config files.
See usage in the script for more info.
Signed-off-by: Tim Bird <tim.bird@am.sony.com>
scripts/diffconfig | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100755 scripts/diffconfig
diff --git a/scripts/diffconfig b/scripts/diffconfig
new file mode 100755
index 0000000..aa6cfe1
--- /dev/null
+++ b/scripts/diffconfig
@@ -0,0 +1,108 @@
+#!/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
+
+merge_style = 0
+if "-m" in sys.argv:
+ merge_style = 1
+ sys.argv.remove("-m")
+
+if "-h" in sys.argv or len(sys.argv) < 3:
+ print "Usage: diffconfig [-h] [-m] <config1> <config2>\n"
+ print """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.
+
+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
+
+a = readconfig(file(sys.argv[1]))
+b = readconfig(file(sys.argv[2]))
+
+def print_config(op, config, value, new_value):
+ 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)
+
+# 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
+
+# the items from b that were in a (either the same or that changed) were removed
+# the only items left were not in a
+new = b.keys()
+
+new.sort()
+
+for config in new:
+ print_config("+", config, None, b[config])
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-10 19:41 [PATCH] add diffconfig utility Tim Bird
` (2 preceding siblings ...)
2008-06-10 22:07 ` [PATCH] add diffconfig utility David Woodhouse
@ 2008-06-11 6:59 ` Holger Schurig
3 siblings, 0 replies; 18+ messages in thread
From: Holger Schurig @ 2008-06-11 6:59 UTC (permalink / raw)
To: Tim Bird; +Cc: linux-embedded, linux kernel
Nice.
Would it be helpful to compare .config.old to .config if you
don't provide any command line arguments?
scripts/diffconfig
would then do the job.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-11 0:25 ` Tim Bird
@ 2008-06-11 11:28 ` Geert Uytterhoeven
2008-06-11 18:23 ` Tim Bird
0 siblings, 1 reply; 18+ messages in thread
From: Geert Uytterhoeven @ 2008-06-11 11:28 UTC (permalink / raw)
To: Tim Bird; +Cc: Sam Ravnborg, linux-embedded, linux kernel, David Woodhouse
[-- Attachment #1: Type: TEXT/PLAIN, Size: 778 bytes --]
On Tue, 10 Jun 2008, Tim Bird wrote:
> +merge_style = 0
> +if "-m" in sys.argv:
> + merge_style = 1
> + sys.argv.remove("-m")
> +
> +if "-h" in sys.argv or len(sys.argv) < 3:
^^^
No checking for excess arguments?
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Techsoft Centre
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/
Sony Technology and Software Centre Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis 293-0376800-10 GEBA-BE-BB
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-11 11:28 ` Geert Uytterhoeven
@ 2008-06-11 18:23 ` Tim Bird
2008-06-12 13:19 ` Sam Ravnborg
0 siblings, 1 reply; 18+ messages in thread
From: Tim Bird @ 2008-06-11 18:23 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Sam Ravnborg, linux-embedded, linux kernel, David Woodhouse,
Holger Schurig
Geert Uytterhoeven wrote:
> No checking for excess arguments?
Holger Schurig wrote:
> Would it be helpful to compare .config.old to .config if you
> don't provide any command line arguments?
Both good ideas. These are implemented in the latest version.
Note that I check for and use KBUILD_OUTPUT. (I always put
my build output outside the source directory, since
I usually build for multiple arches from a single tree.)
The program is also now better structured, IMHO.
-- Tim
Diffconfig is a simple utility for comparing two .config files.
See usage in the script for more info.
Signed-off-by: Tim Bird <tim.bird@am.sony.com>
scripts/diffconfig | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100755 scripts/diffconfig
diff --git a/scripts/diffconfig b/scripts/diffconfig
new file mode 100755
index 0000000..aa6cfe1
--- /dev/null
+++ b/scripts/diffconfig
@@ -0,0 +1,128 @@
+#!/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>]\n"
+ print """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()
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-11 18:23 ` Tim Bird
@ 2008-06-12 13:19 ` Sam Ravnborg
2008-06-12 16:07 ` Tim Bird
2008-06-24 17:56 ` [PATCH] add diffconfig utility (v2) Tim Bird
0 siblings, 2 replies; 18+ messages in thread
From: Sam Ravnborg @ 2008-06-12 13:19 UTC (permalink / raw)
To: Tim Bird
Cc: Geert Uytterhoeven, linux-embedded, linux kernel, David Woodhouse,
Holger Schurig
Hi Tim.
> The program is also now better structured, IMHO.
> -- Tim
Seeing this programs gets frequent updates (good!) I have not
yet applied it.
When you consider it stabilized could you please drop me a
new mail including full changelog and updated patch.
And please cc: linux-kbuild@vger.kernel.org + linux-kernel on the
submission.
Thanks,
Sam
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility
2008-06-12 13:19 ` Sam Ravnborg
@ 2008-06-12 16:07 ` Tim Bird
2008-06-24 17:56 ` [PATCH] add diffconfig utility (v2) Tim Bird
1 sibling, 0 replies; 18+ messages in thread
From: Tim Bird @ 2008-06-12 16:07 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Geert Uytterhoeven, linux-embedded, linux kernel, David Woodhouse,
Holger Schurig
Sam Ravnborg wrote:
> Hi Tim.
>
>> The program is also now better structured, IMHO.
>> -- Tim
>
> Seeing this programs gets frequent updates (good!) I have not
> yet applied it.
>
> When you consider it stabilized could you please drop me a
> new mail including full changelog and updated patch.
>
> And please cc: linux-kbuild@vger.kernel.org + linux-kernel on the
> submission.
Will do. I'll give it a little settle time, and then
notify you.
-- Tim
=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] add diffconfig utility (v2)
2008-06-12 13:19 ` Sam Ravnborg
2008-06-12 16:07 ` Tim Bird
@ 2008-06-24 17:56 ` Tim Bird
2008-06-27 21:10 ` Sam Ravnborg
1 sibling, 1 reply; 18+ messages in thread
From: Tim Bird @ 2008-06-24 17:56 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-embedded, linux kernel, linux-kbuild
Sam Ravnborg wrote:
> When you consider it stabilized could you please drop me a
> new mail including full changelog and updated patch.
>
> And please cc: linux-kbuild@vger.kernel.org + linux-kernel on the
> submission.
Sam,
I haven't gotten any more feedback, and I believe I've addressed
all previous feedback.
As for the ChangeLog, here's some information about history and
recent changes. I can put this in the patch/script if desired.
CHANGELOG:
2008-06-24 - Tim Bird <tim.bird@am.sony.com> - add usage function,
add -m feature for merge-style output, use .config and .config.old
by default, improve command line handling
~2007 - Tim Bird - re-format code for internal use at Sony
~2006 - Matt Mackall - create original diffconfig tool as part of
bloatwatch project
Diffconfig is a simple utility for comparing two kernel configuration files.
See usage in the script for more info.
Signed-off-by: Tim Bird <tim.bird@am.sony.com>
scripts/diffconfig | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
create mode 100755 scripts/diffconfig
diff --git a/scripts/diffconfig b/scripts/diffconfig
new file mode 100755
index 0000000..aa6cfe1
--- /dev/null
+++ b/scripts/diffconfig
@@ -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()
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] add diffconfig utility (v2)
2008-06-24 17:56 ` [PATCH] add diffconfig utility (v2) Tim Bird
@ 2008-06-27 21:10 ` Sam Ravnborg
0 siblings, 0 replies; 18+ messages in thread
From: Sam Ravnborg @ 2008-06-27 21:10 UTC (permalink / raw)
To: Tim Bird; +Cc: linux-embedded, linux kernel, linux-kbuild
On Tue, Jun 24, 2008 at 10:56:06AM -0700, Tim Bird wrote:
> Sam Ravnborg wrote:
> > When you consider it stabilized could you please drop me a
> > new mail including full changelog and updated patch.
> >
> > And please cc: linux-kbuild@vger.kernel.org + linux-kernel on the
> > submission.
>
> Sam,
>
> I haven't gotten any more feedback, and I believe I've addressed
> all previous feedback.
Thanks, applied
Sam
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2008-06-27 21:10 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-10 19:41 [PATCH] add diffconfig utility Tim Bird
2008-06-10 21:02 ` Jörn Engel
2008-06-10 21:18 ` Sam Ravnborg
2008-06-10 21:33 ` execute bit on scripts (was Re: [PATCH] add diffconfig utility) Tim Bird
2008-06-10 22:26 ` Jan Engelhardt
2008-06-10 21:21 ` [PATCH] add diffconfig utility Sam Ravnborg
2008-06-11 0:25 ` Tim Bird
2008-06-11 11:28 ` Geert Uytterhoeven
2008-06-11 18:23 ` Tim Bird
2008-06-12 13:19 ` Sam Ravnborg
2008-06-12 16:07 ` Tim Bird
2008-06-24 17:56 ` [PATCH] add diffconfig utility (v2) Tim Bird
2008-06-27 21:10 ` Sam Ravnborg
2008-06-10 22:07 ` [PATCH] add diffconfig utility David Woodhouse
2008-06-10 22:33 ` Tim Bird
2008-06-10 23:02 ` Arjan van de Ven
2008-06-10 23:10 ` David Woodhouse
2008-06-11 6:59 ` Holger Schurig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).