aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile20
-rw-r--r--init/Kconfig16
-rw-r--r--scripts/setlocalversion56
3 files changed, 92 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index d01b004a2a0e..c6aae86a02cd 100644
--- a/Makefile
+++ b/Makefile
@@ -548,6 +548,26 @@ export KBUILD_IMAGE ?= vmlinux
548# images. Default is /boot, but you can set it to other values 548# images. Default is /boot, but you can set it to other values
549export INSTALL_PATH ?= /boot 549export INSTALL_PATH ?= /boot
550 550
551# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests
552# and try to determine if the current source tree is a release tree, of any sort,
553# or if is a pure development tree.
554#
555# A 'release tree' is any tree with a git TAG associated
556# with it. The primary goal of this is to make it safe for a native
557# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to
558# continue developing against the current Linus tree, without having the Linus
559# tree overwrite the 2.6.9 tree when installed.
560#
561# Currently, only git is supported.
562# Other SCMs can edit scripts/setlocalversion and add the appropriate
563# checks as needed.
564
565
566ifdef CONFIG_LOCALVERSION_AUTO
567 localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree))
568 LOCALVERSION := $(LOCALVERSION)$(localversion-auto)
569endif
570
551# 571#
552# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 572# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
553# relocations required by build roots. This is not defined in the 573# relocations required by build roots. This is not defined in the
diff --git a/init/Kconfig b/init/Kconfig
index eb86972be1c2..f27fc48c1fdc 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -77,6 +77,22 @@ config LOCALVERSION
77 object and source tree, in that order. Your total string can 77 object and source tree, in that order. Your total string can
78 be a maximum of 64 characters. 78 be a maximum of 64 characters.
79 79
80config LOCALVERSION_AUTO
81 bool "Automatically append version information to the version string"
82 default y
83 help
84 This will try to automatically determine if the current tree is a
85 release tree by looking for git tags that
86 belong to the current top of tree revision.
87
88 A string of the format -gxxxxxxxx will be added to the localversion
89 if a git based tree is found. The string generated by this will be
90 appended after any matching localversion* files, and after the value
91 set in CONFIG_LOCALVERSION
92
93 Note: This requires Perl, and a git repository, but not necessarily
94 the git or cogito tools to be installed.
95
80config SWAP 96config SWAP
81 bool "Support for paging of anonymous memory (swap)" 97 bool "Support for paging of anonymous memory (swap)"
82 depends on MMU 98 depends on MMU
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
new file mode 100644
index 000000000000..7c805c8fccd2
--- /dev/null
+++ b/scripts/setlocalversion
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2# Copyright 2004 - Ryan Anderson <ryan@michonline.com> GPL v2
3
4use strict;
5use warnings;
6use Digest::MD5;
7require 5.006;
8
9if (@ARGV != 1) {
10 print <<EOT;
11Usage: setlocalversion <srctree>
12EOT
13 exit(1);
14}
15
16my ($srctree) = @ARGV;
17chdir($srctree);
18
19my @LOCALVERSIONS = ();
20
21# We are going to use the following commands to try and determine if this
22# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We
23# currently assume that all meaningful version boundaries are marked by a tag.
24# We don't care what the tag is, just that something exists.
25
26# Git/Cogito store the top-of-tree "commit" in .git/HEAD
27# A list of known tags sits in .git/refs/tags/
28#
29# The simple trick here is to just compare the two of these, and if we get a
30# match, return nothing, otherwise, return a subset of the SHA-1 hash in
31# .git/HEAD
32
33sub do_git_checks {
34 open(H,"<.git/HEAD") or return;
35 my $head = <H>;
36 chomp $head;
37 close(H);
38
39 opendir(D,".git/refs/tags") or return;
40 foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) {
41 open(F,"<.git/refs/tags/" . $tagfile) or return;
42 my $tag = <F>;
43 chomp $tag;
44 close(F);
45 return if ($tag eq $head);
46 }
47 closedir(D);
48
49 push @LOCALVERSIONS, "g" . substr($head,0,8);
50}
51
52if ( -d ".git") {
53 do_git_checks();
54}
55
56printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0);