7 while getopts 'xn' arg; do
11 echo "シミュレーションモードを有効化しました"
15 echo "デバッグモードを有効化しました"
21 script_path="$(readlink -f ${0%/*})"
24 function check_files () {
25 if [[ ! -f "${script_path}/build.sh" ]]; then
26 echo "${script_path}/build.shが見つかりませんでした。" >&2
29 if [[ ! -f "${script_path}/keyring.sh" ]]; then
30 echo "${script_path}/keyring.shが見つかりませんでした。" >&2
36 function install_dependencies () {
44 dependence=("git" "make" "arch-install-scripts" "squashfs-tools" "libisoburn" "dosfstools" "lynx" "archiso" "bash" "base")
45 installed_pkg=($(pacman -Q | awk '{print $1}'))
46 installed_ver=($(pacman -Q | awk '{print $2}'))
50 for i in $(seq 1 ${#installed_pkg[@]}); do
51 if [[ ${installed_pkg[${i}]} = ${1} ]]; then
52 if [[ ${installed_ver[${i}]} = $(pacman -Sp --print-format '%v' ${1}) ]]; then
65 for pkg in ${dependence[@]}; do
66 echo "依存パッケージ ${pkg} を確認しています..."
67 if [[ $(check_pkg ${pkg}) = false ]]; then
68 install=(${install[@]} ${pkg})
72 if [[ -n "${install[@]}" ]]; then
74 sudo pacman -S --needed ${install[@]}
80 function run_add_key_script () {
82 echo -n "AlterLinuxの鍵を追加しますか? (y/N) : "
85 echo "${yn}が入力されました。シミュレーションモードが有効化されているためスキップします。"
88 y | Y | yes | Yes | YES ) sudo "${script_path}/keyring.sh" --alter-add ;;
89 n | N | no | No | NO ) return 0 ;;
90 * ) run_add_key_script ;;
96 function remove_dependencies () {
97 if [[ -n "${install[@]}" ]]; then
98 sudo pacman -Rsn ${install[@]}
103 function enable_plymouth () {
105 echo -n "Plymouthを有効化しますか?[no](y/N) : "
108 y | Y | yes | Yes | YES ) plymouth=true ;;
109 n | N | no | No | NO ) plymouth=false ;;
110 * ) enable_plymouth ;;
115 function enable_japanese () {
117 echo -n "日本語を有効化しますか?[no](y/N) : "
120 y | Y | yes | Yes | YES ) japanese=true ;;
121 n | N | no | No | NO ) japanese=false ;;
122 * ) enable_japanese ;;
127 function select_comp_type () {
131 echo -n "圧縮方式を設定しますか?[zstd](y/N) : "
134 y | Y | yes | Yes | YES ) details=true ;;
135 n | N | no | No | NO ) details=false ;;
136 * ) select_comp_type; return 0 ;;
139 function ask_comp_type () {
140 echo "圧縮方式を以下の番号から選択してください "
147 echo "6: zstd (default)"
153 1 ) comp_type="gzip" ;;
154 2 ) comp_type="lzma" ;;
155 3 ) comp_type="lzo" ;;
156 4 ) comp_type="lz4" ;;
157 5 ) comp_type="xz" ;;
158 6 ) comp_type="zstd" ;;
159 gzip ) comp_type="gzip" ;;
160 lzma ) comp_type="lzma" ;;
161 lzo ) comp_type="lzo" ;;
162 lz4 ) comp_type="lz4" ;;
163 xz ) comp_type="xz" ;;
164 zstd ) comp_type="zstd" ;;
169 if [[ ${details} = true ]]; then
179 function set_comp_option () {
180 local ask_comp_option
191 function comp_level () {
193 echo -n "gzipの圧縮レベルを入力してください。 (1~22) : "
195 if [[ ${level} -lt 23 && ${level} -ge 4 ]]; then
196 comp_option="-Xcompression-level ${level}"
202 function window_size () {
204 echo -n "gzipのウィンドウサイズを入力してください。 (1~15) : "
206 if [[ ${window} -lt 16 && ${window} -ge 4 ]]; then
207 comp_option="${comp_option} -Xwindow-size ${window}"
217 echo -n "高圧縮モードを有効化しますか? (y/N) : "
220 y | Y | yes | Yes | YES ) comp_option="-Xhc" ;;
221 n | N | no | No | NO ) : ;;
228 echo -n "zstdの圧縮レベルを入力してください。 (1~22) : "
230 if [[ ${level} -lt 23 && ${level} -ge 4 ]]; then
231 comp_option="-Xcompression-level ${level}"
238 echo "現在lzoは詳細プションのウィザードがサポートされていません。" >&2
242 echo "現在xzは詳細プションのウィザードがサポートされていません。" >&2
255 # lzmaには詳細なオプションはありません。
256 if [[ ! ${comp_type} = "lzma" ]]; then
259 echo -n "圧縮の詳細を設定しますか? (y/N) : "
262 y | Y | yes | Yes | YES ) details=true ;;
263 n | N | no | No | NO ) details=false ;;
264 * ) set_comp_option; return 0 ;;
266 if [[ ${details} = true ]]; then
276 function set_username () {
279 echo -n "デフォルトではないユーザー名を設定しますか? (y/N) : "
282 y | Y | yes | Yes | YES ) details=true ;;
283 n | N | no | No | NO ) details=false ;;
284 * ) set_username; return 0 ;;
287 function ask_username () {
288 echo -n "ユーザー名を入力してください : "
290 if [[ -z ${username} ]]; then
295 if [[ ${details} = true ]]; then
303 function set_password () {
306 echo -n "デフォルトではないパスワードを設定しますか? (y/N) : "
309 y | Y | yes | Yes | YES ) details=true ;;
310 n | N | no | No | NO ) details=false ;;
311 * ) set_password; return 0 ;;
314 function ask_password () {
315 echo -n "パスワードを入力してください : "
318 echo -n "もう一度入力してください : "
320 if [[ ! $password = $confirm ]]; then
322 echo "同じパスワードが入力されませんでした。"
324 elif [[ -z $password || -z $confirm ]]; then
326 echo "パスワードを入力してください。"
333 if [[ ${details} = true ]]; then
341 function select_kernel () {
343 local do_you_want_to_select_kernel
345 function do_you_want_to_select_kernel () {
348 echo -n "デフォルト(zen)以外のカーネルを使用しますか? (y/N) : "
351 y | Y | yes | Yes | YES ) return 0 ;;
352 n | N | no | No | NO ) return 1 ;;
353 * ) do_you_want_to_select_kernel; return 0 ;;
360 function what_kernel () {
361 echo "使用するカーネルを以下の番号から選択してください "
368 echo "6: linux-rt-lts"
370 echo "8: linux-xanmod"
371 echo "9: linux-xanmod-lts"
382 6 ) kernel="rt-lts" ;;
384 8 ) kernel="xanmod" ;;
385 9 ) kernel="xanmod-lts" ;;
386 linux ) kernel="kernel" ;;
387 linux-lts ) kernel="lts" ;;
388 linux-zen ) kernel="zen" ;;
389 linux-ck ) kernel="ck" ;;
390 linux-rt ) kernel="rt" ;;
391 linux-rt-lts ) kernel="rt-lts" ;;
392 linux-lqx ) kernel="lqx" ;;
393 linux-xanmod ) kernel="xanmod" ;;
394 linux-xanmod-lts ) kernel="xanmod-lts" ;;
396 core ) kernel="core" ;;
397 lts ) kernel="lts" ;;
398 zen ) kernel="zen" ;;
401 rt-lts ) kernel="rt-lts" ;;
402 lqx ) kernel="lqx" ;;
403 xanmod ) kernel="xanmod" ;;
404 xanmod-lts ) kernel="xanmod-lts" ;;
409 do_you_want_to_select_kernel
411 if [[ ${exit_code} = 0 ]]; then
419 function select_channel () {
422 echo -n "デフォルト(xfce)以外のチャンネルを使用しますか? (y/N) : "
425 y | Y | yes | Yes | YES ) details=true ;;
426 n | N | no | No | NO ) details=false ;;
427 * ) select_channel; return 0 ;;
430 function ask_channel () {
438 for i in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9 }'); do
439 if [[ -n $(ls "${script_path}"/channels/${i}) ]]; then
440 if [[ ! ${i} = "share" ]]; then
441 channel_list=(${channel_list[@]} ${i})
445 echo "チャンネルを以下の番号から選択してください "
447 for _channel in ${channel_list[@]}; do
448 if [[ -f "${script_path}/channels/${_channel}/description.txt" ]]; then
449 description=$(cat "${script_path}/channels/${_channel}/description.txt")
451 description="This channel does not have a description.txt."
453 if [[ $(echo "${_channel}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
454 echo -ne "${count} $(echo ${_channel} | sed 's/\.[^\.]*$//')"
455 for i in $( seq 1 $(( 23 - ${#_channel} )) ); do
459 echo -ne "${count} ${_channel}"
460 for i in $( seq 1 $(( 19 - ${#_channel} )) ); do
464 echo -ne "${description}\n"
465 count=$(( count + 1 ))
472 expr "${channel}" + 1 >/dev/null 2>&1
473 if [[ ${?} -lt 2 ]]; then
476 channel=$(( channel - 1 ))
477 if [[ -z "${channel_list[${channel}]}" ]]; then
481 channel="${channel_list[${channel}]}"
486 if [[ ! $(printf '%s\n' "${channel_list[@]}" | grep -qx "${channel}.add"; echo -n ${?} ) -eq 0 ]]; then
487 if [[ ! $(printf '%s\n' "${channel_list[@]}" | grep -qx "${channel}"; echo -n ${?} ) -eq 0 ]]; then
495 if [[ ${details} = true ]]; then
504 function set_iso_owner () {
507 function user_check () {
508 if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
518 echo -n "イメージファイルの所有者を入力してください。: "
520 if [[ $(user_check ${owner}) = false ]]; then
524 elif [[ -z "${owner}" ]]; then
525 echo "ユーザー名を入力して下さい。"
528 elif [[ "${owner}" = root ]]; then
536 function set_out_dir () {
537 echo "イメージファイルの作成先を入力して下さい。"
538 echo "デフォルトは ${script_path}/out です。"
541 if [[ -z "${out_dir}" ]]; then
544 if [[ ! -d "${out_dir}" ]]; then
545 echo "存在しているディレクトリを指定して下さい"
548 elif [[ "${out_dir}" = / ]] || [[ "${out_dir}" = /home ]]; then
549 echo "そのディレクトリは使用できません。"
552 elif [[ -n "$(ls ${out_dir})" ]]; then
553 echo "ディレクトリは空ではありません。"
561 # 最終的なbuild.shのオプションを生成
562 function generate_argument () {
563 if [[ ${japanese} = true ]]; then
564 argument="${argument} -j"
566 if [[ ${plymouth} = true ]]; then
567 argument="${argument} -b"
569 if [[ -n ${comp_type} ]]; then
570 argument="${argument} -c ${comp_type}"
572 if [[ -n ${kernel} ]]; then
573 argument="${argument} -k ${kernel}"
575 if [[ -n "${username}" ]]; then
576 argument="${argument} -u '${username}'"
578 if [[ -n ${password} ]]; then
579 argument="${argument} -p '${password}'"
581 if [[ -n ${out_dir} ]]; then
582 argument="${argument} -o '${out_dir}'"
584 argument="${argument} ${channel}"
603 function lastcheck () {
604 echo "以下の設定でビルドを開始します。"
606 [[ -n "${japanese}" ]] && echo " Japanese : ${japanese}"
607 [[ -n "${plymouth}" ]] && echo " Plymouth : ${plymouth}"
608 [[ -n "${kernel}" ]] && echo " kernel : ${kernel}"
609 [[ -n "${comp_type}" ]] && echo " Compression method : ${comp_type}"
610 [[ -n "${comp_option}" ]] && echo "Compression options : ${comp_option}"
611 [[ -n "${username}" ]] && echo " Username : ${username}"
612 [[ -n "${password}" ]] && echo " Password : ${password}"
613 [[ -n "${channel}" ]] && echo " Channel : ${channel}"
615 echo -n "この設定で続行します。よろしいですか? (y/N) : "
619 y | Y | yes | Yes | YES ) : ;;
620 n | N | no | No | NO ) ask ;;
625 function start_build () {
626 if [[ ${nobuild} = true ]]; then
629 # build.shの引数を表示(デバッグ用)
631 sudo ./build.sh ${argument}
638 if [[ -d "${script_path}/work/" ]]; then
639 sudo rm -rf "${script_path}/work/"
644 change_iso_permission() {
645 if [[ -n "${owner}" ]]; then
646 chown -R "${owner}" "${script_path}/out/"
647 chmod -R 750 "${script_path}/out/"
660 change_iso_permission