Skip to content

Commit 414b765

Browse files
committed
[update] : Optimize wasteful processing
1 parent 71bb401 commit 414b765

File tree

1 file changed

+27
-49
lines changed

1 file changed

+27
-49
lines changed

build.sh

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -144,30 +144,22 @@ _usage () {
144144
echo " Default: ${work_dir}"
145145
echo
146146

147-
local blank="33" _arch _list _dirname
148-
149-
echo " Language for each architecture:"
150-
for _list in ${script_path}/system/locale-* ; do
151-
_arch="${_list#${script_path}/system/locale-}"
152-
echo -n " ${_arch}"
153-
echo_blank "$(( ${blank} - 4 - ${#_arch} ))"
154-
"${tools_dir}/locale.sh" -a "${_arch}" show
155-
done
156-
157-
echo
158-
echo " Kernel for each architecture:"
159-
for _list in ${script_path}/system/kernel-* ; do
160-
_arch="${_list#${script_path}/system/kernel-}"
161-
echo -n " ${_arch} "
162-
echo_blank "$(( ${blank} - 5 - ${#_arch} ))"
163-
"${tools_dir}/kernel.sh" -a "${_arch}" show
147+
local blank="33" _arch _list _dirname _type
148+
149+
for _type in "locale" "kernel"; do
150+
echo " ${_type} for each architecture:"
151+
for _list in ${script_path}/system/${_type}-* ; do
152+
_arch="${_list#${script_path}/system/${_type}-}"
153+
echo -n " ${_arch}$(echo_blank "$(( "${blank}" - 4 - "${#_arch}" ))")"
154+
"${tools_dir}/${_type}.sh" -a "${_arch}" show
155+
done
156+
echo
164157
done
165158

166-
echo
167159
echo " Channel:"
168160
for _dirname in $(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -d -b -n show); do
169161
echo -ne " ${_dirname%.add}"
170-
echo_blank "$(( ${blank} - 3 - $(echo ${_dirname%.add} | wc -m) ))"
162+
echo_blank "$(( "${blank}" - 3 - "$(echo "${_dirname%.add}" | wc -m)" ))"
171163
"${tools_dir}/channel.sh" --version "${alteriso_version}" --nocheck desc "${_dirname%.add}"
172164
done
173165

@@ -315,7 +307,6 @@ _cleanup_common () {
315307

316308
_cleanup_airootfs(){
317309
_cleanup_common
318-
319310
# Delete all files in /boot
320311
[[ -d "${airootfs_dir}/boot" ]] && find "${airootfs_dir}/boot" -mindepth 1 -delete
321312
}
@@ -416,15 +407,10 @@ show_settings() {
416407
msg_info "Live username is ${username}."
417408
msg_info "Live user password is ${password}."
418409
msg_info "The compression method of squashfs is ${sfs_comp}."
419-
if [[ $(echo "${channel_name}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
420-
msg_info "Use the $(echo ${channel_name} | sed 's/\.[^\.]*$//') channel."
421-
else
422-
msg_info "Use the ${channel_name} channel."
423-
fi
410+
msg_info "Use the ${channel_name%.add} channel."
424411
msg_info "Build with architecture ${arch}."
425-
if [[ ${noconfirm} = false ]]; then
426-
echo
427-
echo "Press Enter to continue or Ctrl + C to cancel."
412+
if [[ "${noconfirm}" = false ]]; then
413+
echo -e "\nPress Enter to continue or Ctrl + C to cancel."
428414
read
429415
fi
430416
trap 1 2 3 15
@@ -438,15 +424,7 @@ prepare_build() {
438424
if [[ -d "${script_path}/.git" ]]; then
439425
cd "${script_path}"
440426
msg_debug "The version of alteriso is $(git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')."
441-
cd - > /dev/null 2>&1
442-
fi
443-
444-
# Pacman configuration file used only when building
445-
# If there is pacman.conf for each channel, use that for building
446-
if [[ -f "${channel_dir}/pacman-${arch}.conf" ]]; then
447-
build_pacman_conf="${channel_dir}/pacman-${arch}.conf"
448-
else
449-
build_pacman_conf="${script_path}/system/pacman-${arch}.conf"
427+
cd "${OLDPWD}" > /dev/null 2>&1
450428
fi
451429

452430
# Set dirs
@@ -483,8 +461,8 @@ prepare_build() {
483461
msg_error "Module ${1} is not available." "1";
484462
fi
485463
}
486-
for_module "module_check {}"
487464
modules=($(printf "%s\n" "${modules[@]}" | sort | uniq))
465+
for_module "module_check {}"
488466
for_module load_config "${module_dir}/{}/config.any" "${module_dir}/{}/config.${arch}"
489467
msg_debug "Loaded modules: ${modules[*]}"
490468
if ! printf "%s\n" "${modules[@]}" | grep -x "share" >/dev/null 2>&1; then
@@ -514,7 +492,7 @@ prepare_build() {
514492
if [[ "${gitversion}" = true ]]; then
515493
cd "${script_path}"
516494
iso_version=${iso_version}-$(git rev-parse --short HEAD)
517-
cd - > /dev/null 2>&1
495+
cd "${OLDPWD}"
518496
fi
519497

520498
# Generate iso file name.
@@ -544,6 +522,15 @@ prepare_build() {
544522
# Setup custom pacman.conf with current cache directories.
545523
make_pacman_conf() {
546524
msg_debug "Use ${build_pacman_conf}"
525+
526+
# Pacman configuration file used only when building
527+
# If there is pacman.conf for each channel, use that for building
528+
if [[ -f "${channel_dir}/pacman-${arch}.conf" ]]; then
529+
build_pacman_conf="${channel_dir}/pacman-${arch}.conf"
530+
else
531+
build_pacman_conf="${script_path}/system/pacman-${arch}.conf"
532+
fi
533+
547534
if [[ "${nosigcheck}" = true ]]; then
548535
sed -r "s|^#?\\s*SigLevel.+|SigLevel = Never|g" ${build_pacman_conf} > "${work_dir}/pacman-${arch}.conf"
549536
else
@@ -562,8 +549,6 @@ make_basefs() {
562549
msg_info "Mounting ${airootfs_dir}.img on ${airootfs_dir}"
563550
mount_airootfs
564551
msg_info "Done!"
565-
566-
#_pacman "base" "syslinux"
567552
}
568553

569554
# Additional packages (airootfs)
@@ -628,7 +613,6 @@ make_pkgbuild() {
628613
done
629614

630615
#-- ビルドスクリプトの実行 --#
631-
# prepare for makepkg
632616
cp -rf --preserve=mode "${script_path}/system/pkgbuild.sh" "${airootfs_dir}/root/pkgbuild.sh"
633617
cp -rf --preserve=mode "/usr/bin/yay" "${airootfs_dir}/usr/local/bin/yay"
634618
sed "s|https|http|g" "${work_dir}/pacman-${arch}.conf" > "${airootfs_dir}/etc/alteriso-pacman.conf"
@@ -680,14 +664,12 @@ make_customize_airootfs() {
680664
# -r is obsolete due to the removal of rebuild.
681665
# -k changed in AlterISO3 from passing kernel name to passing kernel configuration.
682666

683-
684667
# Generate options of customize_airootfs.sh.
685668
_airootfs_script_options="-p '${password}' -k '${kernel} ${kernel_filename} ${kernel_mkinitcpio_profile}' -u '${username}' -o '${os_name}' -i '${install_dir}' -s '${usershell}' -a '${arch}' -g '${locale_gen_name}' -l '${locale_name}' -z '${locale_time}' -t ${theme_name}"
686669
[[ "${boot_splash}" = true ]] && _airootfs_script_options="${_airootfs_script_options} -b"
687670
[[ "${debug}" = true ]] && _airootfs_script_options="${_airootfs_script_options} -d"
688671
[[ "${bash_debug}" = true ]] && _airootfs_script_options="${_airootfs_script_options} -x"
689672

690-
691673
_main_script="root/customize_airootfs.sh"
692674

693675
_script_list=(
@@ -842,7 +824,6 @@ make_syslinux() {
842824
# Prepare /isolinux
843825
make_isolinux() {
844826
mkdir -p "${isofs_dir}/isolinux"
845-
846827
sed "s|%INSTALL_DIR%|${install_dir}|g" \
847828
"${script_path}/system/isolinux.cfg" > "${isofs_dir}/isolinux/isolinux.cfg"
848829
cp "${airootfs_dir}/usr/lib/syslinux/bios/isolinux.bin" "${isofs_dir}/isolinux/"
@@ -1072,10 +1053,7 @@ make_iso() {
10721053

10731054
# If exists, add an EFI "El Torito" boot image (FAT filesystem) to ISO-9660 image.
10741055
if [[ -f "${work_dir}/iso/EFI/alteriso/efiboot.img" ]]; then
1075-
_iso_efi_boot_args="-eltorito-alt-boot
1076-
-e EFI/alteriso/efiboot.img
1077-
-no-emul-boot
1078-
-isohybrid-gpt-basdat"
1056+
_iso_efi_boot_args="-eltorito-alt-boot -e EFI/alteriso/efiboot.img -no-emul-boot -isohybrid-gpt-basdat"
10791057
fi
10801058

10811059
mkdir -p -- "${out_dir}"

0 commit comments

Comments
 (0)