![DKMSを使用して、更新時にカーネルにパッチを適用してインストールする](https://rvso.com/image/36012/DKMS%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%80%81%E6%9B%B4%E6%96%B0%E6%99%82%E3%81%AB%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB%E3%81%AB%E3%83%91%E3%83%83%E3%83%81%E3%82%92%E9%81%A9%E7%94%A8%E3%81%97%E3%81%A6%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B.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 のマニュアルページ。