Linux Kernel版本号后面的加号如何去除?
时间:2022-04-25 12:28:13
不少朋友在编译Linux Kernel的时候,生成的RPM包中的版本号都莫名其妙地带着一个加号,这可能是因为修改了Linux.git中的文件。那么如何去除Linux Kernel版本号后面的加号?可以参考以下方法。
内核版本号是根据Makefile里提供的数字生成的。打开Makefile,文件开始可以看到:
1 VERSION = 3
2 PATCHLEVEL = 10
3 SUBLEVEL = 28
4 EXTRAVERSION =
5 NAME = TOSSUG Baby Fish
和内核版本号生成相关的文件是 scripts/setlocalversion, 其中有如下的部分脚本:
# 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
如果
CONFIG_LOCALVERSION_AUTO
没有被配置, LOCALVERSION 也没有数值,那么,根据上面的脚本,+号就不会被添加了。
实际在编译代码的时候,可以执行:
LOCALVERSION= make
另外,在文件scripts/setlocalversion里面,有一句:
if test -d .git && head=`git rev-parse --verify --short HEAD 2》/dev/null`;
git rev-parse 是为了取出最近的 commit的id:
$ git rev-parse --verify --short HEAD
e77fcc1
charles@taotao:~/code/linux-3.10.28$ git rev-parse --verify HEAD
e77fcc1e9be7a0ab373f96d5b9d58e1136c8c4b0
或者用:
$ git log --pretty=format:‘%h’ -n 1
e77fcc1
${LOCALVERSION+set} 是variable expansion modfier.
它有一下几种形式:
${variable:–word}如果 variable被设置了一个不为空的值,那么这个表达式的值就是 variable的值;反之,则是 word的值(variable的值不变)
${variable:=word} 如果 variale被set或者值非空,那么这个表达式的值就是 variable的值; 反之,则是 word的值(variable的值被更新)
${variable:+word} 如果 variable被设置了一个不为空的值,那么这个表达式的值就是 variable的值;反之,为NULL。
${variable:offset} 获得字符串的一个子串(从variable字符串索引为 offset开始, offset值从0开始计算)
${variable:?word}如果 variable被设置了一个不为空的值,那么这个表达式的值就是 variable的值;否则,打印 word的值,退出。
${variable:offset:length}获得variable的字串(从 offset开始,长度为length)
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Win10电脑怎么重装IE11浏览器?重装IE11浏览器教程
![](https://img.aspxhome.com/file/2023/2/52062_0s.png)
wps中图片怎么旋转?
![](https://img.aspxhome.com/file/2023/0/a168770_0s.jpg)
Word中Win10出现打开错误的处理方法
Win8杀毒软件Defender阻止修改hosts文件的解决方法
![](https://img.aspxhome.com/file/2023/29/a251683_0s.jpg)
excel2019中公式的概念及运算符的使用情况
![](https://img.aspxhome.com/file/2023/2/a161452_0s.jpg)
Win7开机速度很慢怎么解决?
![](https://img.aspxhome.com/file/2023/1/a277425_0s.jpg)
wps怎样插入文本框
按笔画排序:播放Excel数据(04)
![](https://img.aspxhome.com/file/2023/1/a143071_0s.jpg)
在苹果Mac上如何共享备忘录或文件夹?
![](https://img.aspxhome.com/file/2023/6/a207746_0s.jpeg)
windowsXP系统提示autochk program not found的3种解决方法
你知道Apple 无线鼠标、键盘或触控板各型号的Mac系统要求和区别吗?
![](https://img.aspxhome.com/file/2023/2/a209602_0s.jpeg)
Win10电脑更新驱动之后电脑黑屏了怎么办?
![](https://img.aspxhome.com/file/2023/0/51680_0s.png)
然后在工作表中选择目标行
苹果mac电脑下刻录光盘的技巧分享
Win10创意者1703提示TPM 2.0 CORE PROVISIONING TEST的解决方法
![](https://img.aspxhome.com/file/2023/28/a241888_0s.jpg)
在wps表格中怎样套用求和公式
Excel怎么制作突出数据的扇形饼状图表?
![](https://img.aspxhome.com/file/2023/2/40572_0s.jpg)
Win10如何设置电脑开机密码?Win10设置电脑开机密码的方法
![](https://img.aspxhome.com/file/2023/26/a224503_0s.jpg)
Win7中怎么找到网络连接 如何将win7电脑改造成无线路由器
![](https://img.aspxhome.com/file/2023/29/a256384_0s.jpg)
为什么Win10上的Onedrive打不开?
![](https://img.aspxhome.com/file/2023/26/a221710_0s.png)