diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-07-13 01:03:35 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2019-07-14 13:58:07 +0200 |
commit | 8d49b5d4bc42af5dcd5a6ed3c08d781154eb3cc0 (patch) | |
tree | 5f366a8d642d78a9144f20b545924646b588f504 | |
parent | gen_funcs.sh: Refactor print_info() (diff) | |
download | genkernel-8d49b5d4bc42af5dcd5a6ed3c08d781154eb3cc0.tar.gz genkernel-8d49b5d4bc42af5dcd5a6ed3c08d781154eb3cc0.tar.bz2 genkernel-8d49b5d4bc42af5dcd5a6ed3c08d781154eb3cc0.zip |
gen_funcs.sh: Refactor getIndent()
- Renamed to get_indent().
- Make use of get_useful_function_stack().
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rwxr-xr-x | gen_funcs.sh | 15 | ||||
-rwxr-xr-x | genkernel | 12 |
2 files changed, 17 insertions, 10 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh index 4f992587..b1337d9e 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -252,16 +252,23 @@ gen_die() { exit 1 } -getIndent() { - [[ "$#" -lt '1' ]] && - gen_die 'getIndent(): improper usage!' +# @FUNCTION: get_indent +# @USAGE: <level> +# @DESCRIPTION: +# Returns the indent level in spaces. +# +# <level> Indentation level. +get_indent() { + [[ ${#} -ne 1 ]] \ + && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!" local _level=${1} local _indent= local _indentTemplate=" " local i=0 - while [[ ${i} -lt ${_level} ]]; do + while [[ ${i} -lt ${_level} ]] + do _indent+=${_indentTemplate} i=$[$i+1] done @@ -192,7 +192,7 @@ else fi else print_warning 1 "${BOLD}WARNING${NORMAL}: No mounted ${BOOTDIR} partition detected!" - print_warning 1 "$(getIndent 1)Run ``mount ${BOOTDIR}`` to mount it!" + print_warning 1 "$(get_indent 1)Run ``mount ${BOOTDIR}`` to mount it!" echo fi fi @@ -222,7 +222,7 @@ then then compile_generic prepare kernel else - print_info 2 "$(getIndent 1)>> Skipping 'make prepare' due to ARCH_HAVENOPREPARE=yes!" + print_info 2 "$(get_indent 1)>> Skipping 'make prepare' due to ARCH_HAVENOPREPARE=yes!" fi # KV may have changed due to the configuration @@ -230,10 +230,10 @@ then if [ -f "${TEMP}/.old_kv" ] then old_KV=$(cat "${TEMP}/.old_kv") - print_info 1 "$(getIndent 1)>> Kernel version has changed (probably due to config change) since genkernel start:" - print_info 1 "$(getIndent 1)>> We are now building Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL} ..." + print_info 1 "$(get_indent 1)>> Kernel version has changed (probably due to config change) since genkernel start:" + print_info 1 "$(get_indent 1)>> We are now building Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL} ..." else - print_info 2 "$(getIndent 1)>> Kernel version has not changed since genkernel start." + print_info 2 "$(get_indent 1)>> Kernel version has not changed since genkernel start." fi compile_kernel @@ -246,7 +246,7 @@ then if isTrue "${SAVE_CONFIG}" then - print_info 1 "Copying config for successful build to /etc/kernels/kernel-config-${ARCH}-${KV}" + print_info 1 "$(get_indent 1)>> Saving config of successful build to '/etc/kernels/kernel-config-${ARCH}-${KV}' ..." [ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \ print_warning 1 "Unable to copy the kernel configuration file; Ignoring non-fatal error ..." |