Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to remove the plus sign after the Linux Kernel version number

Shulou Source: shulou.com Published: 2022-06-01 18:09:47 09月13日 Update

Editor to share with you how to remove the plus sign after the Linux Kernel version number, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

The kernel version number is generated based on the numbers provided in Makefile. Open Makefile, and the file begins to see:

1 VERSION = 3

2 PATCHLEVEL = 10

3 SUBLEVEL = 28

4 EXTRAVERSION =

5 NAME = TOSSUG Baby Fish

The file related to kernel version number generation is scripts/setlocalversion, which contains the following partial scripts:

# scm version string if not at a tagged commit

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 Universe) and

# LOCALVERSION= is not specified

If test "${LOCALVERSION+set}"! = "set"; then

Scm=$ (scm_version-- short)

Res= "$res$ {scm:++}"

Fi

Fi

If

CONFIG_LOCALVERSION_AUTO

It is not configured, and LOCALVERSION has no values, so, according to the above script, the + sign will not be added.

When you actually compile the code, you can execute:

LOCALVERSION= make

In addition, in the file scripts/setlocalversion, there is a sentence:

If test-d. Git & & head= `git rev-parse-- verify-- short HEAD 2 "/ dev/ null`

Git rev-parse is used to retrieve the id of the most recent commit:

$git rev-parse-verify-short HEAD

E77fcc1

Charles@taotao:~/code/linux-3.10.28$ git rev-parse-- verify HEAD

E77fcc1e9be7a0ab373f96d5b9d58e1136c8c4b0

Or use:

$git log-- pretty=format:'%h'-n 1

E77fcc1

${LOCALVERSION+set} is variable expansion modfier.

It comes in several forms:

${variable:-word} if variable is set to a value that is not empty, then the value of this expression is the value of variable; otherwise, it is the value of word (the value of variable remains the same)

${variable:=word} if variale is set or the value is not empty, then the value of this expression is the value of variable; otherwise, it is the value of word (the value of variable is updated)

${variable:+word} if variable is set to a value that is not empty, then the value of this expression is the value of variable; otherwise, it is NULL.

${variable:offset} gets a substring of the string (since the variable string index is offset, the offset value is calculated from 0)

${variable:? Word} if variable is set to a value that is not empty, then the value of this expression is the value of variable; otherwise, print the value of word and exit.

${variable:offset:length} get the string of variable (starting with offset, the length is length)

The above is all the contents of the article "how to remove the plus sign after the Linux Kernel version number". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Version that is expression file article plus sign content kernel character string script generation not much size code most actual form numerical value number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Huawei Shulou Tech Info OPPO Reno