Skip to content

编译linux内核时,让版本号不跟着git变化

现象

内核每次重新编译时,uname -r都会跟着变。

4.1.15-00005-g482731e4-dirty

导致报错,modprobe: can't change directory to '4.1.15-00005-g482731e4-dirty': No such file or directory

方法一

取消 CONFIG_LOCALVERSION_AUTO宏

image-20240815092617337

这样配置编译后,版本号变为4.1.15+

如果不想要有4.1.15+,请参照方法二。

方法二

修改脚本文件,scripts/setlocalversion

bash
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&

改为

shell
if test -n "$(git rev-parse --show-cdup 2>/dev/null)" &&

这样版本号4.1.15永远不会变了。

image-20240815093305813

上次更新于: