commit 53f2da6f0b864a3759d9acf760c321079e45dd86 from: Thomas Adam date: Wed Sep 07 14:31:15 2022 UTC portable: maintscript: wrap nproc Wrap nproc for non-Linux systems so this script can run on, say, FreeBSD. commit - 769c6a981d7734fe920f59790dcca00819f03356 commit + 53f2da6f0b864a3759d9acf760c321079e45dd86 blob - 150fc8a96782fde711c03b2c9a75707d7e06e3aa blob + 7819af6212cd5e10cb08b10fc7af82ebb38a8374 --- maintscripts/sync-upstream.sh +++ maintscripts/sync-upstream.sh @@ -10,6 +10,23 @@ die() exit 1 } +# Wrap the nproc command found on Linux, to return the number of CPU cores. +# On non-Linux systems, the same value can be found via sysctl. For +# everything else, just return "1". +nproc() +{ + NPROCCMD="nproc" + + command -v "$NPROCCMD" >/dev/null 2>&1 || { + NPROCCMD="sysctl -n hw.ncpu" + } + + result="$(eval command $NPROCCMD)" + [ -z "$result" -o "$result" -le 0 ] && result="1" + + echo "$result" +} + [ -z "$(git status --porcelain)" ] || die "Working tree is not clean" echo "Updating main from origin..."