git Linux 内核:内核版本字符串附加“+”或“-dirty”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25090803/
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 10:15:50  来源:igfitidea点击:

Linux kernel : Kernel version string appended with either ''+" or "-dirty"

linuxgitlinux-kernel

提问by iammurtaza

I am trying to install latest kernel from git of Linus Torvalds, i.e., version 3.16-rc7. I have created a new branch by following using following commands: git checkout -b v_3_16 v3.16-rc7Then I checkout on the branch v_3_16 and fire following commands make menuconfigand check the option CONFIG_LOCALVERSION_AUTObecause I need the version string to be updated. But I cannot understand why does this append "+" or "-dirty" (when CONFIG_LOCALVERSION_AUTO is disabled) to the version string. I have checked out for uncommited changes using git commit -abut it says nothing to commit.

我正在尝试从 Linus Torvalds 的 git 安装最新的内核,即版本 3.16-rc7。我使用以下命令创建了一个新分支: git checkout -b v_3_16 v3.16-rc7然后我在分支 v_3_16 上签出并触发以下命令 make menuconfig并检查该选项,CONFIG_LOCALVERSION_AUTO因为我需要更新版本字符串。但我不明白为什么这会将“+”或“-dirty”(禁用 CONFIG_LOCALVERSION_AUTO 时)附加到版本字符串。我已经使用检查了未提交的更改,git commit -a但它没有说明要提交。

回答by askb

If Linux kernel images are being built with "-dirty" on the end of the version string, this simply means that modifications in the source directory have not been committed. Use git statusto check for uncommitted files.

如果 Linux 内核映像是在版本字符串末尾使用“-dirty”构建的,这仅意味着源目录中的修改尚未提交。使用git status检查未提交的文件。

When you see the dirty string, it appends the kernel version string with the last abbreviated commit id + dirtyto the kernel version.

当您看到脏字符串时,它会将内核版本字符串与最后一个附加abbreviated commit id + dirty到内核​​版本。

You can use the above Git command to report modified, removed, or added files. You should commit those changes to the tree regardless of whether they will be saved, exported, or used. Once you commit the changes, you need to rebuild the kernel.

您可以使用上述 Git 命令报告修改、删除或添加的文件。无论是保存、导出还是使用这些更改,您都应该将这些更改提交到树中。提交更改后,您需要重建内核。

To force a pickup and commit of all such pending changes, enter the following:

要强制拾取并提交所有此类挂起的更改,请输入以下内容:

 $ git add .
 $ git commit -s -a -m "getting rid of -dirty"

Alternatively, use the make -j2 LOCALVERSION="-customstring"to get the custom string

或者,使用make -j2 LOCALVERSION="-customstring"来获取自定义字符串

回答by user2955935

"Create an empty .scmversion file in the root of the kernel sources."

“在内核源代码的根目录中创建一个空的 .scmversion 文件。”