From af9c2144b85999f9307ce9c0599d864c1eafc9a6 Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Mon, 27 Jul 2020 05:23:42 -0700 Subject: [PATCH] Fix `./bin/package host cpu` on FreeBSD (#99) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This bugfix is from Marcin Cieślak's fork of the INIT build system. Before this bugfix, running 'bin/package host cpu' on FreeBSD would always report one CPU core, even if the CPU is multi-core: $ ./bin/package host cpu 1 bin/package, src/cmd/INIT/package.sh: - Correctly report the number of CPUs on FreeBSD by using 'sysctl -n hw.ncpu'. --- bin/package | 7 +++++++ src/cmd/INIT/package.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/bin/package b/bin/package index d014c576f..81e68411a 100755 --- a/bin/package +++ b/bin/package @@ -1673,6 +1673,13 @@ hostinfo() # attribute ... continue ;; esac + cpu=`sysctl -n hw.ncpu` + case $cpu in + [123456789]*) + _hostinfo_="$_hostinfo_ $cpu" + continue + ;; + esac cpu=`grep -ic '^processor[ ][ ]*:[ ]*[0123456789]' /proc/cpuinfo` case $cpu in [123456789]*) diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 0c353db67..4fa4cd866 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -1672,6 +1672,13 @@ hostinfo() # attribute ... continue ;; esac + cpu=`sysctl -n hw.ncpu` + case $cpu in + [123456789]*) + _hostinfo_="$_hostinfo_ $cpu" + continue + ;; + esac cpu=`grep -ic '^processor[ ][ ]*:[ ]*[0123456789]' /proc/cpuinfo` case $cpu in [123456789]*)