linux - 不要将 "+"添加到 linux 内核版本

标签 linux git linux-kernel

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

Image Name:   Linux-2.6.39+

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

我知道这是由 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

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

最佳答案

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

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

make LOCALVERSION=

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

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

关于linux - 不要将 "+"添加到 linux 内核版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19333918/

相关文章:

linux - Windows 和 Linux 上的 maven-antrun-plugin

git mv 和变化和相似度索引

linux-kernel - KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file 没有按预期工作

linux - 我可以在内核代码中使用 vpush/vpop 吗?

Linux ELF 文件段名称

linux - Gnuplot 条形图对齐

linux - TF 命令行可执行文件未显示在 Jenkins 上

git - 手动修复 git am -3 冲突

windows - 从 Git 中删除凭据

linux - 中断处理和用户空间通知