diff --git a/pkg_auto/impl/inside_sdk_container_lib.sh b/pkg_auto/impl/inside_sdk_container_lib.sh index ec7480dd74..3f1bdd2007 100644 --- a/pkg_auto/impl/inside_sdk_container_lib.sh +++ b/pkg_auto/impl/inside_sdk_container_lib.sh @@ -434,20 +434,6 @@ function clean_empty_warning_files() { done } -function get_num_proc() { - local -n num_proc_ref=${1}; shift - local -i num_proc=1 rv=1 - - # stolen from portage - [[ rv -eq 0 ]] || { rv=0; num_proc=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || rv=1; } - [[ rv -eq 0 ]] || { rv=0; num_proc=$(sysctl -n hw.ncpu 2>/dev/null) || rv=1; } - # stolen from common.sh - [[ rv -eq 0 ]] || { rv=0; num_proc=$(grep -c "^processor" /proc/cpuinfo 2>/dev/null) || rv=1; } - [[ rv -eq 0 ]] || { rv=0; num_proc=1; } - - num_proc_ref=${num_proc} -} - function generate_cache_for() { local repo=${1}; shift diff --git a/pkg_auto/impl/util.sh b/pkg_auto/impl/util.sh index 267b550d11..2f1b0d4d32 100644 --- a/pkg_auto/impl/util.sh +++ b/pkg_auto/impl/util.sh @@ -333,4 +333,20 @@ function struct_declare() { declare "${args[@]}" "${@}" } +function get_num_proc() { + local -n num_proc_ref=${1}; shift + local -i num_proc=1 rv=1 + + # stolen from portage + [[ rv -eq 0 ]] || { rv=0; num_proc=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || rv=1; } + [[ rv -eq 0 ]] || { rv=0; num_proc=$(sysctl -n hw.ncpu 2>/dev/null) || rv=1; } + # stolen from my head + [[ rv -eq 0 ]] || { rv=0; num_proc=$(nproc) || rv=1; } + # stolen from common.sh + [[ rv -eq 0 ]] || { rv=0; num_proc=$(grep -c "^processor" /proc/cpuinfo 2>/dev/null) || rv=1; } + [[ rv -eq 0 ]] || { rv=0; num_proc=1; } + + num_proc_ref=${num_proc} +} + fi