How to fast build the ISO image for a customized kernel

I have modified the kernel in order to fix a bug (related to storage driver for hyper-v), and I have to verify it through a fresh installation. I modified the release/generate-release.sh to build my local copy of FreeBSD 10.2. But it takes quite long time and failed at installworld:
Code:
install: hcsecd.conf and /home/honzhan/10.2/10.2.0/etc/bluetooth/hcsecd.conf are the same file.
The following is my modications. I did 3 modifications:
  1. The script accepts only 1 argument: the customized src folder instead of svn repository.
  2. Remove ${CHROOTDIR}/usr/src to ${CHROOTDIR}
  3. Use parallel build make -j8
If I don't want to include src and doc, is there a quick method to build ISO image? Can I avoid make installworld? I don't think I need to installworld for build ISO image.

Code:
--- generate-release.sh 2015-12-28 14:52:08.071568000 +0800
+++ my-generate-release.sh      2016-01-12 19:12:46.745939000 +0800
@@ -46,11 +46,11 @@

usage()
{
-       echo "Usage: $0 svn-branch[@revision] scratch-dir" 2>&1
+       echo "Usage: $0 scratch-dir" 2>&1
        exit 1
}

-if [ $# -lt 2 ]; then
+if [ $# -lt 1 ]; then
        usage
fi

@@ -60,12 +60,12 @@ fi
: ${SVNROOTPORTS:=${SVNROOTBASE}/ports}
: ${SVNROOT:=${SVNROOTSRC}} # for backward compatibility
: ${SVN_CMD:=/usr/local/bin/svn}
-BRANCHSRC=$1
+#BRANCHSRC=$1
: ${BRANCHDOC:=head}
: ${BRANCHPORTS:=head}
: ${WORLD_FLAGS:=${MAKE_FLAGS}}
: ${KERNEL_FLAGS:=${MAKE_FLAGS}}
-: ${CHROOTDIR:=$2}
+: ${CHROOTDIR:=$1}

if [ ! -r "${CHROOTDIR}" ]; then
        echo "${CHROOTDIR}: scratch dir not found."
@@ -83,10 +83,10 @@ case ${TARGET_ARCH} in
esac
SETENV="env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin"
CROSSENV="${SETENV_TARGET} ${SETENV_TARGET_ARCH}"
-WMAKE="make -C /usr/src ${WORLD_FLAGS}"
+WMAKE="make -j8 -C /usr/src ${WORLD_FLAGS}"
NWMAKE="${WMAKE} __MAKE_CONF=/dev/null SRCCONF=/dev/null"
-KMAKE="make -C /usr/src ${KERNEL_FLAGS}"
-RMAKE="make -C /usr/src/release"
+KMAKE="make -j8 -C /usr/src ${KERNEL_FLAGS}"
+RMAKE="make -j8 -C /usr/src/release"

if [ $(id -u) -ne 0 ]; then
        echo "Needs to be run as root."
@@ -95,13 +95,13 @@ fi

set -e # Everything must succeed

-mkdir -p ${CHROOTDIR}/usr/src
-${SVN_CMD} co ${SVNROOT}/${BRANCHSRC} ${CHROOTDIR}/usr/src
-${SVN_CMD} co ${SVNROOTDOC}/${BRANCHDOC} ${CHROOTDIR}/usr/doc
-${SVN_CMD} co ${SVNROOTPORTS}/${BRANCHPORTS} ${CHROOTDIR}/usr/ports
+#mkdir -p ${CHROOTDIR}/usr/src
+#${SVN_CMD} co ${SVNROOT}/${BRANCHSRC} ${CHROOTDIR}/usr/src
+#${SVN_CMD} co ${SVNROOTDOC}/${BRANCHDOC} ${CHROOTDIR}/usr/doc
+#${SVN_CMD} co ${SVNROOTPORTS}/${BRANCHPORTS} ${CHROOTDIR}/usr/ports

-${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src ${WORLD_FLAGS} buildworld
-${SETENV} ${NWMAKE} -C ${CHROOTDIR}/usr/src installworld distribution DESTDIR=${CHROOTDIR}
+${SETENV} ${NWMAKE} -C ${CHROOTDIR} ${WORLD_FLAGS} buildworld
+${SETENV} ${NWMAKE} -C ${CHROOTDIR} installworld distribution DESTDIR=${CHROOTDIR}
mount -t devfs devfs ${CHROOTDIR}/dev
trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
 
Last edited by a moderator:
Just build the release by hand.

Code:
cd /usr/src
make buildworld buildkernel
cd /usr/src/release
make -DNOPORTS -DNODOC -DNOSRC -DNOPKG release
make -DNOPORTS -DNODOC -DNOSRC -DNOPKG DESTDIR=/storage/releases/myrelease install
If you want to use the resulting FTP install directory for poudriere you'll need to remove the NOSRC, poudriere requires the sources.
 
Thanks all. I finally rebuild ISO with another method, which is similar as Chris posted.

The whole release build take very long time (>3 hours) in my virtual machine and finally gives me an error. I cannot tolerate time spend on the long build and error troubleshooting.

My modification is in only one file, so I don't think it deserve that heavy build. Finally, I decided to patch my modification into FreeBSD 10.2 ISO.

First, I build the new kernel, kernel.txz, and generate the new MANIFEST. Then I mount the ISO to /mnt/ folder. Replace /mnt/boot/kernel/kernel, /mnt/usr/freebsd-dist/kernel.txz, and /mnt/usr/freebsd-dist/MANIFEST. After that, I run /usr/src/release/amd64/mkisoimages.sh to make the new ISO image. And that image is what I want.
 
Back
Top