Commit 85a256d8 authored by David Rientjes's avatar David Rientjes Committed by Michal Marek

kbuild: improve version string logic

The LOCALVERSION= string passed to "make" will now always be appended to
the kernel version after CONFIG_LOCALVERSION, if it exists, regardless of
whether CONFIG_LOCALVERSION_AUTO is set or not.  This allows users to
uniquely identify their kernel builds with a string.

If CONFIG_LOCALVERSION_AUTO is enabled, the unique SCM tag reported by
setlocalversion (or .scmversion) is appended to the kernel version, if it
exists.  When CONFIG_LOCALVERSION_AUTO is not enabled, a `+' is appended
to the kernel version to represent that the kernel has been revised since
the last release unless "make LOCALVERSION=" was used to uniquely identify
the build.

The end result is this:

 - when LOCALVERSION= is passed to "make", it is appended to the kernel
   version,

 - when CONFIG_LOCALVERSION_AUTO is enabled, a unique SCM identifier is
   appended if the respository has been revised beyond a tagged commit,
   and

 - when CONFIG_LOCALVERSION_AUTO is disabled, a `+' is appended if the
   repository has been revised beyond a tagged commit and LOCALVERSION=
   was not passed to "make".

Examples:

With CONFIG_LOCALVERSION_AUTO: "make" results in
v2.6.32-rc4-00149-ga3ccf63e.  If there are uncommited changes to the
respository, it results in v2.6.32-rc4-00149-ga3ccf63e-dirty.  If
"make LOCALVERSION=kbuild" were used, it results in
v2.6.32-rc4-kbuild-00149-ga3ccf63e-dirty.

Without CONFIG_LOCALVERSION_AUTO, "make" results in v2.6.32-rc4+
unless the repository is at the Linux v2.6.32-rc4 commit (in which
case the version would be v2.6.32-rc4).  If "make LOCALVERSION=kbuild"
were used, it results in v2.6.32-rc4-kbuild.

Also renames variables such as localver-auto and _localver-auto to more
accurately describe what they represent: localver-extra and
scm-identifier, respectively.
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 68c16edd
...@@ -910,14 +910,19 @@ endif ...@@ -910,14 +910,19 @@ endif
# $(localver) # $(localver)
# localversion* (files without backups, containing '~') # localversion* (files without backups, containing '~')
# $(CONFIG_LOCALVERSION) (from kernel config setting) # $(CONFIG_LOCALVERSION) (from kernel config setting)
# $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set) # $(LOCALVERSION) (from make command line, if provided)
# ./scripts/setlocalversion (SCM tag, if one exists) # $(localver-extra)
# $(LOCALVERSION) (from make command line if provided) # $(scm-identifier) (unique SCM tag, if one exists)
# ./scripts/setlocalversion (only with CONFIG_LOCALVERSION_AUTO)
# .scmversion (only with CONFIG_LOCALVERSION_AUTO)
# + (only without CONFIG_LOCALVERSION_AUTO
# and without LOCALVERSION= and
# repository is at non-tagged commit)
# #
# Note how the final $(localver-auto) string is included *only* if the # For kernels without CONFIG_LOCALVERSION_AUTO compiled from an SCM that has
# kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the # been revised beyond a tagged commit, `+' is appended to the version string
# moment, only git is supported but other SCMs can edit the script # when not overridden by using "make LOCALVERSION=". This indicates that the
# scripts/setlocalversion and add the appropriate checks as needed. # kernel is not a vanilla release version and has been modified.
pattern = ".*/localversion[^~]*" pattern = ".*/localversion[^~]*"
string = $(shell cat /dev/null \ string = $(shell cat /dev/null \
...@@ -926,26 +931,32 @@ string = $(shell cat /dev/null \ ...@@ -926,26 +931,32 @@ string = $(shell cat /dev/null \
localver = $(subst $(space),, $(string) \ localver = $(subst $(space),, $(string) \
$(patsubst "%",%,$(CONFIG_LOCALVERSION))) $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called # scripts/setlocalversion is called to create a unique identifier if the source
# and if the SCM is know a tag from the SCM is appended. # is managed by a known SCM and the repository has been revised since the last
# The appended tag is determined by the SCM used. # tagged (release) commit. The format of the identifier is determined by the
# SCM's implementation.
# #
# .scmversion is used when generating rpm packages so we do not loose # .scmversion is used when generating rpm packages so we do not loose
# the version information from the SCM when we do the build of the kernel # the version information from the SCM when we do the build of the kernel
# from the copied source # from the copied source
ifdef CONFIG_LOCALVERSION_AUTO
ifeq ($(wildcard .scmversion),) ifeq ($(wildcard .scmversion),)
_localver-auto = $(shell $(CONFIG_SHELL) \ scm-identifier = $(shell $(CONFIG_SHELL) \
$(srctree)/scripts/setlocalversion $(srctree)) $(srctree)/scripts/setlocalversion $(srctree))
else else
_localver-auto = $(shell cat .scmversion 2> /dev/null) scm-identifier = $(shell cat .scmversion 2> /dev/null)
endif endif
localver-auto = $(LOCALVERSION)$(_localver-auto) ifdef CONFIG_LOCALVERSION_AUTO
localver-extra = $(scm-identifier)
else
ifneq ($scm-identifier,)
ifeq ($(LOCALVERSION),)
localver-extra = +
endif
endif
endif endif
localver-full = $(localver)$(localver-auto) localver-full = $(localver)$(LOCALVERSION)$(localver-extra)
# Store (new) KERNELRELASE string in include/config/kernel.release # Store (new) KERNELRELASE string in include/config/kernel.release
kernelrelease = $(KERNELVERSION)$(localver-full) kernelrelease = $(KERNELVERSION)$(localver-full)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment