@@ -126,9 +126,9 @@ _usage () {
126126 done
127127
128128 echo " Channel:"
129- for _dirname in $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -d -b -n show) ; do
130- echo -ne " ${_dirname% .add } $( echo_blank " $(( "${blank} " - 3 - "$(echo " ${ _dirname% .add} " | wc - m) " )) " ) "
131- " ${tools_dir} /channel.sh" --version " ${alteriso_version} " --nocheck desc " ${_dirname% .add } "
129+ for _dirname in $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -d -b -n --line show | sed " s|.add$||g " ) ; do
130+ echo -ne " ${_dirname} $( echo_blank " $(( "${blank} " - 4 - "${ # _dirname} " )) " ) "
131+ " ${tools_dir} /channel.sh" --version " ${alteriso_version} " --nocheck desc " ${_dirname} "
132132 done
133133
134134 echo
@@ -324,9 +324,7 @@ prepare_env() {
324324 if [[ " ${nodepend} " = false ]]; then
325325 local _check_failed=false _pkg _result=0
326326 msg_info " Checking dependencies ..."
327- if ! pacman -Qq pyalpm > /dev/null 2>&1 ; then
328- msg_error " pyalpm is not installed." 1
329- fi
327+ ! pacman -Qq pyalpm > /dev/null 2>&1 && msg_error " pyalpm is not installed." 1
330328 for _pkg in " ${dependence[@]} " ; do
331329 eval " ${tools_dir} /package.py" " ${_pkg} " " $( [[ " ${debug} " = false ]] && echo " > /dev/null" ) " || _result=" ${?} "
332330 if (( _result == 3 )) || (( _result == 4 )) ; then
@@ -340,7 +338,7 @@ prepare_env() {
340338 # Load loop kernel module
341339 if [[ " ${noloopmod} " = false ]]; then
342340 [[ ! -d " /usr/lib/modules/$( uname -r) " ]] && msg_error " The currently running kernel module could not be found.\nProbably the system kernel has been updated.\nReboot your system to run the latest kernel." " 1"
343- [[ -z " $( lsmod | getclm 1 | grep -x " loop" ) " ]] && modprobe loop
341+ lsmod | getclm 1 | grep -x " loop" || modprobe loop
344342 fi
345343
346344 # Check work dir
@@ -384,7 +382,7 @@ show_settings() {
384382 msg_info " Build with architecture ${arch} ."
385383 if [[ " ${noconfirm} " = false ]]; then
386384 echo -e " \nPress Enter to continue or Ctrl + C to cancel."
387- read
385+ read -r
388386 fi
389387 trap 1 2 3 15
390388 trap ' umount_trap' 1 2 3 15
@@ -413,7 +411,7 @@ prepare_build() {
413411 # Legacy mode
414412 if [[ " $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " ver " ${channel_name} " ) " = " 3.0" ]]; then
415413 msg_warn " The module cannot be used because it works with Alter ISO3.0 compatibility."
416- if [[ ! -z " ${include_extra+SET} " ]]; then
414+ if [[ -n " ${include_extra+SET} " ]]; then
417415 if [[ " ${include_extra} " = true ]]; then
418416 modules=(" base" " share" " share-extra" " calamares" " zsh-powerline" )
419417 else
@@ -427,7 +425,7 @@ prepare_build() {
427425 msg_debug " Checking ${1} module ..."
428426 bash " ${tools_dir} /module.sh" check " ${1} " || msg_error " Module ${1} is not available." " 1" ;
429427 }
430- modules=( $( printf " %s\n" " ${modules[@]} " | awk ' !a[$0]++' ) )
428+ readarray -t modules < <( printf " %s\n" " ${modules[@]} " | awk ' !a[$0]++' )
431429 for_module " module_check {}"
432430 for_module load_config " ${module_dir} /{}/config.any" " ${module_dir} /{}/config.${arch} "
433431 msg_debug " Loaded modules: ${modules[*]} "
@@ -450,6 +448,7 @@ prepare_build() {
450448 # Generate iso file name.
451449 local _channel_name=" ${channel_name% .add} -${locale_version} "
452450 iso_filename=" ${iso_name} -${_channel_name} -${iso_version} -${arch} .iso"
451+ tar_filename=" ${iso_filename% .iso} .tar.xz"
453452 [[ " ${nochname} " = true ]] && iso_filename=" ${iso_name} -${iso_version} -${arch} .iso"
454453 msg_debug " Iso filename is ${iso_filename} "
455454
@@ -458,7 +457,7 @@ prepare_build() {
458457
459458 # Check architecture for each channel
460459 local _exit=0
461- bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -a ${arch} -n -b check " ${channel_name} " || _exit=" ${?} "
460+ bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -a " ${arch} " -n -b check " ${channel_name} " || _exit=" ${?} "
462461 if (( "${_exit} " != 0 )) && (( "${_exit} " != 1 )) ; then
463462 msg_error " ${channel_name} channel does not support current architecture (${arch} )." " 1"
464463 fi
@@ -537,7 +536,7 @@ make_basefs() {
537536# Additional packages (airootfs)
538537make_packages_repo () {
539538 msg_debug " pkglist.sh ${pkglist_args[*]} "
540- local _pkglist=( $( " ${tools_dir} /pkglist.sh" " ${pkglist_args[@]} " ) )
539+ readarray -t _pkglist < <( " ${tools_dir} /pkglist.sh" " ${pkglist_args[@]} " )
541540
542541 # Create a list of packages to be finally installed as packages.list directly under the working directory.
543542 echo -e " # The list of packages that is installed in live cd.\n#\n" > " ${build_dir} /packages.list"
@@ -550,7 +549,7 @@ make_packages_repo() {
550549}
551550
552551make_packages_aur () {
553- local _pkglist_aur=( $( " ${tools_dir} /pkglist.sh" --aur " ${pkglist_args[@]} " ) )
552+ readarray -t _pkglist_aur < <( " ${tools_dir} /pkglist.sh" --aur " ${pkglist_args[@]} " )
554553
555554 # Create a list of packages to be finally installed as packages.list directly under the working directory.
556555 echo -e " \n# AUR packages.\n#\n" >> " ${build_dir} /packages.list"
@@ -779,7 +778,7 @@ make_syslinux() {
779778 local _remove_config
780779 function _remove_config() {
781780 remove " ${isofs_dir} /syslinux/${1} "
782- sed -i " s|$( cat " ${isofs_dir} /syslinux/archiso_sys_load.cfg" | grep " ${1} " ) ||g" " ${isofs_dir} /syslinux/archiso_sys_load.cfg"
781+ sed -i " s|$( grep " ${1} " " ${ isofs_dir} /syslinux/archiso_sys_load.cfg" ) ||g" " ${isofs_dir} /syslinux/archiso_sys_load.cfg"
783782 }
784783
785784 [[ " ${norescue_entry} " = true ]] && _remove_config archiso_sys_rescue.cfg
@@ -814,25 +813,18 @@ make_isolinux() {
814813
815814# Prepare /EFI
816815make_efi () {
817- install -d -m 0755 -- " ${isofs_dir} /EFI/boot"
816+ local _bootfile _use_config_name=" nosplash" _efi_config_list=() _efi_config
817+ [[ " ${boot_splash} " = true ]] && _use_config_name=" splash"
818+ _bootfile=" $( basename " $( ls " ${airootfs_dir} /usr/lib/systemd/boot/efi/systemd-boot" * " .efi" ) " ) "
818819
819- local _bootfile= " $( basename " $( ls " ${airootfs_dir} /usr/lib/systemd/ boot/efi/systemd-boot " * " .efi " ) " ) "
820+ install -d -m 0755 -- " ${isofs_dir} /EFI/ boot"
820821 install -m 0644 -- " ${airootfs_dir} /usr/lib/systemd/boot/efi/${_bootfile} " " ${isofs_dir} /EFI/boot/${_bootfile# systemd-} "
821822
822- local _use_config_name=" nosplash"
823- if [[ " ${boot_splash} " = true ]]; then
824- _use_config_name=" splash"
825- fi
826-
827823 install -d -m 0755 -- " ${isofs_dir} /loader/entries"
828824 sed " s|%ARCH%|${arch} |g;" " ${script_path} /efiboot/${_use_config_name} /loader.conf" > " ${isofs_dir} /loader/loader.conf"
829825
830- local _efi_config_list=() _efi_config
831- _efi_config_list+=($( ls " ${script_path} /efiboot/${_use_config_name} /archiso-usb" * " .conf" | grep -v " rescue" ) )
832-
833- if [[ " ${norescue_entry} " = false ]]; then
834- _efi_config_list+=($( ls " ${script_path} /efiboot/${_use_config_name} /archiso-usb" * " .conf" | grep -v " rescue" ) )
835- fi
826+ readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-usb*.conf" -printf " %f" | grep -v " rescue" )
827+ [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-usb*rescue*.conf" -printf " %f" )
836828
837829 for _efi_config in " ${_efi_config_list[@]} " ; do
838830 sed " s|%ARCHISO_LABEL%|${iso_label} |g;
@@ -869,35 +861,27 @@ make_efiboot() {
869861 mkdir -p " ${build_dir} /efiboot"
870862 mount " ${build_dir} /efiboot.img" " ${build_dir} /efiboot"
871863
872- mkdir -p " ${build_dir} /efiboot/EFI/alteriso/${arch} "
864+ mkdir -p " ${build_dir} /efiboot/EFI/alteriso/${arch} " " ${build_dir} /efiboot/EFI/boot " " ${build_dir} /efiboot/loader/entries "
873865 cp " ${isofs_dir} /${install_dir} /boot/${arch} /${kernel_filename} " " ${build_dir} /efiboot/EFI/alteriso/${arch} /${kernel_filename} .efi"
874866 cp " ${isofs_dir} /${install_dir} /boot/${arch} /archiso.img" " ${build_dir} /efiboot/EFI/alteriso/${arch} /archiso.img"
875867
876- local _ucode_image
868+ local _ucode_image _efi_config _use_config_name= " nosplash " _bootfile
877869 for _ucode_image in " ${airootfs_dir} /boot/" {intel-uc.img,intel-ucode.img,amd-uc.img,amd-ucode.img,early_ucode.cpio,microcode.cpio}; do
878870 [[ -e " ${_ucode_image} " ]] && cp " ${_ucode_image} " " ${build_dir} /efiboot/EFI/alteriso/"
879871 done
880872
881- mkdir -p " ${build_dir} /efiboot/EFI/boot"
882-
883873 cp " ${airootfs_dir} /usr/share/efitools/efi/HashTool.efi" " ${build_dir} /efiboot/EFI/boot/"
884874
885- local _bootfile=" $( basename " $( ls " ${airootfs_dir} /usr/lib/systemd/boot/efi/systemd-boot" * " .efi" ) " ) "
875+ _bootfile=" $( basename " $( ls " ${airootfs_dir} /usr/lib/systemd/boot/efi/systemd-boot" * " .efi" ) " ) "
886876 cp " ${airootfs_dir} /usr/lib/systemd/boot/efi/${_bootfile} " " ${build_dir} /efiboot/EFI/boot/${_bootfile# systemd-} "
887877
888- local _use_config_name=" nosplash"
889878 [[ " ${boot_splash} " = true ]] && _use_config_name=" splash"
890-
891- mkdir -p " ${build_dir} /efiboot/loader/entries"
892879 sed " s|%ARCH%|${arch} |g;" " ${script_path} /efiboot/${_use_config_name} /loader.conf" > " ${build_dir} /efiboot/loader/loader.conf"
893880
894881 find " ${isofs_dir} /loader/entries/" -maxdepth 1 -mindepth 1 -name " uefi-shell*" -type f -printf " %p\0" | xargs -0 -I{} cp {} " ${build_dir} /efiboot/loader/entries/"
895882
896- local _efi_config _efi_config_list=($( ls " ${script_path} /efiboot/${_use_config_name} /archiso-cd" * " .conf" ) )
897-
898- if [[ " ${norescue_entry} " = false ]]; then
899- _efi_config_list=($( printf " %s\n" " ${_efi_config_list[@]} " | grep -v " rescue" ) )
900- fi
883+ readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-cd*.conf" -printf " %f" | grep -v " rescue" )
884+ [[ " ${norescue_entry} " = false ]] && readarray -t _efi_config_list < <( find " ${script_path} /efiboot/${_use_config_name} /" -mindepth 1 -maxdepth 1 -type f -name " archiso-cd*rescue*.conf" -printf " %f" )
901885
902886 for _efi_config in " ${_efi_config_list[@]} " ; do
903887 sed " s|%ARCHISO_LABEL%|${iso_label} |g;
@@ -922,9 +906,7 @@ make_tarball() {
922906
923907 # Run script
924908 mount_airootfs
925- if [[ -f " ${airootfs_dir} /root/optimize_for_tarball.sh" ]]; then
926- _chroot_run " bash /root/optimize_for_tarball.sh -u ${username} "
927- fi
909+ [[ -f " ${airootfs_dir} /root/optimize_for_tarball.sh" ]] && _chroot_run " bash /root/optimize_for_tarball.sh -u ${username} "
928910
929911 _cleanup_common
930912 _chroot_run " mkinitcpio -P"
@@ -933,20 +915,17 @@ make_tarball() {
933915
934916 mkdir -p " ${out_dir} "
935917 msg_info " Creating tarball..."
936- local tar_path=" $( realpath ${out_dir} ) /${iso_filename% .iso} .tar.xz"
937918 cd -- " ${airootfs_dir} "
938- tar -v -J -p -c -f " ${tar_path } " ./*
919+ tar -v -J -p -c -f " ${out_dir} / ${tar_filename }" ./*
939920 cd -- " ${OLDPWD} "
940921
941- _mkchecksum " ${tar_path } "
942- msg_info " Done! | $( ls -sh ${tar_path} ) "
922+ _mkchecksum " ${out_dir} / ${tar_filename }"
923+ msg_info " Done! | $( ls -sh " ${out_dir} / ${tar_filename} " ) "
943924
944925 remove " ${airootfs_dir} .img"
945926 mv " ${airootfs_dir} .img.org" " ${airootfs_dir} .img"
946927
947- if [[ " ${noiso} " = true ]]; then
948- msg_info " The password for the live user and root is ${password} ."
949- fi
928+ [[ " ${noiso} " = true ]] && msg_info " The password for the live user and root is ${password} ."
950929
951930 return 0
952931}
@@ -1038,7 +1017,7 @@ make_iso() {
10381017 -eltorito-boot syslinux/isolinux.bin \
10391018 -eltorito-catalog syslinux/boot.cat \
10401019 -no-emul-boot -boot-load-size 4 -boot-info-table \
1041- -isohybrid-mbr ${build_dir} /iso/syslinux/isohdpfx.bin \
1020+ -isohybrid-mbr " ${build_dir} /iso/syslinux/isohdpfx.bin" \
10421021 " ${_iso_efi_boot_args[@]} " \
10431022 -output " ${out_dir} /${iso_filename} " \
10441023 " ${build_dir} /iso/"
@@ -1052,10 +1031,9 @@ make_iso() {
10521031
10531032
10541033# Parse options
1055- ARGUMENT=(" ${@ } " ${DEFAULT_ARGUMENT} )
10561034OPTS=(" a:" " b" " c:" " d" " e" " g:" " h" " j" " k:" " l:" " o:" " p:" " r" " t:" " u:" " w:" " x" )
10571035OPTL=(" arch:" " boot-splash" " comp-type:" " debug" " cleaning" " cleanup" " gpgkey:" " help" " lang:" " japanese" " kernel:" " out:" " password:" " comp-opts:" " user:" " work:" " bash-debug" " nocolor" " noconfirm" " nodepend" " gitversion" " msgdebug" " noloopmod" " tarball" " noiso" " noaur" " nochkver" " channellist" " config:" " noefi" " nodebug" " nosigcheck" " normwork" " log" " logpath:" " nolog" " nopkgbuild" " pacman-debug" " confirm" )
1058- if ! OPT=$( getopt -o " $( printf " %s," " ${OPTS[@]} " ) " -l " $( printf " %s," " ${OPTL[@]} " ) " -- " ${ARGUMENT [@]} " ) ; then
1036+ if ! OPT=$( getopt -o " $( printf " %s," " ${OPTS[@]} " ) " -l " $( printf " %s," " ${OPTL[@]} " ) " -- " ${@ } " " ${DEFAULT_ARGUMENT [@]}" ) ; then
10591037 exit 1
10601038fi
10611039
@@ -1262,7 +1240,7 @@ msg_debug "Use the default configuration file (${defaultconfig})."
12621240
12631241# Check for a valid channel name
12641242if [[ -n " ${1+SET} " ]]; then
1265- case " $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -n check " ${1} " ; printf " ${?} " ) " in
1243+ case " $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " -n check " ${1} " ; printf " %d " " ${?} " ) " in
12661244 " 2" )
12671245 msg_error " Invalid channel ${1} " " 1"
12681246 ;;
@@ -1280,7 +1258,6 @@ else
12801258fi
12811259
12821260# Set vars
1283- work_dir=" $( realpath " ${work_dir} " ) "
12841261build_dir=" ${work_dir} /build/${arch} "
12851262cache_dir=" ${work_dir} /cache/${arch} "
12861263airootfs_dir=" ${build_dir} /airootfs"
@@ -1292,6 +1269,7 @@ gitrev="$(cd "${script_path}"; git rev-parse --short HEAD)"
12921269for _dir in " ${build_dir} " " ${cache_dir} " " ${airootfs_dir} " " ${isofs_dir} " " ${lockfile_dir} " ; do
12931270 mkdir -p " ${_dir} "
12941271done
1272+ ork_dir=" $( realpath " ${work_dir} " ) "
12951273
12961274# Set for special channels
12971275if [[ -d " ${channel_dir} .add" ]]; then
0 commit comments