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

  
                

A lot of people compile Linux Kernel, the version number in the generated RPM package is inexplicably with a plus sign, which may be due to the modification of the files in Linux.git. So how do you remove the plus sign after the Linux Kernel version number? You can refer to the following methods.

kernel version is based on figures provided by the Makefile generated. Open the Makefile and the file will start to see:

1 VERSION = 3

2 PATCHLEVEL = 10

3 SUBLEVEL = 28

4 EXTRAVERSION =

5 NAME = TOSSUG Baby Fish

The file associated with kernel version number generation is scripts/setlocalversion, which has 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)&rdquo ;

else

# append a plus sign if the repository is not in a clean

# annotated or signed tagged state (as git describe only

#口 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

If

CONFIG_LOCALVERSION_AUTO

is not configured, LOCALVERSION has no value, then, according to the above script, the + sign will not be added. It is.

Actually, when compiling the code, you can execute it:

LOCALVERSION= make

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

if Test -d .git && head=`git rev-parse --verify --short HEAD 2》/dev/null`;

git rev-parse is to get 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< Br>

${LOCALVERSION+set} is variable expansion modfier.

It has several forms:

${variable:–word} If variable is set to one If the value is null, then the value of this expression is the value of variable; otherwise, it is the value of word (the value of variable is unchanged)

${variable:=word} if varial If e 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 (variable value is updated)

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

${variable:offset} Get a substring of the string (starting from the variable string index as offset, offset value starting from 0)

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

${variable:offset:length} Get the variable string (starting from offset, length is length)

The above is the reason for the addition of a plus sign after the Linux Kernel version number. The method, although the Linux Kernel version number seems to have no effect on the use, but it also has deep-seated reasons, you can use the method in the text to clear the plus sign.

Copyright © Windows knowledge All Rights Reserved