Hi,
while playing with Nick Bender's auto-install stuff, I hit a problem:
In src/distrib/i386/common/install.md, I see this code:
------------
NCPU=$(sysctl -n hw.ncpufound)
((NCPU > 1)) && { DEFAULTSETS="bsd bsd.rd bsd.mp" ; SANESETS="bsd bsd.mp" ; }
------------
Executing this during install, or from a shell reached after booting
bsd.rd, yields:
/install.auto: //install.md[6]: NCPU: not found
I've copied the two lines above into an isolated shell script and ran
that shell script, with exactly the same result. Then I carried this
two-liner over to a machine which was already running full multi-user,
and now, the script worked just fine. But the code can't be broken,
otherwise installs would not work properly, so I guess I'm doing
something wrong.
If I use the following code instead, no problem occurs:
[ NCPU -gt 1 ] && ...
I read the man page for the shell several times, but didn't figure out
where this behaviour is described:
(( expression )) -- I only found $(( expression ))
PARAMETER -- I only found $PARAMETER
What gives?
Since I'm in a hurry to fix this problem, I also took a closer look and
fixed the problem for me. The value of NCPU is only used to decide
whether to install the MP kernel as /bsd. Since there is nowhere any
logic to decide whether there is enough disk space to hold all three
kernel files, this can be simplified while saving a few bytes at the
same time:
--- /tmp/install.md 2009-06-11 19:05:06.000000000 +0200
+++ install.md 2010-04-27 23:46:58.000000000 +0200
@@ -34,13 +34,13 @@
MDXAPERTURE=2
MDXDM=y
-NCPU=$(sysctl -n hw.ncpufound)
-((NCPU > 1)) && { DEFAULTSETS="bsd bsd.rd bsd.mp" ; SANESETS="bsd bsd.mp" ; }
+DEFAULTSETS="bsd bsd.rd bsd.mp"
+SANESETS="bsd bsd.mp"
md_installboot() {
cd /mnt
- if [[ -f bsd.mp ]] && ((NCPU > 1)); then
+ if [[ -f bsd.mp ]] && [$(sysctl -n hw.ncpufound) -gt 1 ]; then
echo "Multiprocessor machine; using bsd.mp instead of bsd."
mv bsd bsd.sp 2>/dev/null
mv bsd.mp bsd
Enjoy,
--Toni++