linux-embedded.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Tim Bird <tim.bird@am.sony.com>
Cc: linux-embedded <linux-embedded@vger.kernel.org>,
	linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] add diffconfig utility
Date: Tue, 10 Jun 2008 23:21:58 +0200	[thread overview]
Message-ID: <20080610212158.GB23855@uranus.ravnborg.org> (raw)
In-Reply-To: <484ED902.9040000@am.sony.com>

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

  parent reply	other threads:[~2008-06-10 21:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Sam Ravnborg [this message]
2008-06-11  0:25   ` [PATCH] add diffconfig utility 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080610212158.GB23855@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=linux-embedded@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim.bird@am.sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).