7 script_path="$(readlink -f ${0%/*})"
11 # Pacman configuration file used only when building
12 build_pacman_conf=${script_path}/system/pacman-${arch}.conf
23 "arch-install-scripts"
44 if [[ ${lang} = "jp" ]]; then
50 function msg_error() {
51 if [[ ${lang} = "jp" ]]; then
58 if [[ ${lang} = "jp" ]]; then
65 while getopts 'xnje' arg; do
70 "シミュレーションモードを有効化しました" "Enabled simulation mode"
74 msg "デバッグモードを有効化しました" "Debug mode enabled"
90 function set_language () {
91 if [[ ${skip_set_lang} = false ]]; then
92 echo "このウィザードでどちらの言語を使用しますか?"
93 echo "この質問はウィザード内のみの設定であり、ビルドへの影響はありません。"
95 echo "Which language would you like to use for this wizard?"
96 echo "This question is a wizard-only setting and does not affect the build."
99 echo "2: 日本語 Japanese"
109 "English" ) lang=en ;;
110 "Japanese" ) lang=jp ;;
116 function check_files () {
117 if [[ ! -f "${script_path}/build.sh" ]]; then
118 msg_error "${script_path}/build.shが見つかりませんでした。" "${script_path}/build.sh was not found."
121 if [[ ! -f "${script_path}/keyring.sh" ]]; then
122 echo "${script_path}/keyring.shが見つかりませんでした。" "${script_path}/keyring.sh was not found."
128 function install_dependencies () {
135 sudo pacman -Sy --config "${build_pacman_conf}"
136 installed_pkg=($(pacman -Q | awk '{print $1}'))
137 installed_ver=($(pacman -Q | awk '{print $2}'))
141 for i in $(seq 0 $(( ${#installed_pkg[@]} - 1 ))); do
142 if [[ ${installed_pkg[${i}]} = ${1} ]]; then
143 if [[ ${installed_ver[${i}]} = $(pacman -Sp --print-format '%v' --config ${build_pacman_conf} ${1}) ]]; then
156 for pkg in ${dependence[@]}; do
157 msg "依存パッケージ ${pkg} を確認しています..." "Checking dependency package ${pkg} ..."
158 if [[ $(check_pkg ${pkg}) = false ]]; then
159 install=(${install[@]} ${pkg})
162 if [[ -n "${install[@]}" ]]; then
164 sudo pacman -S --needed --config ${build_pacman_conf} ${install[@]}
170 function run_add_key_script () {
172 msg_n "AlterLinuxの鍵を追加しますか?(y/N): " "Are you sure you want to add the AlterLinux key? (y/N):"
176 "${yn}が入力されました。シミュレーションモードが有効化されているためスキップします。" \
177 "You have entered ${yn}. Simulation mode is enabled and will be skipped."
180 y | Y | yes | Yes | YES ) sudo "${script_path}/keyring.sh" --alter-add ;;
181 n | N | no | No | NO ) return 0 ;;
182 * ) run_add_key_script ;;
188 function remove_dependencies () {
189 if [[ -n "${install[@]}" ]]; then
190 sudo pacman -Rsn --config ${build_pacman_conf} ${install[@]}
195 function enable_plymouth () {
197 msg_n "Plymouthを有効化しますか?[no](y/N) : " "Do you want to enable Plymouth? [no] (y/N) : "
200 y | Y | yes | Yes | YES ) plymouth=true ;;
201 n | N | no | No | NO ) plymouth=false ;;
202 * ) enable_plymouth ;;
207 function enable_japanese () {
209 msg_n "日本語を有効化しますか?[no](y/N) : " "Do you want to activate Japanese? [no] (y/N) : "
212 y | Y | yes | Yes | YES ) japanese=true ;;
213 n | N | no | No | NO ) japanese=false ;;
214 * ) enable_japanese ;;
219 function select_comp_type () {
223 msg_n "圧縮方式を設定しますか?[zstd](y/N) : " "Do you want to set the compression method?[zstd](y/N)"
226 y | Y | yes | Yes | YES ) details=true ;;
227 n | N | no | No | NO ) details=false ;;
228 * ) select_comp_type; return 0 ;;
231 function ask_comp_type () {
233 "圧縮方式を以下の番号から選択してください " \
234 "Please select the compression method from the following numbers"
241 echo "6: zstd (default)"
247 1 ) comp_type="gzip" ;;
248 2 ) comp_type="lzma" ;;
249 3 ) comp_type="lzo" ;;
250 4 ) comp_type="lz4" ;;
251 5 ) comp_type="xz" ;;
252 6 ) comp_type="zstd" ;;
253 gzip ) comp_type="gzip" ;;
254 lzma ) comp_type="lzma" ;;
255 lzo ) comp_type="lzo" ;;
256 lz4 ) comp_type="lz4" ;;
257 xz ) comp_type="xz" ;;
258 zstd ) comp_type="zstd" ;;
263 if [[ ${details} = true ]]; then
273 function set_comp_option () {
274 local ask_comp_option
285 function comp_level () {
287 msg_n "gzipの圧縮レベルを入力してください。 (1~22) : " "Enter the gzip compression level. (1~22) : "
289 if [[ ${level} -lt 23 && ${level} -ge 4 ]]; then
290 comp_option="-Xcompression-level ${level}"
296 function window_size () {
299 "gzipのウィンドウサイズを入力してください。 (1~15) : " \
300 "Please enter the gzip window size. (1~15) : "
303 if [[ ${window} -lt 16 && ${window} -ge 4 ]]; then
304 comp_option="${comp_option} -Xwindow-size ${window}"
315 "高圧縮モードを有効化しますか? (y/N) : " \
316 "Do you want to enable high compression mode? (y/N) : "
319 y | Y | yes | Yes | YES ) comp_option="-Xhc" ;;
320 n | N | no | No | NO ) : ;;
328 "zstdの圧縮レベルを入力してください。 (1~22) : " \
329 "Enter the zstd compression level. (1~22) : "
331 if [[ ${level} -lt 23 && ${level} -ge 4 ]]; then
332 comp_option="-Xcompression-level ${level}"
340 "現在lzoの詳細設定ウィザードがサポートされていません。" \
341 "The lzo Advanced Wizard is not currently supported."
346 "現在xzの詳細設定のウィザードがサポートされていません。" \
347 "The xz Advanced Wizard is not currently supported."
360 # lzmaには詳細なオプションはありません。
361 if [[ ! ${comp_type} = "lzma" ]]; then
365 "圧縮の詳細を設定しますか? (y/N) : " \
366 "Do you want to set the compression details? (y/N) : "
369 y | Y | yes | Yes | YES ) details=true ;;
370 n | N | no | No | NO ) details=false ;;
371 * ) set_comp_option; return 0 ;;
373 if [[ ${details} = true ]]; then
383 function set_username () {
387 "デフォルトではないユーザー名を設定しますか? (y/N) : " \
388 "Would you like to set a non-default username? (y/N) : "
391 y | Y | yes | Yes | YES ) details=true ;;
392 n | N | no | No | NO ) details=false ;;
393 * ) set_username; return 0 ;;
396 function ask_username () {
397 msg_n "ユーザー名を入力してください : " "Please enter your username : "
399 if [[ -z ${username} ]]; then
404 if [[ ${details} = true ]]; then
412 function set_password () {
416 "デフォルトではないパスワードを設定しますか? (y/N) : " \
417 "Do you want to set a non-default password? (y/N) : "
420 y | Y | yes | Yes | YES ) details=true ;;
421 n | N | no | No | NO ) details=false ;;
422 * ) set_password; return 0 ;;
425 function ask_password () {
426 msg_n "パスワードを入力してください。" "Please enter your password."
429 msg_n "Type it again : "
431 if [[ ! $password = $confirm ]]; then
433 msg_error "同じパスワードが入力されませんでした。" "You did not enter the same password."
435 elif [[ -z $password || -z $confirm ]]; then
437 msg_error "パスワードを入力してください。" "Please enter your password."
444 if [[ ${details} = true ]]; then
452 function select_kernel () {
454 local do_you_want_to_select_kernel
456 function do_you_want_to_select_kernel () {
460 "デフォルト(zen)以外のカーネルを使用しますか? (y/N) : " \
461 "Do you want to use a kernel other than the default (zen)? (y/N) : "
464 y | Y | yes | Yes | YES ) return 0 ;;
465 n | N | no | No | NO ) return 1 ;;
466 * ) do_you_want_to_select_kernel; return 0 ;;
473 function what_kernel () {
475 "使用するカーネルを以下の番号から選択してください" \
476 "Please select the kernel to use from the following numbers"
480 kernel_list=($(cat ${script_path}/system/kernel_list | grep -h -v ^'#'))
486 for i in ${kernel_list[@]}; do
487 echo "${count}: linux-${i}"
488 count=$(( count + 1 ))
499 expr "${answer}" + 1 >/dev/null 2>&1
500 if [[ ${?} -lt 2 ]]; then
503 answer=$(( answer - 1 ))
504 if [[ -z "${kernel_list[${answer}]}" ]]; then
508 kernel="${kernel_list[${answer}]}"
514 if [[ ! $(printf '%s\n' "${kernel_list[@]}" | grep -qx "${answer#linux-}"; echo -n ${?} ) -eq 0 ]]; then
518 kernel="${answer#linux-}"
523 do_you_want_to_select_kernel
525 if [[ ${exit_code} = 0 ]]; then
533 function select_channel () {
537 "デフォルト(xfce)以外のチャンネルを使用しますか? (y/N) : " \
538 "Do you want to use a channel other than the default (xfce)? (y/N) : "
542 y | Y | yes | Yes | YES ) details=true ;;
543 n | N | no | No | NO ) details=false ;;
544 * ) select_channel; return 0 ;;
547 function ask_channel () {
555 for i in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9 }'); do
556 if [[ -n $(ls "${script_path}"/channels/${i}) ]]; then
557 if [[ ! ${i} = "share" ]]; then
558 channel_list=(${channel_list[@]} ${i})
562 msg "チャンネルを以下の番号から選択してください。" "Select a channel from the numbers below."
564 for _channel in ${channel_list[@]}; do
565 if [[ -f "${script_path}/channels/${_channel}/description.txt" ]]; then
566 description=$(cat "${script_path}/channels/${_channel}/description.txt")
568 if [[ "${lang}" = "jp" ]]; then
569 description="このチャンネルにはdescription.txtがありません。"
571 description="This channel does not have a description.txt."
574 if [[ $(echo "${_channel}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
575 echo -ne "${count} $(echo ${_channel} | sed 's/\.[^\.]*$//')"
576 for i in $( seq 1 $(( 23 - ${#_channel} )) ); do
580 echo -ne "${count} ${_channel}"
581 for i in $( seq 1 $(( 19 - ${#_channel} )) ); do
585 echo -ne "${description}\n"
586 count=$(( count + 1 ))
593 expr "${channel}" + 1 >/dev/null 2>&1
594 if [[ ${?} -lt 2 ]]; then
597 channel=$(( channel - 1 ))
598 if [[ -z "${channel_list[${channel}]}" ]]; then
602 channel="${channel_list[${channel}]}"
607 if [[ ! $(printf '%s\n' "${channel_list[@]}" | grep -qx "${channel}.add"; echo -n ${?} ) -eq 0 ]]; then
608 if [[ ! $(printf '%s\n' "${channel_list[@]}" | grep -qx "${channel}"; echo -n ${?} ) -eq 0 ]]; then
616 if [[ ${details} = true ]]; then
625 function set_iso_owner () {
628 function user_check () {
629 if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
639 msg_n "イメージファイルの所有者を入力してください。: " "Enter the owner of the image file.: "
641 if [[ $(user_check ${owner}) = false ]]; then
645 elif [[ -z "${owner}" ]]; then
646 echo "ユーザー名を入力して下さい。"
649 elif [[ "${owner}" = root ]]; then
657 function set_out_dir () {
658 msg "イメージファイルの作成先を入力して下さい。" "Enter the destination to create the image file."
659 msg "デフォルトは ${script_path}/out です。" "The default is ${script_path}/out."
662 if [[ -z "${out_dir}" ]]; then
665 if [[ ! -d "${out_dir}" ]]; then
667 "存在しているディレクトリを指定して下さい。" \
668 "Please specify the existing directory."
671 elif [[ "${out_dir}" = / ]] || [[ "${out_dir}" = /home ]]; then
673 "そのディレクトリは使用できません。" \
674 "The directory is unavailable."
677 elif [[ -n "$(ls ${out_dir})" ]]; then
680 "The directory is not empty."
688 # 最終的なbuild.shのオプションを生成
689 function generate_argument () {
690 if [[ ${japanese} = true ]]; then
691 argument="${argument} -j"
693 if [[ ${plymouth} = true ]]; then
694 argument="${argument} -b"
696 if [[ -n ${comp_type} ]]; then
697 argument="${argument} -c ${comp_type}"
699 if [[ -n ${kernel} ]]; then
700 argument="${argument} -k ${kernel}"
702 if [[ -n "${username}" ]]; then
703 argument="${argument} -u '${username}'"
705 if [[ -n ${password} ]]; then
706 argument="${argument} -p '${password}'"
708 if [[ -n ${out_dir} ]]; then
709 argument="${argument} -o '${out_dir}'"
711 argument="${argument} ${channel}"
730 function lastcheck () {
731 msg "以下の設定でビルドを開始します。" "Start the build with the following settings."
733 [[ -n "${japanese}" ]] && echo " Japanese : ${japanese}"
734 [[ -n "${plymouth}" ]] && echo " Plymouth : ${plymouth}"
735 [[ -n "${kernel}" ]] && echo " kernel : ${kernel}"
736 [[ -n "${comp_type}" ]] && echo " Compression method : ${comp_type}"
737 [[ -n "${comp_option}" ]] && echo "Compression options : ${comp_option}"
738 [[ -n "${username}" ]] && echo " Username : ${username}"
739 [[ -n "${password}" ]] && echo " Password : ${password}"
740 [[ -n "${channel}" ]] && echo " Channel : ${channel}"
743 "この設定で続行します。よろしいですか? (y/N) : " \
744 "Continue with this setting. Is it OK? (y/N) : "
748 y | Y | yes | Yes | YES ) : ;;
749 n | N | no | No | NO ) ask ;;
754 function start_build () {
755 if [[ ${nobuild} = true ]]; then
758 # build.shの引数を表示(デバッグ用)
760 sudo ./build.sh ${argument}
767 if [[ -d "${script_path}/work/" ]]; then
768 sudo rm -rf "${script_path}/work/"
773 change_iso_permission() {
774 if [[ -n "${owner}" ]]; then
775 chown -R "${owner}" "${script_path}/out/"
776 chmod -R 750 "${script_path}/out/"
790 change_iso_permission