OSDN Git Service

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