git linux内核版本不要加“+”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19333918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:11:32  来源:igfitidea点击:

Don't add "+" to linux kernel version

linuxgitlinux-kernel

提问by Yuri

I am building linux kernel, if my kernel under git, then kernel version every time is:

我正在构建linux内核,如果我的内核在git下,那么每次内核版本都是:

Image Name:   Linux-2.6.39+

If I am not using git, then everything is OK without any plus at the end.

如果我不使用 git,那么一切都很好,最后没有任何加号。

I know that this done by scripts/setlocalversion script:

我知道这是由 scripts/setlocalversion 脚本完成的:

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?

那么,有可能在没有代码更改的情况下构建不需要在版本行末尾添加“+”的系统?

回答by Jon Gjengset

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.

版本字符串末尾的加号表示内核是从修改过的源构建的(即,存在未提交的更改)。中的注释也表明了这一点scripts/setlocalversion

To avoid the '+' being appended despite having a dirty working directory, simply set LOCALVERSION explicityly when running make:

为了避免在工作目录不干净的情况下附加“+”,只需在运行时显式设置 LOCALVERSION make

make LOCALVERSION=

You may also have to change the configuration option CONFIG_LOCALVERSION_AUTOto nin your kernel config (.config) before building:

您可能还需要配置选项更改CONFIG_LOCALVERSION_AUTOn你的内核配置(.config大厦前):

sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" .config

回答by HappyCactus

To prevent the script scripts/setlocalversionto append the +to the end of the kernel local version, create an empty .scmversionfile in the root of the kernel sources.

为防止脚本scripts/setlocalversion将 附加+到内核​​本地版本的末尾.scmversion,请在内核源代码的根目录中创建一个空文件。

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.

这样,您就可以将 LOCALVERSION 保留在内核配置文件中,以防您想将本地签名附加到内核名称。

回答by Sabin

Manipulating scripts/setlocalversion seems to be the only way for me. Force return in scm_version():

操作脚本/setlocalversion 对我来说似乎是唯一的方法。强制返回scm_version()

scm_version()
{
        local short
        short=false
        **return**

回答by Keelung

Add this line to your local.conf if you're using yocto and imx soc

如果您使用的是 yocto 和 imx soc,请将此行添加到您的 local.conf

SCMVERSION_pn-linux-imx = ""

Tested on imx-4.9.88-2.0.0_ga release

在 imx-4.9.88-2.0.0_ga 版本上测试