OSDN Git Service

fixed lfbs
[alterlinux/LFBS.git] / lfbs
1 #!/usr/bin/env bash
2
3 # SPDX-License-Identifier: GPL-3.0
4 #
5 # kokkiemouse
6 # Twitter: @kokkiemouse
7 # Email  : kokkiemouse@gmail.com
8 #
9 # lfbs
10 #
11
12 set -e
13 # set -u
14
15 #export LANG=C
16
17 script_path=$(readlink -f "${0%/*}")
18 work_dir="${script_path}/work"
19 channels_dir="${script_path}/channels"
20 nfb_dir="${script_path}/nfb"
21 codename="32"
22 os_name="Fedora"
23 iso_name="Fedora"
24 language="ja_JP.UTF-8"
25
26 arch=x86_64
27
28 out_dir="${script_path}/out"
29 iso_label="${os_name}_${codename}_${arch}"
30 iso_publisher='Fascode Network <https://fascode.net>'
31 iso_application="${os_name} Live/Rescue CD"
32 iso_version="${codename}-$(date +%Y.%m.%d)"
33 iso_filename="${iso_name}-${iso_version}-${arch}.iso"
34 liveuser_name=fedora
35 liveuser_password=fedora
36 liveuser_shell="/usr/bin/zsh"
37
38 #-- language config --#
39
40 # Sets the default locale for the live environment.
41 # You can also place a package list for that locale name and install packages specific to that locale.
42 locale_name="en"
43 locale_gen_name="en_US.UTF-8"
44 locale_version="gl"
45 locale_time="UTC"
46 locale_fullname="global"
47
48 debug=false
49 cache_only=false
50
51
52 start_time="$(date +%s)"
53
54 _msg_common() {
55     if [[ "${debug}" = true ]]; then
56         local _current_time
57         local _time
58         _current_time="$(date +%s)"
59         _time="$(("${_current_time}"-"${start_time}"))"
60
61         if [[ "${_time}" -ge 3600 ]]; then
62             echo "[$(date -d @${_time} +%H:%M.%S)]$("${script_path}/echo_color" -t 6 "[LFBS Core]")"
63         elif [[ "${_time}" -ge 60 ]]; then
64             echo "[00:$(date -d @${_time} +%M.%S)]$("${script_path}/echo_color" -t 6 "[LFBS Core]")"
65         else
66             echo "[00:00.$(date -d @${_time} +%S)] $("${script_path}/echo_color" -t 6 "[LFBS Core]")"
67         fi
68     else
69         "${script_path}/echo_color" -t 6 "[LFBS Core]"
70     fi
71 }
72
73 # Show an INFO message
74 # _msg_info <message>
75 _msg_info() {
76     local _msg
77     _msg="${@}"
78     echo "$(_msg_common)  $("${script_path}/echo_color" -t 2 "Info:") ${_msg}"
79 }
80
81 # Show an debug message
82 # _msg_debug <message>
83 _msg_debug() {
84     if [[ "${debug}" = true ]]; then
85         local _msg
86         _msg="${@}"
87         echo "$(_msg_common)  $("${script_path}/echo_color" -t 3 "Debug:") ${_msg}"
88     fi
89 }
90
91 # Show an ERROR message then exit with status
92 # _msg_error <message> <exit code>
93 _msg_error() {
94     local _msg
95     local _error
96     _msg="${1}"
97     _error=${2}
98     echo "$(_msg_common)  $("${script_path}/echo_color" -t 1 "Error:") ${_msg}"
99
100     if [[ ! ${_error} = 0 ]]; then
101         exit ${_error}
102     fi
103 }
104
105 # Unmount chroot dir
106 umount_chroot () {
107     local mount
108
109     for mount in $(mount | awk '{print $3}' | grep "$(realpath "${work_dir}")" | sort -r); do
110         if [[ "${mount}" == "${work_dir}/airootfs" ]]; then
111             :
112         else
113             _msg_info "Unmounting ${mount}"
114             umount -fl "${mount}"
115         fi
116     done
117 }
118
119 # Unmount chroot dir and airootfs
120 umount_chroot_airootfs () {
121     local mount
122
123     for mount in $(mount | awk '{print $3}' | grep "$(realpath "${work_dir}")" | sort -r); do
124         _msg_info "Unmounting ${mount}"
125         umount -fl "${mount}"
126     done
127 }
128 # Helper function to run make_*() only one time.
129 run_once() {
130     local name
131     umount_chroot
132     name="$1"
133
134     if [[ ! -e "${work_dir}/build.${name}" ]]; then
135         _msg_info "$(echo $name | sed "s@_@ @g") is starting."
136         "${1}"
137         _msg_info "$(echo $name | sed "s@_@ @g") was done!"
138         touch "${work_dir}/build.${name}"
139     fi
140 }
141
142 run_cmd() {
143     local mount
144
145     for mount in "dev" "dev/pts" "proc" "sys" "etc/resolv.conf"; do
146     #for mount in "dev" "dev/pts" "proc" "sys" ; do
147         if [[ "${mount}" == "etc/resolv.conf" ]]; then
148             cp /etc/resolv.conf "${work_dir}/airootfs/${mount}"
149         else
150             mount --bind /${mount} "${work_dir}/airootfs/${mount}"
151         fi
152     done
153     
154     chroot "${work_dir}/airootfs" "${@}"
155
156     for mount in $(mount | awk '{print $3}' | grep "$(realpath "${work_dir}")" | sort -r); do
157         if [[ "${mount}" == "${work_dir}/airootfs" ]]; then
158             :
159         else
160             umount -fl "${mount}"
161         fi
162     done
163 }
164
165 _dnf_install() {
166     run_cmd dnf install -y ${@}
167 }
168
169 # rm helper
170 # Delete the file if it exists.
171 # For directories, rm -rf is used.
172 # If the file does not exist, skip it.
173 # remove <file> <file> ...
174 remove() {
175     local _list
176     local _file
177     _list=($(echo "$@"))
178
179     for _file in "${_list[@]}"; do
180         _msg_debug "Removeing ${_file}"
181
182         if [[ -f ${_file} ]]; then
183             rm -f "${_file}"
184         elif [[ -d ${_file} ]]; then
185             rm -rf "${_file}"
186         fi
187     done
188 }
189
190 # Show help
191 _usage () {
192     echo "usage ${0} [options] [channel]"
193     echo
194     echo " General options:"
195     echo
196     echo "    -a | --arch <str>      Set architecture"
197     echo "                           Default: ${arch}"
198     echo "    -c | --codename <str>  Set ubuntu codename"
199     echo "                           Default: ${codename}"
200     echo "    -l | --lang <lang>     Specifies the default language for the live environment"
201     echo "                           Default: ${locale_name}"
202     echo "    -m | --mirror <url>    Set apt mirror server."
203     echo "                           Default: ${mirror}"
204     echo "    -o | --out <out_dir>   Set the output directory"
205     echo "                           Default: ${out_dir}"
206     echo "    -w | --work <work_dir> Set the working directory"
207     echo "                           Default: ${work_dir}"
208     echo
209     echo "    -d | --debug           "
210     echo "    -h | --help            This help message and exit"
211     echo
212     echo "You can switch between installed packages, files included in images, etc. by channel."
213     echo
214     echo " Language for each architecture:"
215     for _list in ${script_path}/system/locale-* ; do
216         _arch="${_list#${script_path}/system/locale-}"
217         echo -n "    ${_arch}"
218         for i in $( seq 1 $(( ${blank} - 4 - ${#_arch} )) ); do
219             echo -ne " "
220         done
221         _locale_name_list=$(cat ${_list} | grep -h -v ^'#' | awk '{print $1}')
222         for _lang in ${_locale_name_list[@]};do
223             echo -n "${_lang} "
224         done
225         echo
226     done
227     echo " Channel:"
228     
229     local _channel
230     local channel_list
231     local description
232
233     for _channel in $(ls -l "${channels_dir}" | awk '$1 ~ /d/ {print $9 }'); do
234         if [[ -n $(ls "${channels_dir}/${_channel}") ]] && [[ ! "${_channel}" = "share" ]]; then
235             channel_list+=( "${_channel}" )
236         fi
237     done
238
239     for _channel in ${channel_list[@]}; do
240         if [[ -f "${channels_dir}/${_channel}/description.txt" ]]; then
241             description=$(cat "${channels_dir}/${_channel}/description.txt")
242         else
243             description="This channel does not have a description.txt."
244         fi
245
246         echo -ne "    ${_channel}"
247
248         for i in $( seq 1 $(( 23 - ${#_channel} )) ); do
249             echo -ne " "
250         done
251         
252         echo -ne "${description}\n"
253     done
254 }
255
256
257
258 make_basefs() {
259     _msg_info "Installing Fedora to '${work_dir}/airootfs'..."
260     dnf --installroot="${work_dir}/airootfs" $(${script_path}/system/repository-json-parser.py ${script_path}/system/repository.json) install @Core -y
261     _msg_info "${codename} installed successfully!"
262     
263     echo 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}' > "${work_dir}/airootfs/etc/bash.bashrc"
264     run_cmd dnf update -y
265     run_cmd dnf -y remove $(run_cmd dnf repoquery --installonly --latest-limit=-1 -q)
266     # run_cmd apt-get upgrade
267 }
268
269
270 # Parse files
271 parse_files() {
272     #-- ロケールを解析、設定 --#
273     local _get_locale_line_number _locale_config_file _locale_name_list _locale_line_number _locale_config_line
274
275     # 選択されたロケールの設定が描かれた行番号を取得
276     _locale_config_file="${script_path}/system/locale-${arch}"
277     _locale_name_list=($(cat "${_locale_config_file}" | grep -h -v ^'#' | awk '{print $1}'))
278     _get_locale_line_number() {
279         local _lang _count=0
280         for _lang in ${_locale_name_list[@]}; do
281             _count=$(( _count + 1 ))
282             if [[ "${_lang}" == "${locale_name}" ]]; then echo "${_count}"; return 0; fi
283         done
284         echo -n "failed"
285     }
286     _locale_line_number="$(_get_locale_line_number)"
287
288     # 不正なロケール名なら終了する
289     [[ "${_locale_line_number}" == "failed" ]] && msg_error "${locale_name} is not a valid language." "1"
290
291     # ロケール設定ファイルから該当の行を抽出
292     _locale_config_line=($(cat "${_locale_config_file}" | grep -h -v ^'#' | grep -v ^$ | head -n "${_locale_line_number}" | tail -n 1))
293
294     # 抽出された行に書かれた設定をそれぞれの変数に代入
295     # ここで定義された変数のみがグローバル変数
296     locale_name="${_locale_config_line[0]}"
297     locale_gen_name="${_locale_config_line[1]}"
298     locale_version="${_locale_config_line[2]}"
299     locale_time="${_locale_config_line[3]}"
300     locale_fullname="${_locale_config_line[4]}"
301 }
302 prepare_build() {
303     if [[ ${EUID} -ne 0 ]]; then
304         _msg_error "This script must be run as root." 1
305     fi
306     umount_chroot_airootfs
307     # Check codename
308     if [[ -z $(grep -h -v ^'#' ${channels_dir}/${channel_name}/codename.${arch} | grep -x ${codename}) ]]; then
309         _msg_error "This codename (${channel_name}) is not supported on this channel (${codename})."
310     fi
311     if [[ -d "${work_dir}/squashfsroot/LiveOS/" ]]; then
312         :
313     else
314         mkdir -p "${work_dir}/squashfsroot/LiveOS/"
315         mkdir -p "${work_dir}/airootfs/"
316         _msg_info "Make rootfs image..."
317         truncate -s 5G "${work_dir}/squashfsroot/LiveOS/rootfs.img"
318         _msg_info "Format rootfs image..."
319         mkfs.ext4 -F "${work_dir}/squashfsroot/LiveOS/rootfs.img"
320     fi    
321     if [[ -d "${out_dir}" ]]; then
322         :
323     else
324         mkdir -p "${out_dir}"
325     fi
326     _msg_info "Mount rootfs image..."
327     mount -o loop,rw,sync "${work_dir}/squashfsroot/LiveOS/rootfs.img" "${work_dir}/airootfs"
328
329 }
330
331 make_systemd() {
332     _dnf_install dbus-tools
333     run_cmd dbus-uuidgen --ensure=/etc/machine-id
334     if [[ -d "${work_dir}/airootfs/var/lib/dbus" ]]; then
335         :
336     else
337         run_cmd mkdir /var/lib/dbus
338     fi
339     run_cmd ln -sf /etc/machine-id /var/lib/dbus/machine-id
340 }
341 make_dnf_packages() {
342     remove "${work_dir}/airootfs/dnfpkglist"
343     #_apt_install initramfs-tools
344     # run_cmd env -i bash -c 'DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade --yes'
345
346     if [[ -f "${channels_dir}/share/packages.${arch}" ]]; then
347         grep -h -v ^'#' "${channels_dir}/share/packages.${arch}" | grep -v "^$" >> "${work_dir}/airootfs/dnfpkglist"
348     fi
349     if [[ -f "${channels_dir}/share/packages-${locale_name}.${arch}" ]]; then
350         grep -h -v ^'#' "${channels_dir}/share/packages-${locale_name}.${arch}" | grep -v "^$" >> "${work_dir}/airootfs/dnfpkglist"
351     fi
352
353     if [[ -f "${channels_dir}/${channel_name}/packages.${arch}" ]]; then
354         grep -h -v ^'#' "${channels_dir}/${channel_name}/packages.${arch}" | grep -v "^$" >> "${work_dir}/airootfs/dnfpkglist"
355     fi
356
357     if [[ -f "${channels_dir}/${channel_name}/packages-${locale_name}.${arch}" ]]; then
358         grep -h -v ^'#' "${channels_dir}/${channel_name}/packages-${locale_name}.${arch}" | grep -v "^$" >> "${work_dir}/airootfs/dnfpkglist"
359     fi
360
361     if [[ -s "${work_dir}/airootfs/dnfpkglist" ]]; then
362         run_cmd env -i bash -c 'dnf -y --nogpgcheck install $(echo $(<dnfpkglist))'
363     fi
364
365     remove "${work_dir}/airootfs/dnfpkglist"
366 }
367
368 make_cp_airootfs() {
369     local _copy_airootfs
370
371     _copy_airootfs() {
372         local _dir="${1%/}"
373         if [[ -d "${_dir}" ]]; then
374             cp -af "${_dir}"/* "${work_dir}/airootfs"
375         fi
376     }
377     _copy_airootfs "${channels_dir}/share/airootfs"
378     _copy_airootfs "${channels_dir}/share/airootfs.${locale_name}"
379     _copy_airootfs "${channels_dir}/${channel_name}/airootfs"
380     _copy_airootfs "${channels_dir}/${channel_name}/airootfs.${locale_name}"
381 }
382
383 make_config() {
384
385     # customize_airootfs options
386     # -b                        : Enable boot splash.
387     # -d                        : Enable debug mode.
388     # -g <locale_gen_name>      : Set locale-gen.
389     # -i <inst_dir>             : Set install dir
390     # -k <kernel config line>   : Set kernel name.
391     # -o <os name>              : Set os name.
392     # -p <password>             : Set password.
393     # -s <shell>                : Set user shell.
394     # -t                        : Set plymouth theme.
395     # -u <username>             : Set live user name.
396     # -x                        : Enable bash debug mode.
397     # -r                        : Enable rebuild.
398     # -z <locale_time>          : Set the time zone.
399     # -l <locale_name>          : Set language.
400     #
401     # -j is obsolete in AlterISO3 and cannot be used.
402     # -k changed in AlterISO3 from passing kernel name to passing kernel configuration.
403     local _airootfs_script_options
404     _airootfs_script_options="-p '${liveuser_password}' -u ${liveuser_name} -o ${os_name} -s ${liveuser_shell} -a ${arch} -g ${locale_gen_name} -l ${locale_name} -z ${locale_time} "
405     # X permission
406     local chmod_755
407     chmod_755() {
408         for _file in ${@}; do
409             if [[ -f "$_file" ]]; then chmod 755 "${_file}" ;fi
410         done
411     }
412     chmod_755 "${work_dir}/airootfs/root/customize_airootfs.sh" "${work_dir}/airootfs/root/customize_airootfs_${channel_name}.sh"
413
414     if [ -f ${work_dir}/airootfs/root/customize_airootfs.sh ]; then
415         run_cmd /root/customize_airootfs.sh ${_airootfs_script_options}
416     fi
417     if [ -f ${work_dir}/airootfs/root/customize_airootfs_${channel_name}.sh ]; then
418         run_cmd /root/customize_airootfs_${channel_name}.sh ${_airootfs_script_options}
419     fi
420     run_cmd ln -sf /usr/share/zoneinfo/${locale_time} /etc/localtime
421     echo "LANG=${locale_gen_name}" > "${work_dir}/airootfs/etc/locale.conf"
422     run_cmd truncate -s 0 /etc/machine-id
423     run_cmd passwd -u -f root
424 }
425 make_clean() {
426     run_cmd dnf -y remove $(run_cmd dnf repoquery --installonly --latest-limit=-1 -q)
427     run_cmd dnf clean all
428 }
429
430 make_squashfs() {
431     # prepare
432     [[ -d "${bootfiles_dir}" ]] && rm -r "${bootfiles_dir}"
433     mkdir -p "${bootfiles_dir}"/{grub,LiveOS,boot,isolinux}
434     #generate initrd
435     _msg_info "make initrd..."
436     run_cmd dracut --xz --add "dmsquash-live convertfs pollcdrom" --omit plymouth --no-hostonly --no-early-microcode /boot/initrd0 `run_cmd ls /lib/modules`
437     cp ${work_dir}/airootfs/boot/vmlinuz-$(run_cmd ls /lib/modules) ${bootfiles_dir}/boot/vmlinuz
438     mv ${work_dir}/airootfs/boot/initrd0 ${bootfiles_dir}/boot/initrd
439     #cp isolinux
440     cp "${nfb_dir}"/isolinux/* "${bootfiles_dir}/isolinux/"
441     # make squashfs
442     rm -rf "${work_dir}/airootfs/boot"
443     umount "${work_dir}/airootfs"
444     _msg_info "Minimize rootfs..."
445     resize2fs -M "${work_dir}/squashfsroot/LiveOS/rootfs.img"
446     _msg_info "Compress rootfs.."
447     mksquashfs "${work_dir}/squashfsroot/" "${bootfiles_dir}/LiveOS/squashfs.img"
448 }
449
450 make_nfb() {
451     touch "${bootfiles_dir}/fedora_lfbs"
452     # isolinux setup
453     sed "s|%OS_NAME%|${os_name}|g" "${nfb_dir}/isolinux.cfg" | sed "s|%CD_LABEL%|${iso_label}|g"  > "${bootfiles_dir}/isolinux/isolinux.cfg"
454     #grub
455     sed "s|%OS_NAME%|${os_name}|g" "${nfb_dir}/grub.cfg" | sed "s|%CD_LABEL%|${iso_label}|g" > "${bootfiles_dir}/grub/grub.cfg"
456 }
457 make_efi() {
458     # UEFI 32bit (ia32)
459     grub-mkstandalone \
460         --format=i386-efi \
461         --output="${bootfiles_dir}/grub/bootia32.efi" \
462         --locales="" \
463         --fonts="" \
464         "boot/grub/grub.cfg=${bootfiles_dir}/grub/grub.cfg"
465     
466     # UEFI 64bit (x64)
467     grub-mkstandalone \
468         --format=x86_64-efi \
469         --output="${bootfiles_dir}/grub/bootx64.efi" \
470         --locales="" \
471         --fonts="" \
472         "boot/grub/grub.cfg=${bootfiles_dir}/grub/grub.cfg"
473
474     # create efiboot.img
475     truncate -s 200M "${bootfiles_dir}/grub/efiboot.img"
476     mkfs.fat -F 16 -f 1 -r 112 "${bootfiles_dir}/grub/efiboot.img"
477     mkdir "${bootfiles_dir}/mnt"
478     mount "${bootfiles_dir}/grub/efiboot.img" "${bootfiles_dir}/mnt"
479     mkdir -p "${bootfiles_dir}/mnt/efi/boot"
480     cp "${bootfiles_dir}/grub/bootia32.efi" "${bootfiles_dir}/mnt/efi/boot"
481     cp "${bootfiles_dir}/grub/bootx64.efi" "${bootfiles_dir}/mnt/efi/boot"
482     umount -d "${bootfiles_dir}/mnt"
483     rm -r "${bootfiles_dir}/mnt"
484 }
485 make_iso() {
486     cd "${bootfiles_dir}"
487
488     # create checksum (using at booting)
489     bash -c "(find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt)"
490
491     # create iso
492     xorriso \
493         -as mkisofs \
494         -iso-level 3 \
495         -full-iso9660-filenames \
496         -volid "${iso_label}" \
497         -appid "${iso_application}" \
498         -publisher "${iso_publisher}" \
499         -preparer "prepared by LFBS" \
500         -b isolinux/isolinux.bin \
501             -no-emul-boot \
502             -boot-load-size 4 \
503             -boot-info-table \
504         -eltorito-alt-boot \
505             -eltorito-platform efi \
506             -eltorito-boot EFI/efiboot.img \
507             -no-emul-boot \
508         -isohybrid-mbr "${bootfiles_dir}/isolinux/isohdpfx.bin" \
509         -isohybrid-gpt-basdat \
510         -eltorito-catalog isolinux/boot.cat \
511         -output "${out_dir}/${iso_filename}" \
512         -graft-points \
513             "." \
514             "/isolinux/isolinux.bin=isolinux/isolinux.bin" \
515             "/EFI/efiboot.img=grub/efiboot.img"
516     
517     cd - > /dev/null
518 }
519
520 make_checksum() {
521     cd "${out_dir}"
522     _msg_info "Creating md5 checksum ..."
523     md5sum "${iso_filename}" > "${iso_filename}.md5"
524
525     _msg_info "Creating sha256 checksum ..."
526     sha256sum "${iso_filename}" > "${iso_filename}.sha256"
527     cd - > /dev/null 2>&1
528     umount_chroot_airootfs
529 }
530
531 # 引数解析()
532 # 参考記事:https://0e0.pw/ci83 https://0e0.pw/VJlg
533
534 _opt_short="w:l:o:ha:-:m:c:d"
535 _opt_long="help,arch:,codename:,debug,help,lang,mirror:,out:,work,cache-only"
536 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
537
538 if [[ ${?} != 0 ]]; then
539     exit 1
540 fi
541
542 eval set -- "${OPT}"
543
544 while :; do
545     case ${1} in
546         -a | --arch)
547             if [[ -z ${2} ]]; then
548                 _msg_error "Please specify the architecture."
549                 exit 1
550             else
551                 arch="${2}"
552             fi
553             shift 2
554             ;;
555         -c | --codename)
556             if [[ -z ${2} ]]; then
557                 _msg_error "Please specify the codename."
558                 exit 1
559             else
560                 codename="${2}"
561             fi
562             shift 2
563             ;;
564         -d | --debug)
565             debug=true
566             shift 1
567             ;;
568         -h | --help)
569             _usage
570             exit 0
571             ;;
572         -m | --mirror)
573             if [[ -z ${2} ]]; then
574                 _msg_error "Please specify the mirror server."
575                 exit 1
576             else
577                 mirror="${2}"
578             fi
579
580             shift 2
581             ;;
582         -l | --lang)
583             locale_name="${2}"
584             shift 2
585             ;;
586         -o | --out)
587             if [[ -z ${2} ]]; then
588                 _msg_error "Please specify the out dir."
589                 exit 1
590             else
591                 out_dir="${2}"
592             fi
593
594             shift 2
595             ;;
596         -w | --work)
597             if [[ -z ${2} ]]; then
598                 _msg_error "Please specify the out dir."
599                 exit 1
600             else
601                 work_dir="${2}"
602             fi
603
604             shift 2
605             ;;
606         --cache-only)
607             cache_only=true
608             shift 1
609             ;;
610         --)
611             shift
612             break
613             ;;
614         *)
615             _msg_error "Invalid argument '${1}'"
616             _usage 1
617             ;;
618     esac
619 done
620
621 bootfiles_dir="${work_dir}/bootfiles"
622 trap  umount_chroot 0 2 15
623
624 if [[ -n "${1}" ]]; then
625     channel_name="${1}"
626     if [[ "${channel_name}" = "umount" ]]; then
627         umount_chroot_airootfs
628         exit 0
629     fi
630     if [[ "${channel_name}" = "clean" ]]; then
631         umount_chroot_airootfs
632         _msg_info "deleting work dir..."
633         rm -rf "${work_dir}"
634         exit 0
635     fi
636     check_channel() {
637         local channel_list
638         local i
639         channel_list=()
640         
641         for _channel in $(ls -l "${channels_dir}" | awk '$1 ~ /d/ {print $9 }'); do
642             if [[ -n $(ls "${channels_dir}/${_channel}") ]] && [[ ! "${_channel}" = "share" ]]; then
643                 channel_list+=( "${_channel}" )
644             fi
645         done
646
647         for i in ${channel_list[@]}; do
648             if [[ "${i}" = "${channel_name}" ]]; then
649                 echo -n "true"
650                 return 0
651             fi
652         done
653
654         echo -n "false"
655         return 1
656     }
657
658     if [[ $(check_channel ${channel_name}) = false ]]; then
659         _msg_error "Invalid channel ${channel_name}"
660         exit 1
661     fi
662 fi
663 iso_filename="${iso_name}-${codename}-${channel_name}-${locale_name}-$(date +%Y.%m.%d)-${arch}.iso"
664 umount_chroot_airootfs
665 if [[-d "${work_dir}" ]]; then
666     msg_info "deleting work dir..."
667     rm -rf "${work_dir}"
668 fi
669 prepare_build
670 parse_files
671 run_once make_basefs
672 run_once make_systemd
673 run_once make_dnf_packages
674 run_once make_cp_airootfs
675 run_once make_config
676 run_once make_clean
677 run_once make_squashfs
678 run_once make_nfb
679 run_once make_efi
680 run_once make_iso
681 run_once make_checksum