「Kbuilder」の版間の差分
Kusanaginoturugi (トーク | 投稿記録) (→See also: 飜訳) |
Kusanaginoturugi (トーク | 投稿記録) (一部飜訳) |
||
| 1行目: | 1行目: | ||
[[Category:カーネル]] |
[[Category:カーネル]] |
||
| + | kbuilder は、公式にサポートされている 4 つのカーネルのうちの 1 つを、独自のオプションのパッチや設定を加えて、別のパッケージ名でローカルにビルドすることができる bash スクリプトです。 |
||
| − | kbuilder is a bash script that allows you to build one of the four officially supported kernels locally with your own optional patches and configuration, under a different package name. |
||
| + | 例えば、{{Pkg|linux-lts}} カーネルのソースを取得し、カーネルをインテルプロセッサに最適化するパッチを適用し、そのカーネルを '''linux-lts-intel-optimized''' としてインストールすることができます。 |
||
| − | For example, you could fetch the sources of the {{Pkg|linux-lts}} kernel, apply a patch that optimizes the kernel for intel processors, and install that kernel as '''linux-lts-intel-optimized'''. |
||
| − | == |
+ | == インストール == |
| + | kbuilder の取得には以下の方法があります: |
||
| − | The following methods can be used to get kbuilder: |
||
| − | * |
+ | * {{AUR|kbuilder}} パッケージを[[インストール]]する。 |
| − | * |
+ | * [https://github.com/AnnikaV9/kbuilder github リポジトリ]から最新の開発版をインストールする。 |
| + | == カーネルのビルド == |
||
| − | == Building a kernel == |
||
| − | + | デフォルトのバニラ {{Pkg|linux}} カーネルソースを取得し、デフォルトの名前 '''linux-kbuilder-custom''' でパッケージをビルドします: |
|
$ kbuilder build |
$ kbuilder build |
||
| − | {{Note| |
+ | {{Note|ビルドディレクトリは {{ic|~/.kbuilder/cache}} です。}} |
| + | ビルドの過程で、kbuilder は PKGBUILD に bash シェルを注入します。このシェルは {{ic|build()}} が呼ばれる直前に実行され、パッチの追加やカーネル設定の変更をインタラクティブに行うことができます。シェルから抜けるとビルドは継続されます。 |
||
| − | During the build process, kbuilder will inject a bash shell into the PKGBUILD. The shell will be run right before {{ic|build()}} is called, allowing you to add any patches or change the kernel config interactively. The build will continue once you exit from the shell. |
||
| + | ビルドしたパッケージをインストールする: |
||
| − | To install the built packages: |
||
$ kbuilder install |
$ kbuilder install |
||
2023年4月3日 (月) 17:42時点における版
kbuilder は、公式にサポートされている 4 つのカーネルのうちの 1 つを、独自のオプションのパッチや設定を加えて、別のパッケージ名でローカルにビルドすることができる bash スクリプトです。
例えば、linux-lts カーネルのソースを取得し、カーネルをインテルプロセッサに最適化するパッチを適用し、そのカーネルを linux-lts-intel-optimized としてインストールすることができます。
インストール
kbuilder の取得には以下の方法があります:
- kbuilderAUR パッケージをインストールする。
- github リポジトリから最新の開発版をインストールする。
カーネルのビルド
デフォルトのバニラ linux カーネルソースを取得し、デフォルトの名前 linux-kbuilder-custom でパッケージをビルドします:
$ kbuilder build
ビルドの過程で、kbuilder は PKGBUILD に bash シェルを注入します。このシェルは build() が呼ばれる直前に実行され、パッチの追加やカーネル設定の変更をインタラクティブに行うことができます。シェルから抜けるとビルドは継続されます。
ビルドしたパッケージをインストールする:
$ kbuilder install
Build variables
Although kbuilder does not have a configuration file, you can control the build process with environment variables.
KBUILDER_SOURCE_PKGshould be set as 'linux', 'linux-lts', 'linux-zen' or 'linux-hardened'. kbuilder will fetch and build the kernel specified with this variable. Defaults to 'linux'. For more information about the official kernels, see kernel.
KBUILDER_PKG_NAME_APPENDcan be set as any string. It will be appended to the end of the kernel version and the kernel package. Defaults to 'kbuilder-custom'.
KBUILDER_BUILD_JOBSshould be set as an integer. kbuilder will replace themake allline in the PKGBUILD withmake -jX all, where X is the integer specified.
Example usage:
$ KBUILDER_BUILD_JOBS=4 KBUILDER_PKG_NAME_APPEND="my-custom-patch" KBUILDER_SOURCE_PKG="linux-zen" kbuilder build
Hooks
kbuilder looks for hooks in /etc/kbuilder/hooks/, and uses run-parts to execute them right before build() is called. The run-parts command is executed with the flag --regex "kbuilder-hook-*".
An example hook:
/etc/kbuilder/hooks/05-kbuilder-hook-cpu-optimize.sh
#!/bin/bash
#
# kbuilder hook for applying graysky2's kernel compiler patch:
# https://github.com/graysky2/kernel_compiler_patch
#
SOURCE="https://raw.githubusercontent.com/graysky2/kernel_compiler_patch/master"
PATCH="more-uarches-for-kernel-5.17+.patch"
HOOK_NAME="cpu-optimize-hook"
curl -o $PATCH $SOURCE/$PATCH || { echo "$HOOK_NAME failed when fetching $PATCH from $SOURCE" ; exit 1 ; }
patch -Np1 -i "$PATCH" || { echo "$HOOK_NAME failed when applying $PATCH" ; exit 1 ; }
To create a hook, create and make executable a file, with a name following the xx-kbuilder-hook-hookname form: they will be run in order according to the xx value.