我有一个系统需要修补内核中的文件才能正常工作。系统运行的是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 的手册页。