10

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-rc7 Then I checkout on the branch v_3_16 and fire following commands make menuconfig and check the option CONFIG_LOCALVERSION_AUTO because 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 -a but it says nothing to commit.

iammurtaza
  • 957
  • 3
  • 16
  • 31
  • Related question: [Don't add “+” to linux kernel version](https://stackoverflow.com/q/19333918/673852). – Ruslan Sep 08 '19 at 18:43

2 Answers2

15

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 status to check for uncommitted files.

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

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.

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

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
askb
  • 6,501
  • 30
  • 43
  • 3
    But even after "git status" says "nothing to commit, working directory clean", i have "-dirty" still appended ! any advice ? – bicepjai Sep 11 '14 at 20:18
  • @bicepjai Check [scripts/setlocalversion](http://lxr.free-electrons.com/source/scripts/setlocalversion#L75) script, it's where `-dirty` suffix is applied to version. You should check for uncommitted changes the same way that script does, which is: `git diff-index --name-only HEAD`. – Sam Protsenko Sep 06 '16 at 14:32
  • @bicepjai They [removed git update-index](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cdf2bc632ebc9ef51) in the setlocalversion script, which probably [wasn't the smartest move](https://lkml.org/lkml/2017/9/27/693). Now git diff-index reports a dirty working tree even if a file was simply touched, for example. – PiQuer Nov 29 '17 at 13:44
  • 1
    for me adding LOCALVERSION="-bla" just changed it to "5.10.108-bla-dirty" (as seen by `make [LOCALVERSION=-bla] -s kernelrelease`), and committing changed it to "5.10.108-bla-00001-gd11ec87d1bdd" ... but `touch .scmversion` as user2955935 suggests, or renaming the ".git" directory to something else made it stop appending "-dirty". – Peter Mar 24 '22 at 14:49
14

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

user2955935
  • 311
  • 3
  • 8