「DKMS パッケージガイドライン」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(英語版より転載)
 
(セクションの階層構造を修正)
 
(2人の利用者による、間の4版が非表示)
1行目: 1行目:
[[Category:Arch package guidelines]]
+
[[Category:Arch パッケージガイドライン]]
[[ja:DKMS パッケージガイドライン]]
+
[[en:DKMS package guidelines]]
 
[[pt:DKMS package guidelines]]
 
[[pt:DKMS package guidelines]]
{{Package guidelines}}
+
{{Package Guidelines}}
   
  +
以下は [[DKMS]] パッケージを作成するときのガイドラインです。
Here are some guidelines to follow when creating a [[DKMS]] package.
 
   
  +
== パッケージの名前 ==
== Package name ==
 
   
  +
DKMS パッケージはオリジナルのパッケージ名に "''-dkms''" を加えた名前を付けます。
DKMS packages are named by appending "''-dkms''" to the original package name.
 
   
The variable {{ic|$_pkgname}} is often used below {{ic|$pkgname}} to describe the package name minus the "''-dkms''" suffix (e.g. {{ic|1=_pkgname=${pkgname%-*}}}
+
"''-dkms''" を削ったパッケージ名を表すのによく {{ic|$pkgname}} の下に {{ic|$_pkgname}} 変数が使われます (例: {{ic|1=_pkgname=${pkgname%-*} }})。
   
== Dependencies ==
+
== 依存パッケージ ==
   
  +
依存パッケージは元のパッケージから継承するのに加えて、{{pkg|dkms}} を追加して {{pkg|linux-headers}} を削除します (dkms パッケージは''任意パッケージ''として並べられます)。
Dependencies should be inherited from the original version with {{Pkg|dkms}} added and {{Pkg|linux-headers}} removed (as it is listed by the dkms package as ''optional'').
 
   
  +
== ビルドソースの場所 ==
== Build source location ==
 
   
  +
ビルドソースは次の場所に配置します (DKMS のデフォルトビルドディレクトリです):
Build sources should go into (this is the default build directory for DKMS):
 
   
 
/usr/src/''PACKAGE_NAME''-''PACKAGE_VERSION''
 
/usr/src/''PACKAGE_NAME''-''PACKAGE_VERSION''
   
In the package directory, a DKMS configuration tells DKMS how to build the module ({{ic|dkms.conf}}), including the variables {{ic|PACKAGE_NAME}} and {{ic|PACKAGE_VERSION}}.
+
パッケージディレクトリ内の、モジュールのビルド方法を記述した DKMS の設定 ({{ic|dkms.conf}}) には {{ic|PACKAGE_NAME}} {{ic|PACKAGE_VERSION}} 変数を含めます。
   
* {{ic|PACKAGE_NAME}} - the actual project name (usually {{ic|$_pkgname}} or {{ic|$_pkgbase}}).
+
* {{ic|PACKAGE_NAME}} - 実際のプロジェクト名 (通常は {{ic|$_pkgname}} または {{ic|$_pkgbase}})
* {{ic|PACKAGE_VERSION}} - by convention this should also be the {{ic|$pkgver}}.
+
* {{ic|PACKAGE_VERSION}} - {{ic|$pkgver}} にするのが慣例です。
   
== Patching ==
+
== パッチ ==
   
  +
PKGBUILD または {{ic|dkms.conf}} でソースにパッチを適用できます。
The sources can be patched either directly in the PKGBUILD or through {{ic|dkms.conf}}.
 
   
  +
== .install でモジュールを自動的にロード ==
== Module loading automatically in .install ==
 
   
  +
モジュールのロードやアンロードはユーザーが行うようにしてください。モジュールがロードされたときにクラッシュする可能性を考慮します。
Loading and unloading modules should be left to the user. Consider the possibility a module may crash when loaded.
 
   
Also, please note that you do not have to call {{ic|depmod}} explicitly to update the dependencies of your kernel module. Pacman is now calling DKMS {{ic|dkms install}} and {{ic|dkms remove}} automatically as hooks. {{ic|dkms install}} is making sure {{ic|depmod}} is called at the end of its process. {{ic|dkms install}} depends on {{ic|dkms build}} (to build the source against the current kernel), which itself depends on {{ic|dkms add}} (to add a symlink from {{ic|/var/lib/dkms/<package>/<version>/source}} to {{ic|/usr/src/<package>}}).
+
また、カーネルモジュールの依存関係を更新するのに {{ic|depmod}} を明示的に呼び出す必要はありません。Pacman はフックによって自動的に DKMS {{ic|dkms install}} {{ic|dkms remove}} を実行します。{{ic|dkms install}} によって最後に必ず {{ic|depmod}} が呼びだれます。{{ic|dkms install}} {{ic|dkms build}} に依存しており (最新カーネルに対してソースがビルドされます)、さらに {{ic|dkms build}} {{ic|dkms add}} に依存しています ({{ic|/var/lib/dkms/<package>/<version>/source}} から {{ic|/usr/src/<package>}} にシンボリックリンクが張られます)
   
== Example ==
+
== サンプル ==
   
  +
以下はパッケージ名とバージョンにあわせて {{ic|dkms.conf}} を編集するサンプルパッケージです。
Here is an example package that edits {{ic|dkms.conf}} according to the package name and version.
 
   
 
=== PKGBUILD ===
 
=== PKGBUILD ===
102行目: 102行目:
 
=== .install ===
 
=== .install ===
   
Now pacman has DKMS hooks implemented, you do not have to specify DKMS-specific configuration in your .install file. Calls to {{ic|dkms install}} and {{ic|dkms remove}} will be automatic.
+
pacman には DKMS フックが実装されており、.install ファイルで DKMS 固有の設定を指定する必要はありません。{{ic|dkms install}} {{ic|dkms remove}} は自動的に呼び出されます。

2022年4月20日 (水) 11:50時点における最新版

以下は DKMS パッケージを作成するときのガイドラインです。

パッケージの名前

DKMS パッケージはオリジナルのパッケージ名に "-dkms" を加えた名前を付けます。

"-dkms" を削ったパッケージ名を表すのによく $pkgname の下に $_pkgname 変数が使われます (例: _pkgname=${pkgname%-*})。

依存パッケージ

依存パッケージは元のパッケージから継承するのに加えて、dkms を追加して linux-headers を削除します (dkms パッケージは任意パッケージとして並べられます)。

ビルドソースの場所

ビルドソースは次の場所に配置します (DKMS のデフォルトビルドディレクトリです):

/usr/src/PACKAGE_NAME-PACKAGE_VERSION

パッケージディレクトリ内の、モジュールのビルド方法を記述した DKMS の設定 (dkms.conf) には PACKAGE_NAMEPACKAGE_VERSION 変数を含めます。

  • PACKAGE_NAME - 実際のプロジェクト名 (通常は $_pkgname または $_pkgbase)。
  • PACKAGE_VERSION - $pkgver にするのが慣例です。

パッチ

PKGBUILD または dkms.conf でソースにパッチを適用できます。

.install でモジュールを自動的にロード

モジュールのロードやアンロードはユーザーが行うようにしてください。モジュールがロードされたときにクラッシュする可能性を考慮します。

また、カーネルモジュールの依存関係を更新するのに depmod を明示的に呼び出す必要はありません。Pacman はフックによって自動的に DKMS の dkms installdkms remove を実行します。dkms install によって最後に必ず depmod が呼びだれます。dkms installdkms build に依存しており (最新カーネルに対してソースがビルドされます)、さらに dkms builddkms add に依存しています (/var/lib/dkms/<package>/<version>/source から /usr/src/<package> にシンボリックリンクが張られます)。

サンプル

以下はパッケージ名とバージョンにあわせて dkms.conf を編集するサンプルパッケージです。

PKGBUILD

PKGBUILD
# Maintainer: foo <foo(at)example(dot)org>
# Contributor: bar <bar(at)example(dot)org>

_pkgbase=example
pkgname=example-dkms
pkgver=1
pkgrel=1
pkgdesc="The Example kernel modules (DKMS)"
arch=('i686' 'x86_64')
url="https://www.example.org/"
license=('GPL2')
depends=('dkms')
conflicts=("${_pkgbase}")
install=${pkgname}.install
source=("${url}/files/tarball.tar.gz"
        'dkms.conf'
        'linux-3.14.patch')
md5sums=(use 'updpkgsums')

prepare() {
  cd ${_pkgbase}-${pkgver}

  # Patch
  patch -p1 -i "${srcdir}"/linux-3.14.patch

}

package() {
  # Install
  make DESTDIR="${pkgdir}" install

  # Copy dkms.conf
  install -Dm644 dkms.conf "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/dkms.conf

  # Set name and version
  sed -e "s/@_PKGBASE@/${_pkgbase}/" \
      -e "s/@PKGVER@/${pkgver}/" \
      -i "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/dkms.conf

  # Copy sources (including Makefile)
  cp -r ${_pkgbase}/* "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/
}

dkms.conf

dkms.conf
PACKAGE_NAME="@_PKGBASE@"
PACKAGE_VERSION="@PKGVER@"
MAKE[0]="make --uname_r=$kernelver"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="@_PKGBASE@"
DEST_MODULE_LOCATION[0]="/kernel/drivers/misc"
AUTOINSTALL="yes"

.install

pacman には DKMS フックが実装されており、.install ファイルで DKMS 固有の設定を指定する必要はありません。dkms installdkms remove は自動的に呼び出されます。