History log of /linux-master/scripts/setlocalversion
Revision Date Author Comments
# 01e89a4a 04-Aug-2023 Rasmus Villemoes <linux@rasmusvillemoes.dk>

scripts/setlocalversion: also consider annotated tags of the form vx.y.z-${file_localversion}

Commit 6ab7e1f95e96 ("setlocalversion: use only the correct release
tag for git-describe") was absolutely correct to limit which annotated
tags would be used to compute the -01234-gabcdef suffix. Otherwise, if
some random annotated tag exists closer to HEAD than the vX.Y.Z one,
the commit count would be too low.

However, since the version string always includes the
${file_localversion} part, now the problem is that the count can be
too high. For example, building an 6.4.6-rt8 kernel with a few patches
on top, I currently get

$ make -s kernelrelease
6.4.6-rt8-00128-gd78b7f406397

But those 128 commits include the 100 commits that are in
v6.4.6..v6.4.6-rt8, so this is somewhat misleading.

Amend the logic so that, in addition to the linux-next consideration,
the script also looks for a tag corresponding to the 6.4.6-rt8 part of
what will become the `uname -r` string. With this patch (so 29 patches
on top of v6.4.6-rt8), one instead gets

$ make -s kernelrelease
6.4.6-rt8-00029-gd533209291a2

While there, note that the line

git describe --exact-match --match=$tag $tag 2>/dev/null

obviously asks if $tag is an annotated tag, but it does not actually
tell if the commit pointed to has any relation to HEAD. So remove both
uses of --exact-match, and instead just ask if the description
generated is identical to the tag we provided. Since we then already
have the result of

git describe --match=$tag

we also end up reducing the number of times we invoke "git describe".

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 3354c64d 03-Aug-2023 Rasmus Villemoes <linux@rasmusvillemoes.dk>

scripts/setlocalversion: clean up stale comment

Nobody has complained since 2a73cce2dad3 ("scripts/setlocalversion:
remove mercurial, svn and git-svn supports"), so let's also clean up
the header comment accordingly.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 05e96e96 15-Mar-2023 Masahiro Yamada <masahiroy@kernel.org>

kbuild: use git-archive for source package creation

Commit 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git")
added a new tool, scripts/list-gitignored. My intention was to create
source packages without cleaning the source tree, without relying on git.

Linus strongly objected to it, and suggested using 'git archive' instead.
[1] [2] [3]

This commit goes in that direction - Remove scripts/list-gitignored.c
and rewrites Makefiles and scripts to use 'git archive' for building
Debian and RPM source packages. It also makes 'make perf-tar*-src-pkg'
use 'git archive' again.

Going forward, building source packages is only possible in a git-managed
tree. Building binary packages does not require git.

[1]: https://lore.kernel.org/lkml/CAHk-=wi49sMaC7vY1yMagk7eqLK=1jHeHQ=yZ_k45P=xBccnmA@mail.gmail.com/
[2]: https://lore.kernel.org/lkml/CAHk-=wh5AixGsLeT0qH2oZHKq0FLUTbyTw4qY921L=PwYgoGVw@mail.gmail.com/
[3]: https://lore.kernel.org/lkml/CAHk-=wgM-W6Fu==EoAVCabxyX8eYBz9kNC88-tm9ExRQwA79UQ@mail.gmail.com/

Fixes: 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git")
Fixes: e0ca16749ac3 ("kbuild: make perf-tar*-src-pkg work without relying on git")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 6ab7e1f9 05-Feb-2023 Masahiro Yamada <masahiroy@kernel.org>

setlocalversion: use only the correct release tag for git-describe

Currently, setlocalversion uses any annotated tag for git-describe.
If we are at a tagged commit, it will not append the commit hash.

$ git checkout v6.2-rc1^
$ make -s defconfig kernelrelease
6.1.0-14595-g292a089d78d3
$ git tag -a foo -m foo
$ make -s kernelrelease
6.1.0

If a local tag 'foo' exists, it pretends to be a released version
'6.1.0', while there are many commits on top of it.

The output should be consistent irrespective of such a local tag.
Pass the correct release tag to --match option of git-describe.

In the mainline kernel, the SUBLEVEL is always '0', which is omitted
from the tag.

KERNELVERSION annotated tag
6.1.0 -> v6.1 (mainline)
6.2.0-rc5 -> v6.2-rc5 (mainline, release candidate)
6.1.7 -> v6.1.7 (stable)

To preserve the behavior in linux-next, use the tag derived from
localversion* files if exists. In linux-next, the local version is
specified by the localversion-next file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# eed36d77 05-Feb-2023 Masahiro Yamada <masahiroy@kernel.org>

setlocalversion: clean up the construction of version output

Concatenate all components in the last line instead of accumulating
them into the 'res' variable.

No functional change is intended. A preparation for the next change.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# ec31f868 22-Jan-2023 Masahiro Yamada <masahiroy@kernel.org>

setlocalversion: absorb $(KERNELVERSION)

Print $(KERNELVERSION) in setlocalversion so that the callers get
simpler.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 75280bdf 22-Jan-2023 Masahiro Yamada <masahiroy@kernel.org>

setlocalversion: make indentation shallower

Return earlier if we are not in the correct git repository. This makes
the code more readable.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


# 992ebfab 22-Jan-2023 Masahiro Yamada <masahiroy@kernel.org>

setlocalversion: simplify the construction of the short version

With the --short option given, scm_version() prints "+".
Just append it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


# f6e09b07 22-Jan-2023 Masahiro Yamada <masahiroy@kernel.org>

kbuild: do not put .scmversion into the source tarball

.scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE.

In fact, deb-pkg does not rely on it any more because the generated
debian/rules specifies KERNELRELEASE from the command line.

Do likwise for (src)rpm-pkg, and remove this feature.
For the same reason, you do not need to save LOCALVERSION in the
spec file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


# 129ab0d2 13-Dec-2021 Masahiro Yamada <masahiroy@kernel.org>

kbuild: do not quote string values in include/config/auto.conf

The previous commit fixed up all shell scripts to not include
include/config/auto.conf.

Now that include/config/auto.conf is only included by Makefiles,
we can change it into a more Make-friendly form.

Previously, Kconfig output string values enclosed with double-quotes
(both in the .config and include/config/auto.conf):

CONFIG_X="foo bar"

Unlike shell, Make handles double-quotes (and single-quotes as well)
verbatim. We must rip them off when used.

There are some patterns:

[1] $(patsubst "%",%,$(CONFIG_X))
[2] $(CONFIG_X:"%"=%)
[3] $(subst ",,$(CONFIG_X))
[4] $(shell echo $(CONFIG_X))

These are not only ugly, but also fragile.

[1] and [2] do not work if the value contains spaces, like
CONFIG_X=" foo bar "

[3] does not work correctly if the value contains double-quotes like
CONFIG_X="foo\"bar"

[4] seems to work better, but has a cost of forking a process.

Anyway, quoted strings were always PITA for our Makefiles.

This commit changes Kconfig to stop quoting in include/config/auto.conf.

These are the string type symbols referenced in Makefiles or scripts:

ACPI_CUSTOM_DSDT_FILE
ARC_BUILTIN_DTB_NAME
ARC_TUNE_MCPU
BUILTIN_DTB_SOURCE
CC_IMPLICIT_FALLTHROUGH
CC_VERSION_TEXT
CFG80211_EXTRA_REGDB_KEYDIR
EXTRA_FIRMWARE
EXTRA_FIRMWARE_DIR
EXTRA_TARGETS
H8300_BUILTIN_DTB
INITRAMFS_SOURCE
LOCALVERSION
MODULE_SIG_HASH
MODULE_SIG_KEY
NDS32_BUILTIN_DTB
NIOS2_DTB_SOURCE
OPENRISC_BUILTIN_DTB
SOC_CANAAN_K210_DTB_SOURCE
SYSTEM_BLACKLIST_HASH_LIST
SYSTEM_REVOCATION_KEYS
SYSTEM_TRUSTED_KEYS
TARGET_CPU
UNUSED_KSYMS_WHITELIST
XILINX_MICROBLAZE0_FAMILY
XILINX_MICROBLAZE0_HW_VER
XTENSA_VARIANT_NAME

I checked them one by one, and fixed up the code where necessary.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 7d153696 13-Dec-2021 Masahiro Yamada <masahiroy@kernel.org>

kbuild: do not include include/config/auto.conf from shell scripts

Richard Weinberger pointed out the risk of sourcing the kernel config
from shell scripts [1], and proposed some patches [2], [3]. It is a good
point, but it took a long time because I was wondering how to fix this.

This commit goes with simple grep approach because there are only a few
scripts including the kernel configuration.

scripts/link_vmlinux.sh has references to a bunch of CONFIG options,
all of which are boolean. I added is_enabled() helper as
scripts/package/{mkdebian,builddeb} do.

scripts/gen_autoksyms.sh uses 'eval', stating "to expand the whitelist
path". I removed it since it is the issue we are trying to fix.

I was a bit worried about the cost of invoking the grep command over
again. I extracted the grep parts from it, and measured the cost. It
was approximately 0.03 sec, which I hope is acceptable.

[test code]

$ cat test-grep.sh
#!/bin/sh

is_enabled() {
grep -q "^$1=y" include/config/auto.conf
}

is_enabled CONFIG_LTO_CLANG
is_enabled CONFIG_LTO_CLANG
is_enabled CONFIG_STACK_VALIDATION
is_enabled CONFIG_UNWINDER_ORC
is_enabled CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
is_enabled CONFIG_VMLINUX_VALIDATION
is_enabled CONFIG_FRAME_POINTER
is_enabled CONFIG_GCOV_KERNEL
is_enabled CONFIG_LTO_CLANG
is_enabled CONFIG_RETPOLINE
is_enabled CONFIG_X86_SMAP
is_enabled CONFIG_LTO_CLANG
is_enabled CONFIG_VMLINUX_MAP
is_enabled CONFIG_KALLSYMS_ALL
is_enabled CONFIG_KALLSYMS_ABSOLUTE_PERCPU
is_enabled CONFIG_KALLSYMS_BASE_RELATIVE
is_enabled CONFIG_DEBUG_INFO_BTF
is_enabled CONFIG_KALLSYMS
is_enabled CONFIG_DEBUG_INFO_BTF
is_enabled CONFIG_BPF
is_enabled CONFIG_BUILDTIME_TABLE_SORT
is_enabled CONFIG_KALLSYMS

$ time ./test-grep.sh
real 0m0.036s
user 0m0.027s
sys m0.009s

[1]: https://lore.kernel.org/all/1919455.eZKeABUfgV@blindfold/
[2]: https://lore.kernel.org/all/20180219092245.26404-1-richard@nod.at/
[3]: https://lore.kernel.org/all/20210920213957.1064-2-richard@nod.at/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>


# 5df99bec 12-Jul-2021 Mikulas Patocka <mpatocka@redhat.com>

scripts/setlocalversion: fix a bug when LOCALVERSION is empty

The commit 042da426f8eb ("scripts/setlocalversion: simplify the short
version part") reduces indentation. Unfortunately, it also changes behavior
in a subtle way - if the user has empty "LOCALVERSION" variable, the plus
sign is appended to the kernel version. It wasn't appended before.

This patch reverts to the old behavior - we append the plus sign only if
the LOCALVERSION variable is not set.

Fixes: 042da426f8eb ("scripts/setlocalversion: simplify the short version part")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 042da426 22-May-2021 Masahiro Yamada <masahiroy@kernel.org>

scripts/setlocalversion: simplify the short version part

Reduce the indentation.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>


# 630ff0fa 22-May-2021 Masahiro Yamada <masahiroy@kernel.org>

scripts/setlocalversion: factor out 12-chars hash construction

Both of if and else parts append exactly 12 hex chars, but in
different ways.

Factor out the else part because we need to support it without relying
on git-describe. Remove the --abbrev=12 option since we do not use the
hash from git-describe anyway.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>


# ffaf62a8 22-May-2021 Masahiro Yamada <masahiroy@kernel.org>

scripts/setlocalversion: add more comments to -dirty flag detection

This script stumbled on the read-only source tree over again:

- a2bb90a08cb3 ("kbuild: fix delay in setlocalversion on readonly
source")

- cdf2bc632ebc ("scripts/setlocalversion on write-protected source
tree")

- 8ef14c2c41d9 ("Revert "scripts/setlocalversion: git: Make -dirty
check more robust"")

- ff64dd485730 ("scripts/setlocalversion: Improve -dirty check with
git-status --no-optional-locks")

Add comments to clarify that this script should never ever try to write
to the source tree.

'git describe --dirty' might look as a simple solution for appending
the -dirty string, but we cannot use it because it creates the
.git/index.lock file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>


# a2be76a3 22-May-2021 Masahiro Yamada <masahiroy@kernel.org>

scripts/setlocalversion: remove workaround for old make-kpkg

This reverts commit b052ce4c840e ("kbuild: fix false positive -dirty
tag caused by make-kpkg").

If I understand correctly, this problem occurred in very old versions
of make-kpkg. When I tried a newer version, make-kpkg did not touch
scripts/package/Makefile.

Anyway, Debian uses 'make deb-pkg' instead of make-kpkg these days.

Debian handbook [1] mentions it as "the good old days":

"CULTURE The good old days of kernel-package

Before the Linux build system gained the ability to build proper
Debian packages, the recommended way to build such packages was to
use make-kpkg from the kernel-package package."

[1]: https://debian-handbook.info/browse/stable/sect.kernel-compilation.html

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>


# 2a73cce2 22-May-2021 Masahiro Yamada <masahiroy@kernel.org>

scripts/setlocalversion: remove mercurial, svn and git-svn supports

The mercurial, svn, git-svn supports were added by the following commits:

- 3dce174cfcba ("kbuild: support mercurial in setlocalversion")

- ba3d05fb6369 ("kbuild: add svn revision information to setlocalversion")

- ff80aa97c9b4 ("setlocalversion: add git-svn support")

They did not explain why they are useful for the kernel source tree.
Let's revert all of them, and see if somebody will complain about it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>


# 77a88274 29-Apr-2021 Masahiro Yamada <masahiroy@kernel.org>

kbuild: replace LANG=C with LC_ALL=C

LANG gives a weak default to each LC_* in case it is not explicitly
defined. LC_ALL, if set, overrides all other LC_* variables.

LANG < LC_CTYPE, LC_COLLATE, LC_MONETARY, LC_NUMERIC, ... < LC_ALL

This is why documentation such as [1] suggests to set LC_ALL in build
scripts to get the deterministic result.

LANG=C is not strong enough to override LC_* that may be set by end
users.

[1]: https://reproducible-builds.org/docs/locales/

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Reviewed-by: Matthias Maennich <maennich@google.com>
Acked-by: Matthieu Baerts <matthieu.baerts@tessares.net> (mptcp)
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 548b8b51 17-Sep-2020 Rasmus Villemoes <linux@rasmusvillemoes.dk>

scripts/setlocalversion: make git describe output more reliable

When building for an embedded target using Yocto, we're sometimes
observing that the version string that gets built into vmlinux (and
thus what uname -a reports) differs from the path under /lib/modules/
where modules get installed in the rootfs, but only in the length of
the -gabc123def suffix. Hence modprobe always fails.

The problem is that Yocto has the concept of "sstate" (shared state),
which allows different developers/buildbots/etc. to share build
artifacts, based on a hash of all the metadata that went into building
that artifact - and that metadata includes all dependencies (e.g. the
compiler used etc.). That normally works quite well; usually a clean
build (without using any sstate cache) done by one developer ends up
being binary identical to a build done on another host. However, one
thing that can cause two developers to end up with different builds
[and thus make one's vmlinux package incompatible with the other's
kernel-dev package], which is not captured by the metadata hashing, is
this `git describe`: The output of that can be affected by

(1) git version: before 2.11 git defaulted to a minimum of 7, since
2.11 (git.git commit e6c587) the default is dynamic based on the
number of objects in the repo
(2) hence even if both run the same git version, the output can differ
based on how many remotes are being tracked (or just lots of local
development branches or plain old garbage)
(3) and of course somebody could have a core.abbrev config setting in
~/.gitconfig

So in order to avoid `uname -a` output relying on such random details
of the build environment which are rather hard to ensure are
consistent between developers and buildbots, make sure the abbreviated
sha1 always consists of exactly 12 hex characters. That is consistent
with the current rule for -stable patches, and is almost always enough
to identify the head commit unambigously - in the few cases where it
does not, the v5.4.3-00021- prefix would certainly nail it down.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 3c96bdd0 22-Oct-2019 Bhaskar Chowdhury <unixbhaskar@gmail.com>

scripts: setlocalversion: replace backquote to dollar parenthesis

This patch replaces backquote to dollar parenthesis syntax for better
readability.

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 991b78fb 05-Oct-2019 Randy Dunlap <rdunlap@infradead.org>

scripts: setlocalversion: fix a bashism

Fix bashism reported by checkbashisms by using only one '=':

possible bashism in scripts/setlocalversion line 96 (should be 'b = a'):
if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then

Fixes: 38b3439d84f4 ("setlocalversion: update mercurial tag parsing")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Mike Crowe <mcrowe@zipitwireless.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 7a82e3fa 01-Oct-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

scripts/setlocalversion: clear local variable to make it work for sh

Geert Uytterhoeven reports a strange side-effect of commit 858805b336be
("kbuild: add $(BASH) to run scripts with bash-extension"), which
inserts the contents of a localversion file in the build directory twice.

[Steps to Reproduce]
$ echo bar > localversion
$ mkdir build
$ cd build/
$ echo foo > localversion
$ make -s -f ../Makefile defconfig include/config/kernel.release
$ cat include/config/kernel.release
5.4.0-rc1foofoobar

This comes down to the behavior change of local variables.

The 'man sh' on my Ubuntu machine, where sh is an alias to dash,
explains as follows:
When a variable is made local, it inherits the initial value and
exported and readonly flags from the variable with the same name
in the surrounding scope, if there is one. Otherwise, the variable
is initially unset.

[Test Code]

foo ()
{
local res
echo "res: $res"
}

res=1
foo

[Result]

$ sh test.sh
res: 1
$ bash test.sh
res:

So, scripts/setlocalversion correctly works only for bash in spite of
its hashbang being #!/bin/sh. Nobody had noticed it before because
CONFIG_SHELL was previously set to bash almost all the time.

Now that CONFIG_SHELL is set to sh, we must write portable and correct
code. I gave the Fixes tag to the commit that uncovered the issue.

Clear the variable 'res' in collect_files() to make it work for sh
(and it also works on distributions where sh is an alias to bash).

Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension")
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>


# ff64dd48 14-Nov-2018 Brian Norris <briannorris@chromium.org>

scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks

git-diff-index does not refresh the index for you, so using it for a
"-dirty" check can give misleading results. Commit 6147b1cf19651
("scripts/setlocalversion: git: Make -dirty check more robust") tried to
fix this by switching to git-status, but it overlooked the fact that
git-status also writes to the .git directory of the source tree, which
is definitely not kosher for an out-of-tree (O=) build. That is getting
reverted.

Fortunately, git-status now supports avoiding writing to the index via
the --no-optional-locks flag, as of git 2.14. It still calculates an
up-to-date index, but it avoids writing it out to the .git directory.

So, let's retry the solution from commit 6147b1cf19651 using this new
flag first, and if it fails, we assume this is an older version of git
and just use the old git-diff-index method.

It's hairy to get the 'grep -vq' (inverted matching) correct by stashing
the output of git-status (you have to be careful about the difference
betwen "empty stdin" and "blank line on stdin"), so just pipe the output
directly to grep and use a regex that's good enough for both the
git-status and git-diff-index version.

Cc: Christian Kujau <lists@nerdbynature.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Suggested-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Tested-by: Genki Sky <sky@genki.is>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 8ef14c2c 06-Nov-2018 Guenter Roeck <linux@roeck-us.net>

Revert "scripts/setlocalversion: git: Make -dirty check more robust"

This reverts commit 6147b1cf19651c7de297e69108b141fb30aa2349.

The reverted patch results in attempted write access to the source
repository, even if that repository is mounted read-only.

Output from "strace git status -uno --porcelain":

getcwd("/tmp/linux-test", 129) = 16
open("/tmp/linux-test/.git/index.lock", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) =
-1 EROFS (Read-only file system)

While git appears to be able to handle this situation, a monitored
build environment (such as the one used for Chrome OS kernel builds)
may detect it and bail out with an access violation error. On top of
that, the attempted write access suggests that git _will_ write to the
file even if a build output directory is specified. Users may have the
reasonable expectation that the source repository remains untouched in
that situation.

Fixes: 6147b1cf19651 ("scripts/setlocalversion: git: Make -dirty check more robust"
Cc: Genki Sky <sky@genki.is>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 6147b1cf 28-Aug-2018 Genki Sky <sky@genki.is>

scripts/setlocalversion: git: Make -dirty check more robust

$(git diff-index) relies on the index being refreshed. This refreshing
of the index used to happen, but was removed in cdf2bc632ebc
("scripts/setlocalversion on write-protected source tree", 2013-06-14)
due to issues with a read-only filesystem.

If the index is not refreshed, one runs into problems. E.g. as
described in [0], git stores the uid in its index, so even if just the
uid has changed (or git is tricked into thinking so), then we will
think the tree is dirty. So as in [1], if you package linux-git with a
system that uses fakeroot(1), you get a "-dirty" version. Unless you
manually $(git update-index --refresh) themselves.

The simplest solution seems to be $(git status --porcelain), with an
additional flag saying "ignore untracked files". It seems clearer
about what it does, and avoids issues regarding cached indexes and
writable filesystems, but still has stable output for scripting.

[0]: https://public-inbox.org/git/0190ae30-b6c8-2a8b-b1fb-fd9d84e6dfdf@oracle.com/
[1]: https://bbs.archlinux.org/viewtopic.php?id=236702

Signed-off-by: Genki Sky <sky@genki.is>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b2441318 01-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

License cleanup: add SPDX GPL-2.0 license identifier to files with no license

Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.

For non */uapi/* files that summary was:

SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139

and resulted in the first patch in this series.

If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:

SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930

and resulted in the second patch in this series.

- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:

SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1

and that resulted in the third patch in this series.

- when the two scanners agreed on the detected license(s), that became
the concluded license(s).

- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.

- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).

- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.

- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct

This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 78283edf 06-Jun-2016 Wolfram Sang <wsa@kernel.org>

kbuild: setlocalversion: print error to STDERR

I tried to use 'make O=...' from an unclean source tree. This triggered
the error path of setlocalversion. But by printing to STDOUT, it created
a broken localversion which then caused another (unrelated) error:

"4.7.0-rc2Error: kernelrelease not valid - run make prepare to update it" exceeds 64 characters

After printing to STDERR, the true build error gets displayed later:

/home/wsa/Kernel/linux is not clean, please run 'make mrproper'
in the '/home/wsa/Kernel/linux' directory.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Michal Marek <mmarek@suse.com>


# 7593e090 02-Dec-2013 Franck Bui-Huu <fbuihuu@gmail.com>

Fix detectition of kernel git repository in setlocalversion script [take #2]

setlocalversion script was testing the presence of .git directory in
order to find out if git is used as SCM to track the current kernel
project. However in some cases, .git is not a directory but can be a
file: when the kernel is a git submodule part of a git super project for
example.

This patch just fixes this by using 'git rev-parse --show-cdup' to check
that the current directory is the kernel git topdir. This has the
advantage to not test and rely on git internal infrastructure directly.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# cdf2bc63 14-Jun-2013 Christian Kujau <lists@nerdbynature.de>

scripts/setlocalversion on write-protected source tree

I just stumbled across another[0] issue when scripts/setlocalversion
operates on a write-protected source tree. Back then[0] the source tree
was on an read-only NFS share, so "test -w" was introduced before "git
update-index" was run.

This time, the source tree is on read/write NFS share, but the permissions
are world-readable and only a specific user (or root) can write.
Thus, "test -w ." returns "0" and then runs "git update-index",
producing the following message (on a dirty tree):

fatal: Unable to create '/usr/local/src/linux-git/.git/index.lock': Permission denied

While it says "fatal", compilation continues just fine.

However, I don't think a kernel compilation should alter the source
tree (or the .git directory) in any way and I don't see how removing
"git update-index" could do any harm. The Mercurial and SVN routines in
scripts/setlocalversion don't have any tree-modifying commands, AFAICS.
So, maybe the patch below would be acceptable.

[0] https://patchwork.kernel.org/patch/29718/

Signed-off-by: Christian Kujau <lists@nerdbynature.de>
Cc: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# f893bfb6 22-Feb-2013 Christophe Leroy <christophe.leroy@c-s.fr>

kbuild: Unset language specific variables in setlocalversion script

This patch allows the use of setlocalversion script regardless of the language
parameters. Otherwise, the `svn info 2>/dev/null | grep '^Last Changed Rev'`
returns nothing because for instance, in French the text 'Last Changed Rev'
is replaced by 'Révision de la dernière modification'

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 7f3bd6c9 23-Mar-2012 Roland Dreier <roland@purestorage.com>

setlocalversion: Use "grep -q" instead of piping output to "read dummy"

In some circumstances (eg when running a build in an emacs shell
buffer), I get a spew of messages like

grep: writing output: Broken pipe

from setlocalversion, because the "read" subshell apparently exits as
soon as it reads one line and gives EPIPE to grep. It's not clear to
me why this way of writing the check was used instead of just using
grep -q to suppress output, but unless there is some deep reason I
don't know, this way looks cleaner to me anyway, and gets rid of the
ugly message spew.

(I double checked at http://pubs.opengroup.org/onlinepubs/009604499/utilities/grep.html
and "grep -q" is specified in POSIX / SuS, so hopefully even people
cross-compiling the kernel on some bizarre host OS can't complain
about this change)

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 38b3439d 11-Jan-2011 Mike Crowe <mcrowe@zipitwireless.com>

setlocalversion: update mercurial tag parsing

The tag output of hg doesn't quite match what setlocalversion currently
expects, so update it to handle the latest format.

Signed-off-by: Mike Crowe <mcrowe@zipitwireless.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# c3e2f196 06-Sep-2010 Michael Prokop <mika@grml.org>

scripts/setlocalversion: update comment

A tagged repository state isn't enough, git describe only
looks at signed or annotated tags (git tag -a/-s). This
documentation update makes sure the comment matches the
current behaviour.

Signed-off-by: Michael Prokop <mika@grml.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 8558f59e 16-Aug-2010 Michal Marek <mmarek@suse.cz>

setlocalversion: Ignote SCMs above the linux source tree

Dan McGee <dpmcgee@gmail.com> writes:
> Note that when in git, you get the appended "+" sign. If
> LOCALVERSION_AUTO is set, you will get something like
> "eee-gb01b08c-dirty" (whereas the copy of the tree in /tmp still
> returns "eee"). It doesn't matter whether the working tree is dirty or
> clean.
>
> Is there a way to disable this? I'm building from a clean tarball that
> just happens to be unpacked inside a git repository. One would think
> setting LOCALVERSION_AUTO to false would do it, but no such luck...

Fix this by checking if the kernel source tree is the root of the git or
hg repository. No fix for svn: If the kernel source is not tracked in
the svn repository, it works as expected, otherwise determining the
'repository root' is not really a defined task.

Reported-and-tested-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 55c640c3 22-Jul-2010 Milton Miller <miltonm@bga.com>

setlocalversion: fix version for untaged nontip mercurial revs

The manpage for cut says it will return all lines without the delimiter
unless -s is specified.

When I backed up my mecurial tree to generate modules, I found that the
scm part of localversion was turning up blank.

Signed-off-by: Milton Miller <miltonm@bga.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: "Michał Górny" <gentoo@mgorny.alt.pl>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# b003afe3 15-Jul-2010 Michal Marek <mmarek@suse.cz>

kbuild: Fix make rpm

make rpm was broken by commit 0915512:
make clean
set -e; cd ..; ln -sf /usr/src/iwlwifi-2.6 kernel-2.6.35rc4wl
/bin/sh /usr/src/iwlwifi-2.6/scripts/setlocalversion --scm-only >
/usr/src/iwlwifi-2.6/.scmversion
cat: .scmversion: input file is output file
make[1]: *** [rpm] Error 1

Reported-and-tested-by: "Zheng, Jiajia" <jiajia.zheng@intel.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 6dc0c2f3 18-Jul-2010 Michał Górny <gentoo@mgorny.alt.pl>

kbuild: Make the setlocalversion script POSIX-compliant

The 'source' builtin is a bash alias to the '.' (dot) builtin. While the
former is supported only by bash, the latter is specified in POSIX and
works fine with all POSIX-compliant shells I am aware of.

The '$_' special parameter is specific to bash. It is partially
supported in dash too but it always evaluates to the current script path
(which causes the script to enter a loop recursively re-executing
itself). This is why I have replaced the two occurences of '$_' with the
explicit parameter.

The 'local' builtin is another example of bash-specific code. Although
it is supported by all POSIX-compliant shells I am aware of, it is not
part of POSIX specification and thus the code should not rely on it
assigning a specific value to the local variable. Moreover, the 'posh'
shell has a limited version of 'local' builtin not supporting direct
variable assignments. Thus, I have broken one of the 'local'
declarations down into a (non-POSIX) 'local' declaration and a plain
(POSIX-compliant) variable assignment.

Signed-off-by: Michał Górny <gentoo@mgorny.alt.pl>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 09155120 17-Jun-2010 Michal Marek <mmarek@suse.cz>

kbuild: Clean up and speed up the localversion logic

Now that we run scripts/setlocalversion during every build, it makes
sense to move all the localversion logic there. This cleans up the
toplevel Makefile and also makes sure that the script is called only
once in 'make prepare' (previously, it would be called every time due to
a variable expansion in an ifneq statement). No user-visible change is
intended, unless one runs the setlocalversion script directly.

Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# a2bb90a0 12-Jun-2009 Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>

kbuild: fix delay in setlocalversion on readonly source

Do not update index on read only media.
Idea published by Christian Kujau <lists@nerdbynature.de>.

Cc: Nico Schottelius <nico@ikn.schottelius.org>
Cc: Christian Kujau <lists@nerdbynature.de>


# 33252572 16-May-2009 Nico Schottelius <nico-linux-20090330@schottelius.org>

Fix scripts/setlocalversion with tagged git commit

Produce correct output for
- tagged commit (v2.6.30-rc6)
- past tagged commit (v2.6.30-rc5-299-g7c7327d)
- no tag

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a182ad3d 25-Apr-2009 Nico Schottelius <nico-linux-20090330@schottelius.org>

kbuild: fix scripts/setlocalversion with git

When using trees like wireless-testing, which have untagged tags,
scripts/setlocalversion does not display any git indication for
localversion.

This patch fixes it: If git is available, but no usable tag is found,
it uses -g${head}. It skips the detection of unanottated tags via
git name-rev.

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 4774bb1c 26-Mar-2009 Peter Korsgaard <jacmet@sunsite.dk>

kbuild: use git svn instead of git-svn in setlocalversion

Use the correct git <subcmd> syntax instead of the deprecated git-<subcmd>.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# d21d52d4 05-Feb-2009 Mike Frysinger <vapier.adi@gmail.com>

kbuild,setlocalversion: shorten the make time when using svn

Don't bother doing `svn st` as it takes a retarded amount of time when
the source is cold

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# ff80aa97 02-Dec-2008 Peter Korsgaard <jacmet@sunsite.dk>

setlocalversion: add git-svn support

Print svn revision in addition to git info on git-svn repos.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 167d6a02 02-Dec-2008 Peter Korsgaard <jacmet@sunsite.dk>

setlocalversion: print correct subversion revision

Output svn revision of latest change, instead of repo revision as thats
what we're interested in (especially when working on a branch/tag).

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# f03b283f 12-Sep-2008 Trent Piepho <tpiepho@freescale.com>

kbuild: tag with git revision when git describe is missing

setlocalversion used to use an abbreviated git commit sha1 to generate the
tag. This was changed in commit d882421f4e08ddf0a94245cdbe516db260aa6f41
"kbuild: change CONFIG_LOCALVERSION_AUTO to use a git-describe-ish format"
to use git describe to come up with a tag. Which is nice, but git describe
sometimes can't describe the revision.
Commit 56b2f0706d82535fd8d85503f2dcc0be40c8e55d ("setlocalversion: do not
describe if there is nothing to describe") addressed this, but there is still
no tag generated.

So, generate a plain abbreviated sha1 tag like setlocalversion used to when
git describe comes up short.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
CC: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# e3da2fb7 25-Oct-2008 Mike Frysinger <vapier@gentoo.org>

kbuild: setlocalversion: dont include svn change count

The number of pending changes is pretty useless, so encoding it into the
version is just annoying by the constant shuffle in corresponding modules.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 56b2f070 01-Jul-2008 Sebastian Siewior <lkml@ml.breakpoint.cc>

setlocalversion: do not describe if there is nothing to describe

Jan Engelhardt wrote:
> Just a note that when you run git-describe, you should probably quiten it.
>
> fatal: cannot describe 'bd7364a0fd5a4a2878fe4a224be1b142a4e6698e'
>
> This happens when tags are not present, which can happen if Linus's tree
> is sent upwards again, IOW:
>
> machine1$ git-clone torvalds/linux-2.6.git
> machine1$ git push elsewhere master
>
> machine2$ git-clone elsewhere:/linux
> machine2$ git-describe HEAD
> fatal: cannot describe that

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
Acked-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# ba3d05fb 02-Feb-2008 Bryan Wu <bryan.wu@analog.com>

kbuild: add svn revision information to setlocalversion

follow git and mercurial style, include uncommitted changes detect

Cc: Frans Pop <elendil@planet.nl>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# b052ce4c 02-Nov-2007 Theodore Ts'o <tytso@mit.edu>

kbuild: fix false positive -dirty tag caused by make-kpkg

make-kpkg modifies scripts/package/Makefile and deletes
scripts/package/builddeb as part of its build process. Ignore these
changes so the tree isn't marked as -dirty, when it is just an
artifact of make-kpkg. (make-kpkg clean restores the files to their
original state, and these helper scripts won't affect the final
compiled kernel in any way.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 4e7434ff 02-Nov-2007 Theodore Ts'o <tytso@mit.edu>

kbuild: fix scripts/setlocalversion to avoid erroneous -dirty tag

If git's index file is out of date, and some files have been touched
such that their timestamp doesn't what is in the index, "git
diff-index HEAD" may show that a particular file is dirty, when in
fact it really isn't. Running "git update-index" will update the
index to avoid these false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# d882421f 02-Nov-2007 Theodore Ts'o <tytso@mit.edu>

kbuild: change CONFIG_LOCALVERSION_AUTO to use a git-describe-ish format

Change the automatic local version to have the form -nnnnn-gSHA1SUMID,
where 'nnnnn' is the number of commits since the last tag (i.e.,
2.6.21-rc7). This makes it much more likely that the package names created
for the kernel will look "newer" to a package manager.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 3dce174c 28-Nov-2007 Aron Griffis <aron@hp.com>

kbuild: support mercurial in setlocalversion

This represents mercurial changesets similarly to git. For untagged
revisions, append the changeset id. If there are uncommitted changes,
append -dirty. For example, -hgc60016ba6237-dirty

Signed-off-by: Aron Griffis <aron@hp.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 216b2f1f 16-Jun-2006 Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>

kbuild: append -dirty for updated but uncommited changes

Compare the working copy with the last commit, instead of the index.

Signed-off-by: Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
Acked-by: Ryan Anderson <ryan@michonline.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 29b0c899 16-Jun-2006 Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>

kbuild: append git revision for all untagged commits

adds revision suffix for untagged commits that are reachable from a tag

I'm bisecting and don't get the -g...... suffix. The reason is, that

git name-rev --tags HEAD

returns e.g.

HEAD tags/v2.6.17-rc1^0~1067

which is currently good enough for setlocalversion to skip the suffix.
This introduces a dependecy to grep -E, which should be fine.

Signed-off-by: Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
Acked-By: Ryan Anderson <ryan@michonline.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 24d49756 08-Jan-2006 Ryan Anderson <ryan@michonline.com>

kbuild: In setlocalversion change -git_dirty to just -dirty

When building Debian packages directly from the git tree, the appended
"git_dirty" is a problem due to the underscore. In order to cause the
least problems, change that just to "dirty".

Signed-off-by: Ryan Anderson <ryan@michonline.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 117a93db 04-Jan-2006 Rene Scharfe <rene.scharfe@lsrfire.ath.cx>

kbuild: Use git in scripts/setlocalversion

Currently scripts/setlocalversion is a Perl script that tries to figure
out the current git commit ID of a repo without using git. It also
imports Digest::MD5 without using it and generally is too big for the
small task it does. :] And it always reports a git ID, even when the
HEAD is tagged -- this is a bug.

This patch replaces it with a Bourne Shell script that uses git
commands to do the same. I can't come up with a scenario where someone
would use a git repo and refuse to install git core at the same time,
so I think it's reasonable to assume git is available.

The new script also reports uncommitted changes by adding -git_dirty to
the version string. Obviously you can't see from that _what_ has been
changed from the last commit, so it's more of a reminder that you
forgot to commit something.

The script is easily extensible: simply add a check for Mercurial (or
whatever) below the git check.

Note: the script doesn't print a newline char anymore. That's only
because it was easier to implement it that way, not a feature (or bug).
'make kernelrelease' doesn't care.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Acked-by: Ryan Anderson <ryan@michonline.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# aaebf433 31-Jul-2005 Ryan Anderson <ryan@michonline.com>

[PATCH] kbuild: automatically append a short string to the version based upon the git commit

If CONFIG_AUTO_LOCALVERSION is set, the user is using a git-based tree, and the
current HEAD is not referred to by any tags in .git/refs/tags/, append -g and
the first 8 characters of the commit to the version string. This makes it
easier to use git-bisect, and/or to do a daily build, without trampling on your
older, working builds, or accidentally setting up conflicting sets of modules.

Signed-off-by: Ryan Anderson <ryan@michonline.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>