本文介绍了不要添加“+"到linux内核版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

Image Name:   Linux-2.6.39+

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

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

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

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?

推荐答案

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

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.

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

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

make LOCALVERSION=

您可能还需要在构建之前将内核配置 (.config) 中的配置选项 CONFIG_LOCALVERSION_AUTO 更改为 n:

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

这篇关于不要添加“+"到linux内核版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 22:18