public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Frans Pop <elendil@planet.nl>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-kernel@vger.kernel.org, zippel@linux-m68k.org,
	mingo@elte.hu, akpm@linux-foundation.org,
	torvalds@linux-foundation.org
Subject: Re: [PATCH RFC] kconfig: place git SHA1 in .config output if in git tree
Date: Mon, 1 Mar 2010 10:16:16 -0800	[thread overview]
Message-ID: <20100301181616.GD6758@linux.vnet.ibm.com> (raw)
In-Reply-To: <201003011753.34299.elendil@planet.nl>

On Mon, Mar 01, 2010 at 05:53:32PM +0100, Frans Pop wrote:
> On Monday 01 March 2010, Paul E. McKenney wrote:
> > Here is the updated patch.  Thoughts?
> 
> AFAICT that still won't work with KBUILD_OUTPUT as you're not passing the 
> source tree directory to the script. So it will default to "." and when 
> KBUILD_OUTPUT is used that is not the source tree but the target tree (and 
> thus not under git).

Hmmm...  In that case, it won't find the scripts/setlocalversion script,
either.  Unless you have the git tree on your $PATH, which seems
unlikely.  So I can just check for popen() failure and take corrective
action.

Taking a look at conf_get_default_confname(), it looks like one approach
would be to prepend getenv(SRCTREE) to the name of the script and also
pass this to the script.  Will that work for your setup?  If so, please
see below for the updated patch.

							Thanx, Paul

------------------------------------------------------------------------

[PATCH RFC] kconfig: place localversion string in .config output

This patch appends the localversion string to the Linux kernel version.
For example, in a git tree with uncommitted changes, the .config file
might start as follows:

# Automatically generated make config: don't edit
# Linux kernel version: 2.6.33-01836-g90a6501-dirty
# Mon Mar  1 08:21:49 2010

This patch uses the scripts/setlocalversion output, so similar output
is also generated for svn and mercurial.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Frans Pop <elendil@planet.nl>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---

 confdata.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80..4c28ea5 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -399,10 +399,12 @@ int conf_read(const char *name)
 int conf_write(const char *name)
 {
 	FILE *out;
+	FILE *slv;
 	struct symbol *sym;
 	struct menu *menu;
 	const char *basename;
-	char dirname[128], tmpname[128], newname[128];
+	char dirname[128], tmpname[128], newname[128], localversion[128];
+	char cmdline[PATH_MAX * 2 + 128];
 	int type, l;
 	const char *str;
 	time_t now;
@@ -450,12 +452,27 @@ int conf_write(const char *name)
 	if (env && *env)
 		use_timestamp = 0;
 
+	localversion[0] = '\0';
+	slv = popen("scripts/setlocalversion 2> /dev/null", "r");
+	if (slv == NULL) {
+		env = getenv(SRCTREE);
+		if (env) {
+			sprintf(cmdline, "%s/scripts/setlocalversion %s 2> /dev/null", env, env);
+			slv = popen(cmdline, "r");
+		}
+	}
+	if (slv != NULL) {
+		fscanf(slv, " %127s ", localversion);
+		pclose(slv);
+	}
+
 	fprintf(out, _("#\n"
 		       "# Automatically generated make config: don't edit\n"
-		       "# Linux kernel version: %s\n"
+		       "# Linux kernel version: %s%s\n"
 		       "%s%s"
 		       "#\n"),
 		     sym_get_string_value(sym),
+		     localversion[0] != '\0' ? localversion : "",
 		     use_timestamp ? "# " : "",
 		     use_timestamp ? ctime(&now) : "");
 

  reply	other threads:[~2010-03-01 18:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01  4:22 [PATCH RFC] kconfig: place git SHA1 in .config output if in git tree Paul E. McKenney
2010-03-01  8:34 ` Ingo Molnar
2010-03-01  9:42 ` Frans Pop
2010-03-01 10:10   ` Geert Uytterhoeven
2010-03-01 16:27     ` Paul E. McKenney
2010-03-01 16:53       ` Frans Pop
2010-03-01 18:16         ` Paul E. McKenney [this message]
2010-03-01 20:29           ` Frans Pop
2010-03-02  1:16             ` Paul E. McKenney
2010-03-02 15:19               ` Frans Pop
2010-03-03  0:01                 ` Paul E. McKenney
2010-03-03  0:42                   ` Frans Pop
2010-03-03  2:19                     ` Paul E. McKenney
2010-03-01 16:22 ` Linus Torvalds
2010-03-01 16:48   ` Paul E. McKenney
2010-03-01 20:46     ` James Cloos
2010-03-02  1:20       ` Paul E. McKenney
2010-03-02  1:53         ` James Cloos
2010-03-02  5:21           ` Paul E. McKenney

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=20100301181616.GD6758@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=elendil@planet.nl \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    --cc=zippel@linux-m68k.org \
    /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