DKMS policy — различия между версиями

Материал из Rosalab Wiki
Перейти к: навигация, поиск
(Adopted DKMS Policy)
 
 
Строка 1: Строка 1:
[[Category:Kernel Howto]]
+
[[Категория:Packaging Policies]]
[[Category:Packaging Policies]]
+
{{Введение|This page contains the guidelines for packaging kernel modules as DKMS packages in ROSA Linux.}}
{{introduction|This page contains the guidelines for packaging kernel modules as DKMS packages in ROSA Linux.}}
+
  
 
== General ==
 
== General ==
Строка 111: Строка 110:
 
<hr>
 
<hr>
  
{{message|This Policy is based on the [http://wiki.mandriva.com/en/DKMS_packaging_policy Mandriva DKMS Packaging Policy].}}
+
{{Примечание|This Policy is based on the [http://wiki.mandriva.com/en/DKMS_packaging_policy Mandriva DKMS Packaging Policy].}}

Текущая версия на 14:26, 30 мая 2012

This page contains the guidelines for packaging kernel modules as DKMS packages in ROSA Linux.

General

All dkms packages should be named dkms-foo, replacing foo with the driver name (not always same as the module name). They have to have:

Group: System/Kernel and hardware
Requires: dkms
Requires(post): dkms
Requires(preun): dkms

The module source files are installed into %{_usrsrc}/%{name}-%{version}-%{release}. A file named dkms.conf that contains directives for dkms is also installed into this directory. Conditional patches (patches that will be applied depending on kernel version) should be installed into the patches/ subdirectory.

Замечание:
The package should not have any other files or requires, as these are not carried into the possible binary-only dkms packages.

DKMS packages should not be required by any other package, to make binary-only DKMS packages possible.

A DKMS package is generally noarch, unless it contains binary blobs or it is a subpackage of a non-noarch package.

RPM scripts

The following scripts should be used in dkms packages to update dkms data:

%post -n dkms-%{name}
dkms add     -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
dkms build   -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force
true

%preun -n dkms-%{name}
dkms remove  -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
true
  • --rpm_safe-upgrade prevents the uninstallation of the driver in case a package with the same version-release is reinstalled.
  • --force in install prevents dkms from aborting the installation in case DKMS detects that there is already a module installed with the same or higher version in its version tag. Note that not all modules contain the version tag.
  • true prevents the failure of the script, allowing rpm to continue installing/removing the package.

DKMS configuration file

PACKAGE_NAME="%{name}"

The driver name. Should be the one which is in the package name itself.

PACKAGE_VERSION="%{version}-%{release}"

Using %release in the package-version forces dkms to rebuild the module after the package is upgraded, even if %version was not modified. This allows patching the module.

AUTOINSTALL="yes"

The module is automatically built when booting a new kernel.

MAKE[0]="make -C \${kernel_source_dir} M=\\\$(pwd)"
MAKE[0]="make KERNEL_LOCATION=\${kernel_source_dir} KERNVER=\${kernelver}"

MAKE[0] defines the module build command. The first of the above examples can be used if the Makefile is a standard kernel kbuild makefile. DKMS sets $kernel_source_dir to contain the kernel source directory and $kernelver to contain the kernel version. At least $kernel_source_dir has to be used in the MAKE[0] line to allow building modules for other kernels than the running one.

CLEAN="make -C \${kernel_source_dir} M=\\\$(pwd) clean"
CLEAN="make clean"

CLEAN specifies the command that is run after the build to clean the module build tree.

BUILT_MODULE_NAME[0]="adv717x"
BUILT_MODULE_NAME[1]="bt865"
BUILT_MODULE_NAME[2]="em8300"

The names of the modules that this dkms package contains.

BUILT_MODULE_LOCATION[0]="modules"
BUILT_MODULE_LOCATION[1]="modules"
BUILT_MODULE_LOCATION[2]="modules"

(optional) The location in the module build tree that these modules are in after the build. If no BUILT_MODULE_LOCATION is set, "." is assumed.

DEST_MODULE_LOCATION[0]="/kernel/drivers/video"
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"

The location inside the kernel module tree that these modules should be installed into. The directories have to already exist to prevent leaving stale directories behind after the module is removed. (TODO: make dkms remove stale directories in order to allow installing into /dkms/%{name}).

DEST_MODULE_NAME[0]="foo"

(optional) Renames the module to "foo" after the build. This should obviously normally not be done.

PATCH[0]="foo.patch"
PATCH_MATCH[0]="^2\.6\.2[0123]"

(optional) Applies foo.patch when kernel version matches the PATCH_MATCH regexp. Note that cross-version compatible patches should be preferred instead of this. If a patch should be applied unconditionally, it should be done in %prep when building the rpm, as in other packages.

POST_ADD=script.sh
POST_BUILD=
POST_INSTALL=
POST_REMOVE=
PRE_BUILD=
PRE_INSTALL=

(optional) Run a script at the specified stage. The script should be in the dkms module source dir.

MODULES_CONF="options foo no_foo=1"

(optional) Adds the specified line to /etc/modprobe.conf when installing the module. It will be removed when the dkms package is uninstalled. (TODO: use /etc/modprobe.d).

REMAKE_INITRD="yes"

(optional) Remake initrd after module installation.


Idea.png
Примечание
This Policy is based on the Mandriva DKMS Packaging Policy.