Don't add "+" to linux kernel version
Solution 1
The plus sign at the end of your version string is there as an indicator that the kernel was built from modified sources (that is, there were non-committed changes). This is also indicated by the comments in scripts/setlocalversion
.
To avoid the '+' being appended despite having a dirty working directory, simply set LOCALVERSION explicityly when running make
:
make LOCALVERSION=
You may also have to change the configuration option CONFIG_LOCALVERSION_AUTO
to n
in your kernel config (.config
) before building:
sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" .config
Solution 2
To prevent the script scripts/setlocalversion
to append the +
to the end of the kernel local version, create an empty .scmversion
file in the root of the kernel sources.
touch .scmversion
this way, you'll be able to leave LOCALVERSION as is in the kernel configuration file, in case you want to append a local signature to the kernel name.
Yuri
Updated on July 09, 2022Comments
-
Yuri almost 2 years
I am building linux kernel, if my kernel under git, then kernel version every time is:
Image Name: Linux-2.6.39+
If I am not using git, then everything is OK without any plus at the end.
I know that this done by scripts/setlocalversion script:
if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then # full scm version string res="$res$(scm_version)" else # append a plus sign if the repository is not in a clean # annotated or signed tagged state (as git describe only # looks at signed or annotated tags - git tag -a/-s) and # LOCALVERSION= is not specified if test "${LOCALVERSION+set}" != "set"; then scm=$(scm_version --short) res="$res${scm:++}" fi fi
So, it is possible without code changes say to build system that no need to add "+" at the end of version line?
-
Gauthier over 9 yearsI do get a + at the end of my
vmlinuz
andinitrd.img
, yetgit status
says "nothing to commit, working directory clean". It is my own commit though, does the + appear because I am not on the official master branch? Or maybe since I built locally the working directory is not clean although the dirt is gitignored? -
Jon Gjengset over 9 yearsI'm not entirely sure.. You should have a look at
scripts/setlocalversion
and see exactly what it is testing for when setting+
. -
Gauthier over 9 yearsApparently, it also adds a plus if your working directory is clean, but your current git HEAD has no tag.
-
Gauthier over 9 yearsAh, but that's not all of it. I have my own branch, tagged commit, clean working dir, but I still get the +.
-
Peterlits Zo almost 2 years@Gauthier Same as you >_<