Skip to content

Commit a3c8d4a

Browse files
committed
Merge branch 'dev' into dev-stable
2 parents c9560b9 + defd0d4 commit a3c8d4a

File tree

11 files changed

+671
-618
lines changed

11 files changed

+671
-618
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: shell
22
script:
33
- bash -c 'shopt -s globstar nullglob; shellcheck -s bash --exclude=SC2068 -S error **/*.{sh,ksh,bash}'
4+
- bash -c 'shopt -s globstar nullglob; shellcheck -s bash --exclude=SC2068 -S error tools/*.{sh,ksh,bash}'
45
git:
56
submodules: false

allarch.sh

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

@@ -365,7 +366,7 @@ prepare_env() {
365366
fi
366367
cd - > /dev/null 2>&1
367368
else
368-
mkalteriso="${script_path}/system/mkalteriso.sh"
369+
mkalteriso="${script_path}/tools/mkalteriso.sh"
369370
fi
370371

371372
# Load loop kernel module
@@ -439,13 +440,6 @@ configure_var() {
439440
iso_filename="${iso_name}-${_channel_name}-${iso_version}-dual.iso"
440441
fi
441442
msg_debug "Iso filename is ${iso_filename}"
442-
443-
# Set mkalteriso
444-
if [[ "${shmkalteriso}" = false ]]; then
445-
mkalteriso="${script_path}/system/mkalteriso"
446-
else
447-
mkalteriso="${script_path}/system/mkalteriso.sh"
448-
fi
449443
}
450444

451445

@@ -487,6 +481,14 @@ prepare_build() {
487481
load_config "${script_path}/channels/share/config.any" "${script_path}/channels/share/config.${arch}"
488482
load_config "${channel_dir}/config.any" "${channel_dir}/config.${arch}"
489483

484+
# Set kernel
485+
if [[ "${customized_kernel}" = false ]]; then
486+
kernel="${defaultkernel}"
487+
fi
488+
489+
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
490+
eval $(bash "${script_path}/tools/kernel.sh" -s -a "${arch}" get "${kernel}")
491+
490492
# Set dirs
491493
airootfs_dir="${work_dir}/${arch}/airootfs"
492494
isofs_dir="${work_dir}/iso"
@@ -1189,12 +1191,6 @@ make_iso() {
11891191
msg_info "The password for the live user and root is ${password}."
11901192
}
11911193

1192-
# Parse files
1193-
parse_files() {
1194-
eval $(bash "${script_path}/tools/locale.sh" -a "${arch}" get "${kernel}")
1195-
eval $(bash "${script_path}/tools/kernel.sh" -a "${arch}" get "${kernel}")
1196-
}
1197-
11981194
# Parse options
11991195
ARGUMENT="${@}"
12001196
_opt_short="bc:deg:hjk:l:o:p:rt:u:w:x"
@@ -1239,6 +1235,7 @@ while :; do
12391235
msg_error "This option is obsolete in AlterISO 3. To use Japanese, use \"-l ja\"." "1"
12401236
;;
12411237
-k | --kernel)
1238+
customized_kernel=true
12421239
kernel="${2}"
12431240
shift 2
12441241
;;
@@ -1363,6 +1360,9 @@ unset DEFAULT_ARGUMENT ARGUMENT
13631360
msg_debug "Use the default configuration file (${defaultconfig})."
13641361
[[ -f "${script_path}/custom.conf" ]] && msg_debug "The default settings have been overridden by custom.conf"
13651362

1363+
# Debug mode
1364+
if [[ "${bash_debug}" = true ]]; then set -x -v; fi
1365+
13661366
set +eu
13671367

13681368
# Check for a valid channel name
@@ -1404,10 +1404,6 @@ if [[ ! "$(cat "${channel_dir}/alteriso" 2> /dev/null)" = "alteriso=${alteriso_v
14041404
fi
14051405
fi
14061406

1407-
for arch in ${all_arch[@]}; do
1408-
parse_files
1409-
done
1410-
14111407
set -eu
14121408

14131409
prepare_env

build.sh

Lines changed: 25 additions & 23 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

@@ -340,7 +341,7 @@ prepare_env() {
340341
fi
341342
cd - > /dev/null 2>&1
342343
else
343-
mkalteriso="${script_path}/system/mkalteriso.sh"
344+
mkalteriso="${script_path}/tools/mkalteriso.sh"
344345
fi
345346

346347
# Load loop kernel module
@@ -476,14 +477,9 @@ 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"
481-
if [[ "${shmkalteriso}" = false ]]; then
482-
mkalteriso="${script_path}/system/mkalteriso"
483-
else
484-
mkalteriso="${script_path}/system/mkalteriso.sh"
485-
fi
486-
487483
_save_var mkalteriso
488484
_save_var shmkalteriso
489485
_save_var mkalteriso_option
@@ -512,10 +508,24 @@ prepare_build() {
512508
build_pacman_conf="${script_path}/system/pacman-${arch}.conf"
513509
fi
514510

511+
# Set dirs
512+
airootfs_dir="${work_dir}/${arch}/airootfs"
513+
share_dir="${script_path}/channels/share"
514+
isofs_dir="${work_dir}/iso"
515+
515516
# If there is config for channel. load that.
516-
load_config "${script_path}/channels/share/config.any" "${script_path}/channels/share/config.${arch}"
517+
load_config "${share_dir}/config.any" "${script_path}/channels/share/config.${arch}"
517518
load_config "${channel_dir}/config.any" "${channel_dir}/config.${arch}"
518519

520+
# Set kernel
521+
if [[ "${customized_kernel}" = false ]]; then
522+
kernel="${defaultkernel}"
523+
fi
524+
525+
# Parse files
526+
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
527+
eval $(bash "${script_path}/tools/kernel.sh" -s -c "${channel_name}" -a "${arch}" get "${kernel}")
528+
519529
# Set username
520530
if [[ "${customized_username}" = false ]]; then
521531
username="${defaultusername}"
@@ -533,11 +543,6 @@ prepare_build() {
533543
cd - > /dev/null 2>&1
534544
fi
535545

536-
# Set dirs
537-
airootfs_dir="${work_dir}/${arch}/airootfs"
538-
share_dir="${script_path}/channels/share"
539-
isofs_dir="${work_dir}/iso"
540-
541546
# Generate iso file name.
542547
local _channel_name
543548
if [[ $(echo "${channel_name}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
@@ -595,8 +600,9 @@ prepare_build() {
595600

596601

597602
# Check kernel for each channel
598-
if [[ -f "${channel_dir}/kernel_list-${arch}" ]] && [[ -z $(cat "${channel_dir}/kernel_list-${arch}" | grep -h -v ^'#' | grep -x "${kernel}" 2> /dev/null) ]]; then
599-
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"
600606
fi
601607

602608
# Unmount
@@ -1248,12 +1254,6 @@ make_iso() {
12481254
msg_info "The password for the live user and root is ${password}."
12491255
}
12501256

1251-
# Parse files
1252-
parse_files() {
1253-
eval $(bash "${script_path}/tools/locale.sh" -a "${arch}" get "${kernel}")
1254-
eval $(bash "${script_path}/tools/kernel.sh" -a "${arch}" get "${kernel}")
1255-
}
1256-
12571257

12581258
# Parse options
12591259
ARGUMENT="${@}"
@@ -1303,6 +1303,7 @@ while :; do
13031303
msg_error "This option is obsolete in AlterISO 3. To use Japanese, use \"-l ja\"." "1"
13041304
;;
13051305
-k | --kernel)
1306+
customized_kernel=true
13061307
kernel="${2}"
13071308
shift 2
13081309
;;
@@ -1430,6 +1431,9 @@ msg_debug "Use the default configuration file (${defaultconfig})."
14301431
# Set rebuild config file
14311432
rebuildfile="${work_dir}/alteriso_config"
14321433

1434+
# Debug mode
1435+
if [[ "${bash_debug}" = true ]]; then set -x -v; fi
1436+
14331437
set +eu
14341438

14351439
# Check for a valid channel name
@@ -1479,8 +1483,6 @@ if [[ ! "${channel_name}" = "rebuild" ]]; then
14791483
fi
14801484
fi
14811485

1482-
parse_files
1483-
14841486
set -eu
14851487

14861488
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: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mode=""
77
arch=""
88
channel=""
99
kernel=""
10+
script=false
1011

1112
_help() {
1213
echo "usage ${0} [options] [command]"
@@ -22,6 +23,7 @@ _help() {
2223
echo " General options:"
2324
echo " -a | --arch [arch] Specify the architecture"
2425
echo " -c | --channel Specify the channel"
26+
echo " -s | --script Enable script mode"
2527
echo " -h | --help This help message"
2628
}
2729

@@ -33,7 +35,7 @@ getclm() {
3335

3436
# Message functions
3537
msg_error() {
36-
"${script_path}/tools/msg.sh" -a "kernel.sh" error "${1}"
38+
"${script_path}/tools/msg.sh" -s 6 -a "kernel.sh" error "${1}"
3739
}
3840

3941
gen_kernel_list() {
@@ -60,8 +62,10 @@ check() {
6062
fi
6163
if [[ $(printf '%s\n' "${kernellist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
6264
echo "correct"
65+
exit 0
6366
else
6467
echo "incorrect"
68+
exit 1
6569
fi
6670
}
6771

@@ -83,7 +87,11 @@ get() {
8387
local _kernel_config_file _kernel_name_list _kernel_line _get_kernel_line _kernel_config_line
8488

8589
# 選択されたカーネルの設定が描かれた行番号を取得
86-
_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
8795
_kernel_name_list=($(cat "${_kernel_config_file}" | grep -h -v ^'#' | getclm 1))
8896
_get_kernel_line() {
8997
local _kernel _count=0
@@ -99,6 +107,9 @@ get() {
99107
# 不正なカーネル名なら終了する
100108
if [[ "${_kernel_line}" = "failed" ]]; then
101109
msg_error "Invalid kernel ${1}"
110+
if [[ "${script}" = true ]]; then
111+
echo "exit 1"
112+
fi
102113
exit 1
103114
fi
104115

@@ -116,8 +127,8 @@ EOF
116127

117128
# Parse options
118129
ARGUMENT="${@}"
119-
_opt_short="a:c:h"
120-
_opt_long="arch:,channel:,help"
130+
_opt_short="a:c:hs"
131+
_opt_long="arch:,channel:,help,script"
121132
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
122133
[[ ${?} != 0 ]] && exit 1
123134

@@ -134,6 +145,10 @@ while true; do
134145
channel="${2}"
135146
shift 2
136147
;;
148+
-s | --script)
149+
script=true
150+
shift 1
151+
;;
137152
-h | --help)
138153
_help
139154
exit 0

0 commit comments

Comments
 (0)