Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

移除 Linux Kernel 版本號後綴「+」號的原理與作法

編輯:關於 Linux

現象

編譯核心產生的 RPM 版本號尾端多出 +(如 3.10.28+),通常因 Git 倉庫有未提交變更。

機制解析

  • Makefile 定義 VERSION、PATCHLEVEL、SUBLEVEL、EXTRAVERSION。
  • scripts/setlocalversion 若偵測到 CONFIG_LOCALVERSION_AUTO=y 且 Git 非乾淨狀態,會在版本後附加 +。

移除方法

  1. 編譯時指定空字串:
    LOCALVERSION= make
  2. 或關閉 CONFIG_LOCALVERSION_AUTO(make menuconfig → General setup → 取消 Local version - append to kernel release)。

補充:Git 版本資訊取得

git rev-parse --verify --short HEAD   # 短雜湊
git log --pretty=format:'%h' -n 1     # 同樣結果

結語

理解版本號生成邏輯,以 LOCALVERSION= 或關閉自動附加,即可產出乾淨版本號的核心套件。

Copyright © Windows教程網 All Rights Reserved