linux 内核 config_localversion_auto,关于CONFIG_LOCALVERSION_AUTO设置去掉内核版本号SVN后缀...
最近在TI 的DVSDK下寫驅動模塊時老受linux內核svn版本號問題的困擾,如"2.6.37-svn41"、"2.6.37-svn51"等等,svn版本變一次,從上面取下的代碼內核版本就要變一次,這樣造成原來驅動模塊ko文件必須重新拷貝到新的lib/modules/2.6.37-svn51下,非常麻煩且不利于發版本。
按其說法將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
}
這里有個echo "+",那“2.6.37+”里面的“+”到底是這條語句產生的嗎?開始看到有些博客說修改這里,注釋掉"echo "+"",但并未起作用。需要認真分析一下,看第3個f語句,意思是至少有.git目錄存在的話才會執行這后面的,但我們用的svn,沒有.git的,所以這里的echo "+"并未執行。再看一段代碼:
# 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這里的if就是說如果CONFIG_LOCALVERSION_AUTO定義的話,會加上svn版本號,我們已經設為n了,所以會執行else部分,scm=$(scm_version --short)雖然將--short傳給scm_version使得short=true,但.git不存在,所以scm_version并未打印出“+”,再來看res="$res${scm:++}"這句話什么意思呢?scm:++實際上是說如果scm未定義的話,將使用默認值"+"也就是說:+表示使用默認值的意思,而第二個“+”表示默認值。所以將第二個“+”去掉即可。也就是改成res="$res${scm:+}",即可打印不帶“+”的版本號“2.6.37”。
希望給遇到同樣問題的同行以幫助!
總結
以上是生活随笔為你收集整理的linux 内核 config_localversion_auto,关于CONFIG_LOCALVERSION_AUTO设置去掉内核版本号SVN后缀...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux系统 大分区,linux大硬盘
- 下一篇: linux系统桌面缺色,红旗系统如何用?