changeset 1483:54db423b7fef

If CPUS isn't set, calculate it. KVM or chroot can have >1.
author Rob Landley <rob@landley.net>
date Sun, 01 Jan 2012 13:51:04 -0600
parents b381adcd7968
children 62dd9695d825
files sources/root-filesystem/sbin/init.sh
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sources/root-filesystem/sbin/init.sh	Sun Jan 01 05:04:32 2012 -0600
+++ b/sources/root-filesystem/sbin/init.sh	Sun Jan 01 13:51:04 2012 -0600
@@ -9,7 +9,12 @@
 mkdir -p dev/pts
 mountpoint -q dev/pts || mount -t devpts dev/pts dev/pts
 
-[ -z "$CPUS" ] && export CPUS=1
+# If nobody said how many CPUS to use in builds, try to figure it out.
+if [ -z "$CPUS" ]
+then
+  export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
+  [ "$CPUS" -lt 1 ] && CPUS=1
+fi
 export PS1='($HOST:$CPUS) \w \$ '
 
 # Make sure $PATH is exported, even if not set on kernel command line.