最近在TI 的DVSDK下写驱动模块时老受linux内核svn版本号问题的困扰,如"2.6.37-svn41"、"2.6.37-svn51"等等,svn版本变一次,从上面取下的代码内核版本就要变一次,这样造成原来驱动模块ko文件必须重新拷贝到新的lib/modules/2.6.37-svn51下,非常麻烦且不利于发版本。
因此找到一篇博文《去掉SVN管理kernel编译后版本自动变化》,见我的转载。
按其说法将arch/arm/configs/omap3_evm_defconfig里面
CONFIG_LOCALVERSION_AUTO=y
修改为#CONFIG_LOCALVERSION_AUTO=y
或#CONFIG_LOCALVERSION_AUTO is not set
清理内核源码根目录下的.config文件后,重新make omap3_evm_defconfig或者make linux_config,CONFIG_LOCALVERSION_AUTO相关项虽然未设置但依旧被内建。
后来发现将其设置为:
CONFIG_LOCALVERSION_AUTO=n
才使其默认不选上,其原理研究后再补上。
但是这样做了之后,编译linux内核并引导发内核版本变成了"2.6.37+",多了个“+”号
这个就需要修改scripts/setlocalversion的脚本了,先来看一段代码
- scm_version()
- {
- local short
- short=false
- cd "$srctree"
- if test -e .scmversion; then
- cat .scmversion
- return
- fi
- if test "$1" = "--short"; then
- short=true
- fi
- # Check for git and a git repo.
- if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`;then
- # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
- # it, because this version is defined in the top level Makefile.
- if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
- # If only the short version is requested, don't bother
- # running further git commands
- if $short; then
- echo "+"
- return
- fi
- ……
- fi
- ……
- fi
- }
- # scm version string if not at a tagged commit
- 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
希望给遇到同样问题的同行以帮助!