This function can be more useful because the NPROC value can
be provided regardless of how many cores nproc actually detects
and may be handy in a restricted environment like a container.
The new version quotes some values and uses $((...)) as per shellcheck
warning that "expr is antiquated".
Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit
a76a0cfdc63b8f7daefefeb1af542db56310a2da)
echo "CI_DEBUG: $*"
fi
}
+
+# get_processors returns 1/2 the value of the value returned by
+# the nproc program OR the value of the environment variable NPROC
+# allowing the user to tune the number of cores visible to the
+# build scripts.
+function get_processors() {
+ # get_processors() depends on coreutils nproc.
+ if [ -n "$NPROC" ]; then
+ echo "$NPROC"
+ else
+ if [ "$(nproc)" -ge 2 ]; then
+ echo "$(($(nproc) / 2))"
+ else
+ echo 1
+ fi
+ fi
+}
restore_ccache_conf
}
-function get_processors() {
- # get_processors() depends on coreutils nproc.
- if test -n "$NPROC" ; then
- echo $NPROC
- else
- if test $(nproc) -ge 2 ; then
- expr $(nproc) / 2
- else
- echo 1
- fi
- fi
-}
-
function detect_ceph_dev_pkgs() {
local cmake_opts="-DWITH_FMT_VERSION=9.0.0"
local boost_root=/opt/ceph