OSDN Git Service

[clean] : Reduced the number of lines of code
authorhayao <shun819.mail@gmail.com>
Thu, 23 Jul 2020 02:41:31 +0000 (11:41 +0900)
committerhayao <shun819.mail@gmail.com>
Thu, 23 Jul 2020 02:41:31 +0000 (11:41 +0900)
build.sh

index d9cab04..a11204e 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -11,8 +11,7 @@
 # The main script that runs the build
 #
 
-set -e
-set -u
+set -eu
 
 # Internal config
 # Do not change these values.
@@ -21,7 +20,6 @@ defaultconfig="${script_path}/default.conf"
 rebuild=false
 customized_username=false
 
-
 # Load config file
 if [[ -f "${defaultconfig}" ]]; then
     source "${defaultconfig}"
@@ -30,10 +28,8 @@ else
     exit 1
 fi
 
-
 umask 0022
 
-
 # Color echo
 # usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
 #
@@ -67,16 +63,8 @@ umask 0022
 # 8 => Concealed on
 
 echo_color() {
-    local backcolor
-    local textcolor
-    local decotypes
-    local echo_opts
-    local arg
-    local OPTIND
-    local OPT
-    
+    local backcolor textcolor decotypes echo_opts arg OPTIND OPT
     echo_opts="-e"
-    
     while getopts 'b:t:d:n' arg; do
         case "${arg}" in
             b) backcolor="${OPTARG}" ;;
@@ -85,9 +73,7 @@ echo_color() {
             n) echo_opts="-n -e"     ;;
         esac
     done
-    
     shift $((OPTIND - 1))
-    
     if [[ "${nocolor}" = false ]]; then
         echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
     else
@@ -104,10 +90,7 @@ _msg_info() {
     else
         set -xv
     fi
-    local echo_opts="-e"
-    local arg
-    local OPTIND
-    local OPT
+    local echo_opts="-e" arg OPTIND OPT
     while getopts 'n' arg; do
         case "${arg}" in
             n) echo_opts="${echo_opts} -n" ;;
@@ -131,10 +114,7 @@ _msg_warn() {
     else
         set -xv
     fi
-    local echo_opts="-e"
-    local arg
-    local OPTIND
-    local OPT
+    local echo_opts="-e" arg OPTIND OPT
     while getopts 'n' arg; do
         case "${arg}" in
             n) echo_opts="${echo_opts} -n" ;;
@@ -158,10 +138,7 @@ _msg_debug() {
     else
         set -xv
     fi
-    local echo_opts="-e"
-    local arg
-    local OPTIND
-    local OPT
+    local echo_opts="-e" arg OPTIND OPT
     while getopts 'n' arg; do
         case "${arg}" in
             n) echo_opts="${echo_opts} -n" ;;
@@ -188,11 +165,7 @@ _msg_error() {
     else
         set -xv
     fi
-    local echo_opts="-e"
-    local arg
-    local OPTIND
-    local OPT
-    local OPTARG
+    local echo_opts="-e" arg OPTIND OPT
     while getopts 'n' arg; do
         case "${arg}" in
             n) echo_opts="${echo_opts} -n" ;;
@@ -242,12 +215,7 @@ _usage () {
     echo "                                  Default: ${work_dir}"
     echo
 
-    local blank="33"
-    local arch
-    local lang
-    local list
-    local locale_name_list
-    local kernel
+    local blank="33" arch lang list locale_name_list kernel
 
     echo " Language for each architecture:"
     for list in ${script_path}/system/locale-* ; do
@@ -327,7 +295,6 @@ _usage () {
     echo "         --nodepend              No check package dependencies before building."
     echo "         --noiso                 No build iso image. (Use with --tarball)"
     echo "         --shmkalteriso          Use the shell script version of mkalteriso."
-    
     if [[ -n "${1:-}" ]]; then
         exit "${1}"
     fi
@@ -355,16 +322,13 @@ run_once() {
     fi
 }
 
-
 # rm helper
 # Delete the file if it exists.
 # For directories, rm -rf is used.
 # If the file does not exist, skip it.
 # remove <file> <file> ...
 remove() {
-    local _list
-    local _file
-    _list=($(echo "$@"))
+    local _list=($(echo "$@")) _file
     for _file in "${_list[@]}"; do
         if [[ -f ${_file} ]]; then
             _msg_debug "Removeing ${_file}"
@@ -376,6 +340,12 @@ remove() {
     done
 }
 
+# Debug line
+debug_line() {
+    if [[ "${debug}" = true ]]; then
+        echo
+    fi
+}
 
 # 強制終了時にアンマウント
 umount_trap() {
@@ -448,7 +418,6 @@ prepare_build() {
     out_dir="$(realpath -e "${out_dir}")"
     work_dir="$(realpath -e "${work_dir}")"
 
-
     # Check work dir
     if [[ -n $(ls -a "${work_dir}" 2> /dev/null | grep -xv ".." | grep -xv ".") ]] && [[ ! "${rebuild}" = true ]]&& [[ ! "${rebuild}" = true ]]; then
         umount_chroot
@@ -456,7 +425,6 @@ prepare_build() {
         remove "${work_dir%/}"/*
     fi
     
-    
     # 強制終了時に作業ディレクトリを削除する
     local trap_remove_work
     trap_remove_work() {
@@ -477,12 +445,10 @@ prepare_build() {
         load_config "${script_path}/channels/share/config.any"
         load_config ${script_path}/channels/share/config.${arch}
         
-        
         # If there is config for each channel. load that.
         load_config "${script_path}/channels/${channel_name}/config.any"
         load_config "${script_path}/channels/${channel_name}/config.${arch}"
         
-        
         # Set username
         if [[ "${customized_username}" = false ]]; then
             username="${defaultusername}"
@@ -519,8 +485,7 @@ prepare_build() {
 
         local save_var
         save_var() {
-            local out_file="${rebuildfile}"
-            local i
+            local out_file="${rebuildfile}" i
             for i in ${@}; do
                 echo -n "${i}=" >> "${out_file}"
                 echo -n '"' >> "${out_file}"
@@ -611,7 +576,6 @@ prepare_build() {
         if [[ "${channel_name}" = "rebuild" ]]; then
             # Delete the lock file.
             remove "$(ls ${work_dir}/* | grep "build.make")"
-
             # reset work
             remove_work
         fi
@@ -638,7 +602,6 @@ prepare_build() {
         mkalteriso="${script_path}/system/mkalteriso.sh"
     fi
 
-
     # Show alteriso version
     if [[ -d "${script_path}/.git" ]]; then
         cd  "${script_path}"
@@ -646,7 +609,6 @@ prepare_build() {
         cd - > /dev/null 2>&1
     fi
 
-
     # Unmount
     local mount
     for mount in $(mount | awk '{print $3}' | grep $(realpath ${work_dir})); do
@@ -654,21 +616,13 @@ prepare_build() {
         umount "${mount}"
     done
     
-    
     # Check packages
     if [[ "${nodepend}" = false ]] && [[ "${arch}" = $(uname -m) ]] ; then
-        local installed_pkg
-        local installed_ver
-        local check_pkg
-        local check_failed=false
-        local pkg
-        
-        installed_pkg=($(pacman -Q | awk '{print $1}'))
-        installed_ver=($(pacman -Q | awk '{print $2}'))
-        
+        local check_pkg check_failed=false pkg
+        local installed_pkg=($(pacman -Q | awk '{print $1}')) installed_ver=($(pacman -Q | awk '{print $2}'))
+
         check_pkg() {
-            local i
-            local ver
+            local i ver
             for i in $(seq 0 $(( ${#installed_pkg[@]} - 1 ))); do
                 if [[ "${installed_pkg[${i}]}" = ${1} ]]; then
                     ver=$(pacman -Sp --print-format '%v' --config ${build_pacman_conf} ${1} 2> /dev/null)
@@ -754,9 +708,6 @@ show_settings() {
     if [[ ${noconfirm} = false ]]; then
         echo "Press Enter to continue or Ctrl + C to cancel."
         read
-    else
-        :
-        #sleep 3
     fi
     trap 1 2 3 15
     trap 'umount_trap' 1 2 3 15
@@ -774,7 +725,6 @@ make_pacman_conf() {
 # Base installation, plus needed packages (airootfs)
 make_basefs() {
     ${mkalteriso} ${mkalteriso_option} -w "${work_dir}/${arch}" -C "${work_dir}/pacman-${arch}.conf" -D "${install_dir}" init
-    # ${mkalteriso} ${mkalteriso_option} -w "${work_dir}/${arch}" -C "${work_dir}/pacman-${arch}.conf" -D "${install_dir}" -p "haveged intel-ucode amd-ucode memtest86+ mkinitcpio-nfs-utils nbd zsh efitools" install
     ${mkalteriso} ${mkalteriso_option} -w "${work_dir}/${arch}" -C "${work_dir}/pacman-${arch}.conf" -D "${install_dir}" -p "bash haveged intel-ucode amd-ucode mkinitcpio-nfs-utils nbd efitools" install
     
     # Install plymouth.
@@ -800,12 +750,7 @@ make_basefs() {
 make_packages() {
     # インストールするパッケージのリストを読み込み、配列pkglistに代入します。
     set +e
-    local _loadfilelist
-    local _pkg
-    local _file
-    local excludefile
-    local excludelist
-    local _pkglist
+    local _loadfilelist _pkg _file excludefile excludelist _pkglist
     
     #-- Detect package list to load --#
     # Add the files for each channel to the list of files to read.
@@ -825,10 +770,7 @@ make_packages() {
             pkglist=( ${pkglist[@]} "$(grep -h -v ^'#' ${_file})" )
         fi
     done
-    if [[ ${debug} = true ]]; then
-        sleep 1
-    fi
-    
+
     #-- Read exclude list --#
     # Exclude packages from the share exclusion list
     excludefile=(
@@ -857,7 +799,6 @@ make_packages() {
         _msg_debug "Excluded packages:" "${excludelist[@]}"
     fi
 
-
     # Sort the list of packages in abc order.
     pkglist=(
         "$(
@@ -869,8 +810,6 @@ make_packages() {
     )
     set -e
     
-    # _msg_debug "${pkglist[@]}"
-    
     # Create a list of packages to be finally installed as packages.list directly under the working directory.
     echo "# The list of packages that is installed in live cd." > "${work_dir}/packages.list"
     echo "#" >> "${work_dir}/packages.list"
@@ -882,15 +821,13 @@ make_packages() {
     # Install packages on airootfs
     ${mkalteriso} ${mkalteriso_option} -w "${work_dir}/${arch}" -C "${work_dir}/pacman-${arch}.conf" -D "${install_dir}" -p "${pkglist[@]}" install
 }
+
+
 make_packages_aur() {
     # インストールするパッケージのリストを読み込み、配列pkglistに代入します。
     set +e
-    local _loadfilelist
-    local _pkg
-    local _file
-    local excludefile
-    local excludelist
-    local _pkglist
+
+    local _loadfilelist _pkg _file excludefile excludelist _pkglist
     
     #-- Detect package list to load --#
     # Add the files for each channel to the list of files to read.
@@ -901,7 +838,6 @@ make_packages_aur() {
         "${script_path}"/channels/share/packages_aur.${arch}/lang/${language}.${arch}
     )
 
-
     #-- Read package list --#
     # Read the file and remove comments starting with # and add it to the list of packages to install.
     for _file in ${_loadfilelist[@]}; do
@@ -910,9 +846,6 @@ make_packages_aur() {
             pkglist_aur=( ${pkglist_aur[@]} "$(grep -h -v ^'#' ${_file})" )
         fi
     done
-    if [[ ${debug} = true ]]; then
-        sleep 1
-    fi
     
     #-- Read exclude list --#
     # Exclude packages from the share exclusion list
@@ -942,7 +875,6 @@ make_packages_aur() {
         _msg_debug "Excluded packages:" "${excludelist[@]}"
     fi
 
-
     # Sort the list of packages in abc order.
     pkglist_aur=(
         "$(
@@ -1016,15 +948,12 @@ make_customize_airootfs() {
     local copy_airootfs
     
     copy_airootfs() {
-        local i
-        for i in "${@}"; do
-            local _dir="${i%/}"
-            if [[ -d "${_dir}" ]]; then
-                cp -af "${_dir}"/* "${work_dir}/${arch}/airootfs"
-            fi
-        done
+        local _dir="${1%/}"
+        if [[ -d "${_dir}" ]]; then
+            cp -af "${_dir}"/* "${work_dir}/${arch}/airootfs"
+        fi
     }
-    
+
     copy_airootfs "${script_path}/channels/share/airootfs.any"
     copy_airootfs "${script_path}/channels/share/airootfs.${arch}"
     copy_airootfs "${script_path}/channels/${channel_name}/airootfs.any"
@@ -1034,11 +963,7 @@ make_customize_airootfs() {
     if [[ "${boot_splash}" = true ]]; then
         cp "${script_path}/mkinitcpio/mkinitcpio-plymouth.conf" "${work_dir}/${arch}/airootfs/etc/mkinitcpio.conf"
     fi
-    
-    # Code to use common pacman.conf in archiso.
-    # cp "${script_path}/pacman.conf" "${work_dir}/${arch}/airootfs/etc"
-    # cp "${build_pacman_conf}" "${work_dir}/${arch}/airootfs/etc"
-    
+
     # Get the optimal mirror list.
     case "${arch}" in
         "x86_64") arch_domain="https://www.archlinux.org/mirrorlist/" ;;
@@ -1068,91 +993,59 @@ make_customize_airootfs() {
     
     
     # Generate options of customize_airootfs.sh.
-    local addition_options
-    local share_options
-    addition_options=
+    local customize_airootfs_script_options
+    customize_airootfs_script_options="-p '${password}' -k '${kernel_config_line}' -u '${username}' -o '${os_name}' -i '${install_dir}' -s '${usershell}' -a '${arch}' -g '${localegen}' -l '${language}' -z '${timezone}' -t ${theme_name}"
     if [[ ${boot_splash} = true ]]; then
-        if [[ -z ${theme_name} ]]; then
-            addition_options="${addition_options} -b"
-        else
-            addition_options="${addition_options} -b -t ${theme_name}"
-        fi
+        customize_airootfs_script_options="${customize_airootfs_script_options} -b"
     fi
     if [[ ${debug} = true ]]; then
-        addition_options="${addition_options} -d"
+        customize_airootfs_script_options="${customize_airootfs_script_options} -d"
     fi
     if [[ ${bash_debug} = true ]]; then
-        addition_options="${addition_options} -x"
+        customize_airootfs_script_options="${customize_airootfs_script_options} -x"
     fi
     if [[ ${rebuild} = true ]]; then
-        addition_options="${addition_options} -r"
+        customize_airootfs_script_options="${customize_airootfs_script_options} -r"
     fi
-    
-    share_options="-p '${password}' -k '${kernel_config_line}' -u '${username}' -o '${os_name}' -i '${install_dir}' -s '${usershell}' -a '${arch}' -g '${localegen}' -l '${language}' -z '${timezone}'"
-    
-    
+
     # X permission
-    if [[ -f ${work_dir}/${arch}/airootfs/root/customize_airootfs.sh ]]; then
-        chmod 755 "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh"
-    fi
-    if [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh" ]]; then
-        chmod 755 "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh"
-    fi
-    if [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh" ]]; then
-        chmod 755 "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh"
-        elif [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh" ]]; then
-        chmod 755 "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh"
-    fi
+    local chmod_755
+    chmod_755() {
+        _file="${1}"
+        if [[ -f "$_file" ]]; then
+            chmod 755 "${_file}"
+        fi
+    }
+    
+    chmod_755 "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh"
+    chmod_755 "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh"
+    chmod_755 "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh"
+    chmod_755 "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh"
     
     # Execute customize_airootfs.sh.
-    if [[ -z ${addition_options} ]]; then
+    ${mkalteriso} ${mkalteriso_option} \
+    -w "${work_dir}/${arch}" \
+    -C "${work_dir}/pacman-${arch}.conf" \
+    -D "${install_dir}" \
+    -r "/root/customize_airootfs.sh ${customize_airootfs_script_options}" \
+    run
+
+    if [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh" ]]; then
         ${mkalteriso} ${mkalteriso_option} \
         -w "${work_dir}/${arch}" \
         -C "${work_dir}/pacman-${arch}.conf" \
         -D "${install_dir}" \
-        -r "/root/customize_airootfs.sh ${share_options}" \
+        -r "/root/customize_airootfs_${channel_name}.sh ${customize_airootfs_script_options}" \
         run
-        if [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh" ]]; then
-            ${mkalteriso} ${mkalteriso_option} \
-            -w "${work_dir}/${arch}" \
-            -C "${work_dir}/pacman-${arch}.conf" \
-            -D "${install_dir}" \
-            -r "/root/customize_airootfs_${channel_name}.sh ${share_options}" \
-            run
-            elif [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh" ]]; then
-            ${mkalteriso} ${mkalteriso_option} \
-            -w "${work_dir}/${arch}" \
-            -C "${work_dir}/pacman-${arch}.conf" \
-            -D "${install_dir}" \
-            -r "/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh ${share_options}" \
-            run
-        fi
-    else
+    elif [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh" ]]; then
         ${mkalteriso} ${mkalteriso_option} \
         -w "${work_dir}/${arch}" \
         -C "${work_dir}/pacman-${arch}.conf" \
         -D "${install_dir}" \
-        -r "/root/customize_airootfs.sh ${share_options} ${addition_options}" \
+        -r "/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh ${customize_airootfs_script_options}" \
         run
-        
-        if [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh" ]]; then
-            ${mkalteriso} ${mkalteriso_option} \
-            -w "${work_dir}/${arch}" \
-            -C "${work_dir}/pacman-${arch}.conf" \
-            -D "${install_dir}" \
-            -r "/root/customize_airootfs_${channel_name}.sh ${share_options} ${addition_options}" \
-            run
-            elif [[ -f "${work_dir}/${arch}/airootfs/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh" ]]; then
-            ${mkalteriso} ${mkalteriso_option} \
-            -w "${work_dir}/${arch}" \
-            -C "${work_dir}/pacman-${arch}.conf" \
-            -D "${install_dir}" \
-            -r "/root/customize_airootfs_$(echo ${channel_name} | sed 's/\.[^\.]*$//').sh ${share_options} ${addition_options}" \
-            run
-        fi
     fi
     
-    
     # Delete customize_airootfs.sh.
     remove "${work_dir}/${arch}/airootfs/root/customize_airootfs.sh"
     remove "${work_dir}/${arch}/airootfs/root/customize_airootfs_${channel_name}.sh"
@@ -1197,9 +1090,6 @@ make_boot() {
 
 # Add other aditional/extra files to ${install_dir}/boot/
 make_boot_extra() {
-    # In AlterLinux, memtest has been removed.
-    # cp "${work_dir}/${arch}/airootfs/boot/memtest86+/memtest.bin" "${work_dir}/iso/${install_dir}/boot/memtest"
-    # cp "${work_dir}/${arch}/airootfs/usr/share/licenses/common/GPL2/license.txt" "${work_dir}/iso/${install_dir}/boot/memtest.COPYING"
     cp "${work_dir}/${arch}/airootfs/boot/intel-ucode.img" "${work_dir}/iso/${install_dir}/boot/intel_ucode.img"
     cp "${work_dir}/${arch}/airootfs/usr/share/licenses/intel-ucode/LICENSE" "${work_dir}/iso/${install_dir}/boot/intel_ucode.LICENSE"
     cp "${work_dir}/${arch}/airootfs/boot/amd-ucode.img" "${work_dir}/iso/${install_dir}/boot/amd_ucode.img"
@@ -1220,9 +1110,7 @@ make_syslinux() {
     done
     
     # Replace the SYSLINUX configuration file with or without boot splash.
-    local _use_config_name
-    local _no_use_config_name
-    local _pxe_or_sys
+    local _use_config_name _no_use_config_name _pxe_or_sys
     if [[ "${boot_splash}" = true ]]; then
         _use_config_name=splash
         _no_use_config_name=nosplash
@@ -1317,7 +1205,6 @@ make_efiboot() {
     cp "${script_path}/efiboot/loader/entries/uefi-shell-x86_64.conf" "${work_dir}/efiboot/loader/entries/"
     cp "${script_path}/efiboot/loader/entries/uefi-shell-full-x86_64.conf" "${work_dir}/efiboot/loader/entries/"
     
-    
     sed "s|%ARCHISO_LABEL%|${iso_label}|g;
          s|%OS_NAME%|${os_name}|g;
          s|%KERNEL_FILENAME%|${kernel_filename}|g;
@@ -1380,86 +1267,85 @@ unset OPT
 unset _opt_short
 unset _opt_long
 
-
 while :; do
     case ${1} in
         -a | --arch)
             arch="${2}"
             shift 2
-        ;;
+            ;;
         -b | --boot-splash)
             boot_splash=true
             shift 1
-        ;;
+            ;;
         -c | --comp-type)
             case "${2}" in
                 "gzip" | "lzma" | "lzo" | "lz4" | "xz" | "zstd") sfs_comp="${2}" ;;
                 *) _msg_error "Invaild compressors '${2}'" '1' ;;
             esac
             shift 2
-        ;;
+            ;;
         -d | --debug)
             debug=true
             shift 1
-        ;;
+            ;;
         -g | --lang)
             language="${2}"
             shift 2
-        ;;
+            ;;
         -h | --help)
             _usage
             exit 0
-        ;;
+            ;;
         -j | --japanese)
             _msg_error "This option is obsolete in AlterISO 3."
             _msg_error "To use Japanese, use \"-g ja\"." '1'
-        ;;
+            ;;
         -k | --kernel)
             kernel="${2}"
             shift 2
-        ;;
+            ;;
         -l | --cleaning)
             cleaning=true
             shift 1
-        ;;
+            ;;
         -o | --out)
             out_dir="${2}"
             shift 2
-        ;;
+            ;;
         -p | --password)
             password="${2}"
             shift 2
-        ;;
+            ;;
         -t | --comp-opts)
             sfs_comp_opt="${2}"
             shift 2
-        ;;
+            ;;
         -u | --user)
             customized_username=true
             username="$(echo -n "${2}" | sed 's/ //g' |tr '[A-Z]' '[a-z]')"
             shift 2
-        ;;
+            ;;
         -w | --work)
             work_dir="${2}"
             shift 2
-        ;;
+            ;;
         -x | --bash-debug)
             debug=true
             bash_debug=true
             shift 1
-        ;;
+            ;;
         --noconfirm)
             noconfirm=true
             shift 1
-        ;;
+            ;;
         --nodepend)
             nodepend=true
             shift 1
-        ;;
+            ;;
         --nocolor)
             nocolor=true
             shift 1
-        ;;
+            ;;
         --gitversion)
             if [[ -d "${script_path}/.git" ]]; then
                 gitversion=true
@@ -1467,15 +1353,15 @@ while :; do
                 _msg_error "There is no git directory. You need to use git clone to use this feature." "1"
             fi
             shift 1
-        ;;
+            ;;
         --shmkalteriso)
             shmkalteriso=true
             shift 1
-        ;;
+         ;;
         --msgdebug)
             msgdebug=true;
             shift 1
-        ;;
+            ;;
         --noloopmod)
             noloopmod=true
             shift 1
@@ -1503,11 +1389,11 @@ while :; do
         --)
             shift
             break
-        ;;
+            ;;
         *)
             _msg_error "Invalid argument '${1}'"
             _usage 1
-        ;;
+            ;;
     esac
 done
 
@@ -1525,7 +1411,6 @@ fi
 # Show config message
 [[ -f "${defaultconfig}" ]] && _msg_debug "The settings have been overwritten by the ${defaultconfig}"
 
-
 # Debug mode
 mkalteriso_option="-a ${arch} -v"
 if [[ "${bash_debug}" = true ]]; then
@@ -1534,14 +1419,12 @@ if [[ "${bash_debug}" = true ]]; then
     mkalteriso_option="${mkalteriso_option} -x"
 fi
 
-
 # Pacman configuration file used only when building
 build_pacman_conf=${script_path}/system/pacman-${arch}.conf
 
 # Set rebuild config file
 rebuildfile="${work_dir}/build_options"
 
-
 # Parse channels
 set +eu
 if [[ -n "${1}" ]]; then
@@ -1550,8 +1433,7 @@ fi
 
 # check_channel <channel name>
 check_channel() {
-    local channel_list
-    local i
+    local channel_list i
     channel_list=()
     for i in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9 }'); do
         if [[ -n $(ls "${script_path}"/channels/${i}) ]] && [[ ! ${i} = "share" ]]; then
@@ -1631,9 +1513,7 @@ fi
 locale_config_file="${script_path}/system/locale-${arch}"
 locale_name_list=($(cat "${locale_config_file}" | grep -h -v ^'#' | awk '{print $1}'))
 get_locale_line() {
-    local _lang
-    local count
-    count=0
+    local _lang count=0
     for _lang in ${locale_name_list[@]}; do
         count=$(( count + 1 ))
         if [[ "${_lang}" == "${language}" ]]; then
@@ -1682,14 +1562,11 @@ if [[ "${kernel_line}" == "failed" ]]; then
 fi
 
 kernel_config_line="$(cat "${kernel_config_file}" | grep -h -v ^'#' | grep -v ^$ | head -n "${kernel_line}" | tail -n 1)"
-
 kernel_package=$(echo ${kernel_config_line} | awk '{print $2}')
 kernel_headers_packages=$(echo ${kernel_config_line} | awk '{print $3}')
 kernel_filename=$(echo ${kernel_config_line} | awk '{print $4}')
 kernel_mkinitcpio_profile=$(echo ${kernel_config_line} | awk '{print $5}')
 
-kernel_config_line="${kernel} ${kernel_package} ${kernel_headers_packages} ${kernel_filename} ${kernel_mkinitcpio_profile}"
-
 
 # Check the value of a variable that can only be set to true or false.
 check_bool() {
@@ -1706,9 +1583,8 @@ check_bool() {
     fi
 }
 
-if [[ "${debug}" =  true ]]; then
-    echo
-fi
+debug_line
+
 check_bool boot_splash
 check_bool debug
 check_bool bash_debug
@@ -1726,9 +1602,7 @@ check_bool tarball
 check_bool noiso
 check_bool noaur
 
-if [[ "${debug}" =  true ]]; then
-    echo
-fi
+debug_line
 
 set -eu