Add NFS_ROOT kernel option, so that we can mount a root file system over NFS.
When using mktemp, make sure the path of the file is in /tmp

This allows us to run the installer when the root file system is read-only.
Exclude debug kernel from installer ISO.
Create some directories in the STAGEDIR used to create base.ufs.uzip
and in the ISODIR used to create the install ISO image.
By creating these directories in the installer, we can have a read-only
root file system, eliminating the need to have a MFS root during the install.

diff --git a/build/create_iso.sh b/build/create_iso.sh
index dd17633..d614c97 100644
--- a/build/create_iso.sh
+++ b/build/create_iso.sh
@@ -49,7 +49,14 @@ main()

 	cd "$AVATAR_ROOT"

-	mkdir -p ${STAGEDIR}/dev ${ISODIR}/data
+	mkdir -p ${STAGEDIR}/dev
+	mkdir -p ${STAGEDIR}/.mount
+
+	mkdir -p ${ISODIR}/data
+	mkdir -p ${ISODIR}/dev
+	mkdir -p ${ISODIR}/.mount
+	mkdir -p ${ISODIR}/mnt
+	mkdir -p ${ISODIR}/tmp

 	# Create a quick and dirty nano image from the world tree
 	mkdir -p ${INSTALLUFSDIR}

commit 552cc42847831a8c5516cfb6824af5da39ffc008
Author: Craig Rodrigues <rodrigc@ixsystems.com>
Date:   Thu Jul 11 14:11:53 2013 -0700

    Exclude debug kernel from installer ISO.

diff --git a/build/create_iso.sh b/build/create_iso.sh
index 2c15f9e..dd17633 100644
--- a/build/create_iso.sh
+++ b/build/create_iso.sh
@@ -57,7 +57,8 @@ main()

 	# copy /rescue and /boot from the image to the iso
 	tar -cf - -C ${INSTALLUFSDIR} rescue | tar -xf - -C ${STAGEDIR}
-	tar -cf - -C ${INSTALLUFSDIR} boot | tar -xf - -C ${ISODIR}
+	tar -cf - -C ${INSTALLUFSDIR} rescue | tar -xf - -C ${ISODIR}
+	tar -cf - -C ${INSTALLUFSDIR} boot --exclude boot/kernel-debug | tar -xf - -C ${ISODIR}
 	ln -f $IMGFILE $ISODIR/$NANO_LABEL-$NANO_ARCH_HUMANIZED.img.xz

 	echo "#/dev/md0 / ufs ro 0 0" > ${INSTALLUFSDIR}/etc/fstab

commit bb731d0c5778cd6f75e907c3ca0c61dc30900281
Author: Craig Rodrigues <rodrigc@ixsystems.com>
Date:   Thu Jul 11 14:09:21 2013 -0700

    When using mktemp, make sure the path of the file is in /tmp.
    This allows us to run the installer when the root file system is read-only.

diff --git a/nanobsd/Installer/bin/install_worker.sh b/nanobsd/Installer/bin/install_worker.sh
index 13e6430..62c3559 100755
--- a/nanobsd/Installer/bin/install_worker.sh
+++ b/nanobsd/Installer/bin/install_worker.sh
@@ -97,7 +97,7 @@ then
 	error "Could not load the avatar.conf file from the destination directory ($INSTALL_DESTDIR/etc)"
 fi

-if ! stage_log=$(mktemp install_worker.XXXXXX)
+if ! stage_log=$(mktemp /tmp/install_worker.XXXXXX)
 then
 	exit 1
 fi
diff --git a/nanobsd/Installer/lib/functions.sh b/nanobsd/Installer/lib/functions.sh
index 737c3f0..ea868d3 100644
--- a/nanobsd/Installer/lib/functions.sh
+++ b/nanobsd/Installer/lib/functions.sh
@@ -190,7 +190,7 @@ source_conf()
 		return 1
 	fi

-	if ! tmpconf=$(mktemp conf.XXXXXX)
+	if ! tmpconf=$(mktemp /tmp/conf.XXXXXX)
 	then
 		return 1
 	fi

commit f2872191699625a1e7373fe3d185ab7fb181b5c3
Author: Craig Rodrigues <rodrigc@ixsystems.com>
Date:   Thu Jul 11 14:07:18 2013 -0700

    Add NFS_ROOT kernel option, so that we can mount a root file system over NFS.

diff --git a/nanobsd/TRUENAS.amd64 b/nanobsd/TRUENAS.amd64
index 1204c6e..be02032 100644
--- a/nanobsd/TRUENAS.amd64
+++ b/nanobsd/TRUENAS.amd64
@@ -38,6 +38,7 @@ options 	MD_ROOT			# MD is a potential root device
 options 	NFSCL			# New Network Filesystem Client
 options 	NFSD			# New Network Filesystem Server
 options 	NFSLOCKD		# Network Lock Manager
+options 	NFS_ROOT		# NFS usable as /, requires NFSCL
 options 	MSDOSFS			# MSDOS Filesystem
 options 	CD9660			# ISO 9660 Filesystem
 options 	PROCFS			# Process filesystem (requires PSEUDOFS)
Remove memroot_ufs from the install CD, and instead use /.mount.conf to tell the kernel to re-mount /data/base.ufs.uzip as the root file system.
(1)  In loader.conf, add:
     boot_cdrom="YES"

     In src/sys/boot/i386/libi386/bootinfo.c
     this sets the RB_CDROM boot flag.  Then in
     src/sys/kern/vfs_mountroot.c in vfs_mountroot_conf0(),
     this will cause the mountroot logic to try to boot off of CD-ROM.

(2)  In the /etc/rc script used by the installer,
     just before we invoke install.sh, invoke /etc/rc.initdiskless.
     rc.initdiskless will create memory backed file systems
     based on the contents of directories under /conf.
     We create memory backed file systems for /etc , /var, and /tmp.
     This allows us to boot from a read-only file system,
     such as a ISO CD-ROM, or a GEOM uzip file,
     but have certain writable directories.

     This also facilitates booting off of an NFS root.

(cherry picked from commit f922a4a2468e49b5e2ff738afee20558e849d8bc)
create_iso.sh used to generate certain files and copy them into the ISO.
To make the code easier to read, pull these files out
of the create_iso.sh script and place them in boot/files.
create_iso.sh will copy these files into the ISO_DIR staging
directory during the build.

This makes the code a little easier to read.

(cherry picked from commit dac7e274bfb48ea1dd7841ff9688d6dbb510b899)
Clean up creaet_iso.sh by removing sections where we
were generating shell scripts and config files.  Instead, copy the
required shell scripts and config files from $AVATAR_ROOT/build/files
into the stage directories.

(cherry picked from commit 103654921f7beb39439d23fb06ca9cf75deb84c7)
Fix name of loader.conf.cdrom

(cherry picked from commit 80f07d24bf39b123293c1b8a2a226ac5fdcaa66d)
Fix path to loader.conf.cdrom

(cherry picked from commit 077a961df3ee90a9a832022f10d62ec65d6331e2)
Fix cherry-pick.
We cannot use the installworld version of /etc/fstab
on the installer ISO.
Remove one file which is not needed in install ISO, and causes
errors on boot due to try to mount partitions which do not exist.
In the install script, check for these kernel environment variables:
  test.nfs_mount
  test.script
  test.run_tests_on_boot

If they exist, this will allow you to either run
tests as soon as the system comes up, or
add a menu option in the install menu to run tests.
Use -t flag to mktemp to properly select /tmp as the directory
to place temporary files.
Redirect stderr of "kenv test.*" to /dev/null.
If those variables aren't set, we don't want to see error
messages about them not being set.