OSDN Git Service

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