![Verwenden von DKMS, um beim Update automatisch Patches und Kernel-Installationen durchzuführen](https://rvso.com/image/36012/Verwenden%20von%20DKMS%2C%20um%20beim%20Update%20automatisch%20Patches%20und%20Kernel-Installationen%20durchzuf%C3%BChren.png)
Ich habe ein System, bei dem eine Datei im Kernel gepatcht werden muss, damit es richtig funktioniert. Auf dem System läuft Ubuntu 14.04.
Der Patch patcht eine Datei im drivers/hwmon
.
Daher muss ich nach jedem Kernel-Update die Kernel-Quellen herunterladen, den Patch anwenden, den Kernel neu erstellen und installieren.
Im Wesentlichen ist meine Frage sehr ähnlich zuModul-Patch automatisch anwenden und Kernel beim Update kompilieren?, wo die Verwendung von DKMS empfohlen wird. Es wird ein Link zu allgemeinen DKMS-Dokumenten bereitgestellt, der jedoch nicht die Situation des Patchens eines Moduls abdeckt.
Können Sie mir bitte zeigen, wie ich DKMS so konfiguriere, dass das Patchen automatisch durchgeführt wird? Danke!
Antwort1
Das Patchen eines Moduls ändert nicht wirklich die Vorgehensweise. Was Sie im Grunde brauchen, ist, alle Dateien, die Sie zum Kompilieren eines Out-of-Tree-Builds Ihres jeweiligen Kernelmoduls benötigen, in einen Ordner zu legen und diesem Ordner /usr/src/<modulename>-</moduleversion>/
eine Konfigurationsdatei hinzuzufügen .dkms.conf
Im Wesentlichen sollte es so aussehen:
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
Für Patches schauen Sie sich bitte dieManpage für dkmsunten als Auszug verlinkt:
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.
Dann möchten Sie es bei dkms registrieren, das Modul erstellen und installieren
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
Ich habe Platzhalter für Modulnamen und Version verwendet, aber Sie sollten eine Vorstellung davon haben. Dies alles wird imManpage für dkms.