![使用 DKMS,在更新時自動修補和安裝內核](https://rvso.com/image/36012/%E4%BD%BF%E7%94%A8%20DKMS%EF%BC%8C%E5%9C%A8%E6%9B%B4%E6%96%B0%E6%99%82%E8%87%AA%E5%8B%95%E4%BF%AE%E8%A3%9C%E5%92%8C%E5%AE%89%E8%A3%9D%E5%85%A7%E6%A0%B8.png)
我有一個系統需要修補核心中的檔案才能正常運作。系統運作的是Ubuntu 14.04。
該補丁修補了drivers/hwmon
.
因此,每次核心更新後,我都需要下載核心原始碼、套用修補程式、重建核心並安裝它。
本質上,我的問題非常類似於更新時自動應用模組補丁並編譯核心?,其中建議使用 DKMS。提供了通用 DKMS 文件的鏈接,但它不涵蓋修補模組的情況。
您能告訴我如何設定 DKMS 以自動執行修補嗎?謝謝!
答案1
修補模組並不會真正改變方式。您基本上需要的是將編譯特定核心模組的樹外建置所需的所有檔案放入一個資料夾中,/usr/src/<modulename>-</moduleversion>/
並且需要將設定檔新增dkms.conf
到該資料夾中。
基本上它應該看起來像這樣:
MAKE="make -C $kernel_source_dir M=\$(pwd)"
PACKAGE_NAME=hwmon
PACKAGE_VERSION=1.2.3.4
BUILT_MODULE_NAME[0]="hwmon"
DEST_MODULE_LOCATION[0]="/kernel/extra"
AUTOINSTALL=yes
對於補丁,您應該看看dkms 的手冊頁連結到下面,作為摘錄:
PATCH[#]= Use the PATCH directive array to specify patches which should be applied to your source before a build occurs. All patches are expected to be in -p1 format and are applied with the patch -p1 command. Each directive should specify the filename of the patch to apply, and all patches must be located in the patches subdirectory of your source directory ( /usr/src/<mod‐ ule>-<module-version>/patches/ ). If any patch fails to apply, the build will be halted and the rejections can be inspected in /var/lib/dkms/<mod‐ ule>/<module-version>/build/. If a PATCH should only be applied condition‐ ally, the PATCH_MATCH[#] array should be used, and a corresponding regular expression should be placed in PATCH_MATCH[#] which will alert dkms to only use that PATCH[#] if the regular expression matches the kernel which the mod‐ ule is currently being built for. PATCH_MATCH[#]= See the above description for PATCH[#] directives. If you only want a patch applied in certain scenarios, the PATCH_MATCH array should be utilized by giving a regular expression which matches the kernels you intend the corre‐ sponding PATCH[#] to be applied to before building that module.
然後你想向 dkms 註冊它,建造並安裝模組
dkms add -m hwmon -v 1.2.3.4
dkms build -m hwmon -v 1.2.3.4
dkms install -m hwmon -v 1.2.3.4
我已經使用佔位符來表示模組名稱和版本,但您應該明白了。這全部涵蓋在dkms 的手冊頁。