Skip to content

Commit 3f87798

Browse files
committed
Merge branch 'channel-kernel-config' into dev
2 parents 7b23ade + 8a3cfce commit 3f87798

File tree

6 files changed

+75
-25
lines changed

6 files changed

+75
-25
lines changed

build.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ defaultconfig="${script_path}/default.conf"
2020
rebuild=false
2121
customized_username=false
2222
customized_password=false
23+
customized_kernel=false
2324
DEFAULT_ARGUMENT=""
2425
alteriso_version="3.0"
2526

@@ -476,6 +477,7 @@ prepare_rebuild() {
476477
_save_var defaultusername
477478
_save_var customized_username
478479
_save_var customized_password
480+
_save_var customized_kernel
479481

480482
_write_rebuild_file "\n# mkalteriso Info"
481483
_save_var mkalteriso
@@ -510,6 +512,15 @@ prepare_build() {
510512
load_config "${script_path}/channels/share/config.any" "${script_path}/channels/share/config.${arch}"
511513
load_config "${channel_dir}/config.any" "${channel_dir}/config.${arch}"
512514

515+
# Set kernel
516+
if [[ "${customized_kernel}" = false ]]; then
517+
kernel="${defaultkernel}"
518+
fi
519+
520+
# Parse files
521+
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
522+
eval $(bash "${script_path}/tools/kernel.sh" -s -c "${channel_name}" -a "${arch}" get "${kernel}")
523+
513524
# Set username
514525
if [[ "${customized_username}" = false ]]; then
515526
username="${defaultusername}"
@@ -589,8 +600,9 @@ prepare_build() {
589600

590601

591602
# Check kernel for each channel
592-
if [[ -f "${channel_dir}/kernel_list-${arch}" ]] && [[ -z $(cat "${channel_dir}/kernel_list-${arch}" | grep -h -v ^'#' | grep -x "${kernel}" 2> /dev/null) ]]; then
593-
msg_error "This kernel is currently not supported on this channel." "1"
603+
#if [[ -f "${channel_dir}/kernel_list-${arch}" ]] && [[ -z $(cat "${channel_dir}/kernel_list-${arch}" | grep -h -v ^'#' | grep -x "${kernel}" 2> /dev/null) ]]; then
604+
if [[ ! "$(bash "${script_path}/tools/kernel.sh" -c "${channel_name}" -a "${arch}" -s check "${kernel}")" = "correct" ]]; then
605+
msg_error "This kernel is currently not supported on this channel or architecture" "1"
594606
fi
595607

596608
# Unmount
@@ -1242,12 +1254,6 @@ make_iso() {
12421254
msg_info "The password for the live user and root is ${password}."
12431255
}
12441256

1245-
# Parse files
1246-
parse_files() {
1247-
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
1248-
eval $(bash "${script_path}/tools/kernel.sh" -s -a "${arch}" get "${kernel}")
1249-
}
1250-
12511257

12521258
# Parse options
12531259
ARGUMENT="${@}"
@@ -1297,6 +1303,7 @@ while :; do
12971303
msg_error "This option is obsolete in AlterISO 3. To use Japanese, use \"-l ja\"." "1"
12981304
;;
12991305
-k | --kernel)
1306+
customized_kernel=true
13001307
kernel="${2}"
13011308
shift 2
13021309
;;
@@ -1476,8 +1483,6 @@ if [[ ! "${channel_name}" = "rebuild" ]]; then
14761483
fi
14771484
fi
14781485

1479-
parse_files
1480-
14811486
set -eu
14821487

14831488
prepare_env

channels/releng/config.any

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ usershell="/bin/zsh"
5151
# This setting cannot be changed by an argument.
5252
noaur=true
5353

54-
# kernel config
55-
_kernel_config_line=("core" "vmlinuz-linux" "linux")
56-
kernel="${_kernel_config_line[0]}"
57-
kernel_filename="${_kernel_config_line[1]}"
58-
kernel_mkinitcpio_profile="${_kernel_config_line[2]}"
54+
#-- kernel config --#
55+
# Set the kernel that live session use.
56+
# Please don't set anything if you want to use normal kernel.
57+
# See help for a list of available values.
58+
# This setting cannot be changed by an argument.
59+
60+
# Kernel name
61+
defaultkernel="core"
5962

6063
# Use mkalteriso written in a traditional shell script
6164
# instead of the C ++ version of mkalteriso.

default.conf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,10 @@ norescue_entry=false
124124
# Set the kernel that live session use.
125125
# Please don't set anything if you want to use normal kernel.
126126
# See help for a list of available values.
127-
# Change the default behavior of "-k" and "--kernel".
127+
# This setting cannot be changed by an argument.
128128

129129
# Kernel name
130-
kernel="zen"
131-
132-
# Kernel file name
133-
kernel_filename="vmlinuz-linux-zen"
134-
135-
# mkinitcpio profile name (mkinitcpio -p <name>)
136-
kernel_mkinitcpio_profile="linux-zen"
137-
130+
defaultkernel="zen"
138131

139132
#-- Live environment user --#
140133

docs/jp/CHANNEL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ rt
221221
#lqx
222222
```
223223

224+
## kernel-<arch>
225+
`/system/kernel-<arch>`を置き換える役割を果たします。そのためファイル構文は`/system/kernel-<arch>`と変わりません。
226+
`kernek_list-<arch>`とは違って使用可能なカーネルの詳細を設定します。
227+
224228
## README
225229
チャンネルの詳細を書いたテキストファイルです。ビルドには一切影響されませんが、GitHub上で見た際に表示されるので、簡単なガイドの役割を果たします。作成しておいて損はないでしょう。
226230

docs/jp/ORIGINAL_KERNEL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## チャンネルで独自に新しいカーネルをサポートする
2+
AlterISO3ではカーネルに関する処理が大幅に変更され、チャンネルのみで独自にカーネルを追加することができるようになりました。
3+
ここではAlterISO本体のコードを変更せずにチャンネルだけで独自のカーネルを使用する方法を解説します。
4+
5+
## 追加したいカーネルの情報を把握する
6+
カーネルを追加するにはいくつかの設定ファイルを編集する必要があります。
7+
それぞれの設定ファイルの詳細については[CHANNEL.md](./CHANNEL.md)を参考にして下さい。
8+
9+
カーネルを設定するには以下の情報が必要です。
10+
- カーネルのパッケージ名
11+
- (AURからビルドする以外は)そのカーネルのパッケージがホストされているリポジトリの情報
12+
- リポジトリ名
13+
- 公開鍵
14+
- サーバのURL
15+
- `mkinitcpio`によって`/boot`以下に作成されるカーネルのファイル名
16+
- `mkinitcpio -p`で指定するプロファイル名
17+
- カーネルの略称(他のカーネルと重複しない名前ならなんでもOK)
18+
19+
## カーネル設定ファイルを作成する
20+
カーネルの情報を`/system/kernel-<arch>`を参考に作成して下さい。その後作成した設定ファイルをチャンネル内に配置して下さい。
21+
ビルドスクリプトは、`/system/kernel-<arch>`の代わりにチャンネル内の設定ファイルを使用します。
22+
その設定ファイル内の記述されているカーネルしか使用できなくなるので、`/system/kernel-<arch>`で既に設定されているカーネルも記述して下さい。
23+
24+
## カーネルリストを作成する
25+
そのチャンネルが使用可能なカーネルの一覧を書いたファイル(`kernel_list-<arch>`)にカーネル設定ファイルで指定したカーネル名を追記して下さい。
26+
カーネルリストに書かれていないとビルドに使用できません。逆に言えば、一時的にカーネルを無効化したい場合はカーネル設定ファイルを編集するのではなくカーネルリストでコメントアウトして下さい。
27+
28+
## カーネルのパッケージファイルを作成する
29+
`packages.<arch>/kernel/<kernel_name>`ディレクトリを作成して下さい。このディレクトリ内のパッケージはそのカーネルが指定された場合のみインストールされます。
30+
デフォルトで使用可能な`zen``lts`などのカーネルパッケージは`share`チャンネルで指定されています。
31+
参考: [shareチャンネルのlinux-ltsのパッケージファイル1](https://github.com/FascodeNet/alterlinux/blob/dev/channels/share/packages.x86_64/kernel/lts.x86_64)
32+
33+
## pacman-<arch>.confにリポジトリを追加する
34+
チャンネルの`pacman-<arch>.conf`にそのカーネルのパッケージが存在しているリポジトリの情報を追記して下さい。
35+
AURから直接ビルドすることもできますが、ビルドに非常に時間がかかるのでおすすめできません。
36+
リポジトリによっては公開鍵を追加する必要があります。
37+
38+
## config.<arch>でデフォルトカーネルを設定する
39+
`config.<arch>`内の`defaultkernel`変数でユーザーがカーネルを指定しなかった場合のデフォルトを指定できます。
40+
`releng`チャンネルでは`core`カーネルがデフォルトに設定されています。
41+
参考: [https://github.com/FascodeNet/alterlinux/blob/dev/channels/releng/config.any](https://github.com/FascodeNet/alterlinux/blob/dev/channels/releng/config.any)

tools/kernel.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ get() {
8787
local _kernel_config_file _kernel_name_list _kernel_line _get_kernel_line _kernel_config_line
8888

8989
# 選択されたカーネルの設定が描かれた行番号を取得
90-
_kernel_config_file="${script_path}/system/kernel-${arch}"
90+
if [[ -n "${channel}" ]] && [[ -f "${script_path}/channels/${channel}/kernel-${arch}" ]]; then
91+
_kernel_config_file="${script_path}/channels/${channel}/kernel-${arch}"
92+
else
93+
_kernel_config_file="${script_path}/system/kernel-${arch}"
94+
fi
9195
_kernel_name_list=($(cat "${_kernel_config_file}" | grep -h -v ^'#' | getclm 1))
9296
_get_kernel_line() {
9397
local _kernel _count=0

0 commit comments

Comments
 (0)