public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM
@ 2010-03-05 19:43 Paul E. McKenney
  2010-03-05 19:44 ` [PATCH tip/core/rcu 1/2] kconfig: place localversion string in .config output Paul E. McKenney
  2010-03-08 15:01 ` [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Michal Marek
  0 siblings, 2 replies; 5+ messages in thread
From: Paul E. McKenney @ 2010-03-05 19:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: zippel, mingo, akpm, torvalds, geert, elendil, cloos

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 (but with leading hash marks):

	Automatically generated make config: don't edit
	Linux kernel version: 2.6.33-01836-g90a6501-dirty
	Mon Mar  1 17:05:59 2010

The "-01836-g90a6501-dirty" string is added by this patch.

The KBUILD_CONFIG_NO_CHECK_DIRTY environment variable controls the
git "-dirty" check.  If this variable is either empty or undefined,
then a "-dirty" check is performed (the default), otherwise, this
check is omitted.

Differences from v3 (http://lkml.org/lkml/2010/3/4/520):

o	Print errors to stderr, using gcc error format so that scripts
	that pull errors from build output will find them.

o	Make error strings placed in .config file more comprehensible.

o	Make parent warn of child error return (via wait() system call).

Differences from v2 (http://lkml.org/lkml/2010/3/2/570):

o	Replace popen() with the equivalent fork-exec series
	to prevent security vulnerabilities due to shell metacharacter
	interpretation.

o	Added the KBUILD_CONFIG_NO_CHECK_DIRTY environment variable,
	and modified scripts/setlocalversion to check it, as suggested
	by James Cloos.

Differences from v1 (http://lkml.org/lkml/2010/2/28/191):

o	Incorporates feedback from Geert Uytterhoeven, Linus Torvalds,
	Frans Pop, and James Cloos.

o	Fixed to work correctly with the "O=" Makefile argument and
	the KBUILD_OUTPUT environment variable, so that .config files
	created in directories outside of the source tree are tagged
	correctly.

o	Uses scripts/setlocalversion, which handles not only git, but
	also mercurial and svn.

o	Make the new behavior default-off, as scripts/setlocalversion
	has significant latency.  A new environment variable named
	"KBUILD_CONFIG_LOCALVERSION" must be set to enable the
	"-01836-g90a6501-dirty" style of string.

	This is intended to address James Cloos's concern that this
	feature will slow down casual kernel builds.

It has been suggested that this string be output at boot and oops time.
If there is general agreement, this will be the subject of a separate
patch.

 kconfig/confdata.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 setlocalversion    |   18 +++++++------
 2 files changed, 76 insertions(+), 11 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 1/2] kconfig: place localversion string in .config output
  2010-03-05 19:43 [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Paul E. McKenney
@ 2010-03-05 19:44 ` Paul E. McKenney
  2010-03-05 19:44   ` [PATCH tip/core/rcu 2/2] kconfig: make setlocalversion -dirty check optional Paul E. McKenney
  2010-03-08 15:01 ` [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Michal Marek
  1 sibling, 1 reply; 5+ messages in thread
From: Paul E. McKenney @ 2010-03-05 19:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: zippel, mingo, akpm, torvalds, geert, elendil, cloos,
	Paul E. McKenney

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 (but with leading hash marks):

	Automatically generated make config: don't edit
	Linux kernel version: 2.6.33-01836-g90a6501-dirty
	Mon Mar  1 17:05:59 2010

The "-01836-g90a6501-dirty" string is added by this patch.

The KBUILD_CONFIG_NO_CHECK_DIRTY environment variable controls the
git "-dirty" check.  If this variable is either empty or undefined,
then a "-dirty" check is performed (the default), otherwise, this
check is omitted.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Suggested-by: Frans Pop <elendil@planet.nl>
Suggested-by: James Cloos <cloos@jhcloos.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.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>
---
 scripts/kconfig/confdata.c |   68 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80..99d16b4 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -3,6 +3,7 @@
  * Released under the terms of the GNU GPL v2.0.
  */
 
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include <fcntl.h>
@@ -11,10 +12,13 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/wait.h>
 
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
+extern char **environ;
+
 static void conf_warning(const char *fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
 
@@ -399,15 +403,20 @@ 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;
 	int use_timestamp = 1;
+	int pipefd[2];
 	char *env;
+	char *path;
+	pid_t pid;
 
 	dirname[0] = 0;
 	if (name && name[0]) {
@@ -450,12 +459,67 @@ int conf_write(const char *name)
 	if (env && *env)
 		use_timestamp = 0;
 
+	sprintf(localversion, "-error: %s:%d", __FILE__, __LINE__);
+	path = getenv(SRCTREE);
+	if (path && *path) {
+		sprintf(localversion, "-error: %s:%d", __FILE__, __LINE__);
+		if (pipe(pipefd) != 0) {
+			fprintf(stderr, "%s:%d error: pipe() failed\n",
+				__FILE__, __LINE__);
+			goto nolocalversion;
+		}
+		sprintf(cmdline, "%s/scripts/setlocalversion", path);
+		sprintf(localversion, "-error: %s:%d", __FILE__, __LINE__);
+		fflush(stderr);
+		pid = fork();
+		if (pid < 0) {
+			fprintf(stderr, "%s:%d error: fork() failed\n",
+				__FILE__, __LINE__);
+			goto nolocalversion;
+		}
+		if (pid == 0) { /* child */
+			char *newargv[] = { cmdline, path, NULL };
+
+			close(1); /* stdout */
+			if (dup2(pipefd[1], 1) < 0) {
+				fprintf(stderr, "%s:%d error: dup2() failed\n",
+					__FILE__, __LINE__);
+				fflush(stderr);
+				_exit(1);
+			}
+			execve(cmdline, newargv, environ);
+			fprintf(stderr, "%s:%d error: execve() failed\n",
+				__FILE__, __LINE__);
+			fflush(stderr);
+			_exit(2);
+		} else { /* parent */
+			int chldstatus = 0;
+
+			localversion[0] = '\0';
+			slv = fdopen(pipefd[0], "r");
+			if (slv != NULL) {
+				close(pipefd[1]);
+				fscanf(slv, " %127s ", localversion);
+				/* can have EOF if no SCM. */
+				if (wait(&chldstatus) < 0 || chldstatus != 0) {
+					fprintf(stderr,
+						"%s:%d error: child failed\n",
+						__FILE__, __LINE__);
+					sprintf(localversion, "-error: %s:%d",
+						__FILE__, __LINE__);
+				}
+			}
+		}
+	}
+nolocalversion:
+
 	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,
 		     use_timestamp ? "# " : "",
 		     use_timestamp ? ctime(&now) : "");
 
-- 
1.6.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH tip/core/rcu 2/2] kconfig: make setlocalversion -dirty check optional
  2010-03-05 19:44 ` [PATCH tip/core/rcu 1/2] kconfig: place localversion string in .config output Paul E. McKenney
@ 2010-03-05 19:44   ` Paul E. McKenney
  0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2010-03-05 19:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: zippel, mingo, akpm, torvalds, geert, elendil, cloos,
	Paul E. McKenney

The git commands that check for uncommitted changes can be quite
expensive, so this patch introduces an environment variable named
KBUILD_CONFIG_NO_CHECK_DIRTY to control these checks for git.
If KBUILD_CONFIG_NO_CHECK_DIRTY is unset or is set to an empty
string, the dirty checks are performed (the default).  Otherwise,
KBUILD_CONFIG_NO_CHECK_DIRTY is set to some non-empty string, and the
dirty checks are omitted.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 scripts/setlocalversion |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 46989b8..3d4ff84 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -39,13 +39,16 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 	        printf -- '-svn%s' "`git svn find-rev $head`"
 	fi
 
-	# Update index only on r/w media
-	[ -w . ] && git update-index --refresh --unmerged > /dev/null
-
-	# Check for uncommitted changes
-	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
-	    | read dummy; then
-		printf '%s' -dirty
+	if [ -z "$KBUILD_CONFIG_NO_CHECK_DIRTY" ]; then
+		# Update index only on r/w media
+		[ -w . ] && git update-index --refresh --unmerged > /dev/null
+
+		# Check for uncommitted changes
+		if git diff-index --name-only HEAD \
+		    | grep -v "^scripts/package" \
+		    | read dummy; then
+			printf '%s' -dirty
+		fi
 	fi
 
 	# All done with git
-- 
1.6.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM
  2010-03-05 19:43 [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Paul E. McKenney
  2010-03-05 19:44 ` [PATCH tip/core/rcu 1/2] kconfig: place localversion string in .config output Paul E. McKenney
@ 2010-03-08 15:01 ` Michal Marek
  2010-03-11  2:59   ` Paul E. McKenney
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Marek @ 2010-03-08 15:01 UTC (permalink / raw)
  To: paulmck; +Cc: linux-kernel, zippel, mingo, akpm, torvalds, geert, elendil,
	cloos

On 5.3.2010 20:43, Paul E. McKenney wrote:
> 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 (but with leading hash marks):
> 
> 	Automatically generated make config: don't edit
> 	Linux kernel version: 2.6.33-01836-g90a6501-dirty
> 	Mon Mar  1 17:05:59 2010
> 
> The "-01836-g90a6501-dirty" string is added by this patch.

kbuild in linux-next already has
commit 85a256d8e0116c8f5ad276730830f5d4d473344d
Author: David Rientjes <rientjes@google.com>
Date:   Wed Jan 13 13:01:05 2010 -0800

    kbuild: improve version string logic

which results in a scripts/setlocalversion call during each build. And
with CONFIG_LOCALVERSION_AUTO, it stores exactly the string you want in
include/config/kernel.release. So we could change kconfig to read that
file instead of building the version string again. To also cover the
!CONFIG_LOCALVERSION_AUTO case, we can add a
include/config/kernel.release.full file to hold the full string each time.

Sorry for jumping in so late in the discussion, I had a bit of backlog
in mail directed to me and linux-kbuild@vger.kernel.org, let alone LKML ;).

Michal

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM
  2010-03-08 15:01 ` [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Michal Marek
@ 2010-03-11  2:59   ` Paul E. McKenney
  0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2010-03-11  2:59 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kernel, zippel, mingo, akpm, torvalds, geert, elendil,
	cloos

On Mon, Mar 08, 2010 at 04:01:23PM +0100, Michal Marek wrote:
> On 5.3.2010 20:43, Paul E. McKenney wrote:
> > 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 (but with leading hash marks):
> > 
> > 	Automatically generated make config: don't edit
> > 	Linux kernel version: 2.6.33-01836-g90a6501-dirty
> > 	Mon Mar  1 17:05:59 2010
> > 
> > The "-01836-g90a6501-dirty" string is added by this patch.
> 
> kbuild in linux-next already has
> commit 85a256d8e0116c8f5ad276730830f5d4d473344d
> Author: David Rientjes <rientjes@google.com>
> Date:   Wed Jan 13 13:01:05 2010 -0800
> 
>     kbuild: improve version string logic
> 
> which results in a scripts/setlocalversion call during each build. And
> with CONFIG_LOCALVERSION_AUTO, it stores exactly the string you want in
> include/config/kernel.release. So we could change kconfig to read that
> file instead of building the version string again. To also cover the
> !CONFIG_LOCALVERSION_AUTO case, we can add a
> include/config/kernel.release.full file to hold the full string each time.
> 
> Sorry for jumping in so late in the discussion, I had a bit of backlog
> in mail directed to me and linux-kbuild@vger.kernel.org, let alone LKML ;).

Thank you for the pointer, I will take a look.

							Thanx, Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-11  2:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-05 19:43 [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Paul E. McKenney
2010-03-05 19:44 ` [PATCH tip/core/rcu 1/2] kconfig: place localversion string in .config output Paul E. McKenney
2010-03-05 19:44   ` [PATCH tip/core/rcu 2/2] kconfig: make setlocalversion -dirty check optional Paul E. McKenney
2010-03-08 15:01 ` [PATCH 0/2] v4 kconfig: place git SHA1 in .config output if in SCM Michal Marek
2010-03-11  2:59   ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox