Annotation of wikisrc/tutorials/how_to_build_netbsd-current.mdwn, revision 1.2

1.2     ! schmonz     1: Thanks to the Autobuild-System, you can easily build a new Release from the NetBSD CVS sources. I'll show you, how to build a release, sets and a bootable installation CD-ROM for i386, step by step. For this, you need a running NetBSD System and a working Internet Connection.
        !             2: #Contents
        !             3: 
        !             4: [[!toc]]
        !             5: 
        !             6: #Disk space requirements
        !             7: 
        !             8: You will need a minimum of 5.1 GB of disk space to build a whole release. You need currently 1.2 GB for the sources src and 579 MB for xsrc. About 2.4 GB will reside in the obj directory after building a release.
        !             9: #Short way for impatient
        !            10: <pre><code>
        !            11: # fetch source:
        !            12: cd /usr; cvs -z3 -d anoncvs@anoncvs.se.netbsd.org:/cvsroot co -P src
        !            13: # everything goes into this directory
        !            14: mkdir /usr/obj
        !            15: # build tools (to build everything else), custom kernel, binary sets
        !            16: cd /usr/src; ./build.sh -O /usr/obj -U -j 8 tools kernel=H4KK1T modules distribution sets
        !            17: # install kernel:
        !            18: cd /usr/obj/sys/compile/arch/*/compile/H4KK1T; su root -c 'make install'
        !            19: # test kernel:
        !            20: su root -c 'shutdown -r now'
        !            21: # update userland:
        !            22: cd /usr/src; ./build.sh -O /usr/obj install=/
        !            23: # follow printed instructions about "postinstall"
        !            24: 
        !            25: # build CD image (omit "tools" if built already):
        !            26: cd /usr/src; ./build.sh -O /usr/obj -U -j 8 tools release iso-image
        !            27: </code></pre>
        !            28: 
        !            29: #Obtaining the sources via CVS
        !            30: 
        !            31: Create the directories src, xsrc and objdir as root in /usr
        !            32: 
        !            33:     # cd /usr
        !            34:     # mkdir src xsrc objdir 
        !            35: 
        !            36: We also create the following directories in /usr: tooldir, releasedir, destdir. We do this, because we want the src directory to stay clean and not polluted by the build process. We will pass options flags to build.sh, to separate the directories.
        !            37: 
        !            38:     # mkdir tooldir releasedir destdir
        !            39: 
        !            40: Change the owner of the directories:
        !            41: 
        !            42:     # chown john src/ xsrc/ objdir/ tooldir/ releasedir/ destdir/
        !            43: 
        !            44: The following steps from now on can be done as a non-root user:
        !            45: 
        !            46:     # logout
        !            47:     $
        !            48: 
        !            49: Set the environment variable CVSROOT: (For that, please choose a [Mirror](http://www.de.netbsd.org/mirrors/#anoncvs) close to you)
        !            50: 
        !            51: csh users:
        !            52: 
        !            53:     % setenv CVSROOT anoncvs@anoncvs.se.NetBSD.org:/cvsroot
        !            54: 
        !            55: Bourne compatible shell (sh, ksh, zsh, bash...) Users:
        !            56: 
        !            57:     $ export CVSROOT=anoncvs@anoncvs.se.NetBSD.org:/cvsroot
        !            58: 
        !            59: Set the environment variable CVS_RSH:
        !            60: 
        !            61:     $ export CVS_RSH=ssh
        !            62: 
        !            63: The src directory currently needs about 1500 MB disk space and the xsrc directory currently needs about 579 MB of disk space.
        !            64: Now check out the current sources, like this:
        !            65: 
        !            66:     $ cvs checkout -PA src
        !            67: 
        !            68: If you want to use Xorg from pkgsrc you can skip the next step.
        !            69: 
        !            70:     $ cvs checkout -PA xsrc
        !            71: 
        !            72: Or you can check out a certain release, by passing -r
        !            73: 
        !            74:     $ cvs checkout -rnetbsd-5-0 -PA src
        !            75:     $ cvs checkout -rnetbsd-5-0 -PA xsrc
        !            76: 
        !            77: #Building the toolchain
        !            78: 
        !            79: The toolchain contains the software that is needed to build NetBSD, like the GNU C-Compiler and other tools. This way, it is ensured that NetBSD can build itself on almost any Unix™. You can omit this step, if you want to build a new release, because a release always includes building the tools.
        !            80: <pre><code>
        !            81: $ cd /usr/src
        !            82: $ ./build.sh -T ../tooldir -D ../destdir -R ../releasedir -O ../objdir -U -j2 tools 
        !            83: 
        !            84:         build.sh started: Sat Jan 22 21:34:56 CET 2005
        !            85:         No /usr/tools/bin/nbmake, needs building.
        !            86:         Bootstrapping nbmake
        !            87:         MACHINE:          i386
        !            88:         MACHINE_ARCH:     i386
        !            89:         TOOLDIR path:     /usr/tooldir
        !            90:         DESTDIR path:     /usr/destdir
        !            91:         RELEASEDIR path:  /usr/releasedir
        !            92:         Created /usr/tools/bin/nbmake
        !            93:         makewrapper:      /usr/tools/bin/nbmake-i386
        !            94:         Updated /usr/src/obj/tooldir/bin/nbmake-i386
        !            95:         Tools built to /usr/src/obj/tooldir
        !            96:         build.sh started: Sat Jan 22 21:34:56 CET 2005
        !            97:         build.sh ended:   Sat Jan 22 21:41:26 CET 2005
        !            98: </code></pre>
        !            99: #Building the release
        !           100: 
        !           101: Variables to pass to build.sh can be found in [src/share/mk/bsd.README](http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/src/share/mk/bsd.README?rev=1.165.2.3;content-type=text%2Fx-cvsweb-markup).
        !           102: 
        !           103: In this example
        !           104: We are building as a user (non-root): -U
        !           105: We are building the X11R6 sources (Xservers, this is XFree 4.5.0 not Xorg): -x
        !           106: We are using separate directories: -T, -D, -R, -O, -X
        !           107: We are removing contents of tooldir and destdir before building: -r
        !           108: We are using -j2 because we have a multiprocessor system
        !           109: 
        !           110: We are building a release: release
        !           111: 
        !           112:     $ ./build.sh -T ../tooldir -D ../destdir -R ../releasedir -O ../objdir -X ../xsrc -U -x -j2 -r release 
        !           113: 
        !           114: This process takes at least two hours on an high-end server, and usually much longer, depending on your computing power.
        !           115: <pre><code>
        !           116:         build.sh started: Sat Jan 22 21:50:47 CET 2005
        !           117:         No nonexistent/bin/nbmake, needs building.
        !           118:         Bootstrapping nbmake
        !           119:         MACHINE:          i386
        !           120:         MACHINE_ARCH:     i386
        !           121:         TOOLDIR path:     /usr/src/tooldir
        !           122:         DESTDIR path:     /usr/src/destdir
        !           123:         RELEASEDIR path:  /usr/src/releasedir
        !           124:         Created /usr/src/tooldir/bin/nbmake
        !           125:         makewrapper:      /usr/src/tooldir/bin/nbmake-i386
        !           126:         Updated /usr/src/tooldir/bin/nbmake-i386
        !           127:         Successful make release
        !           128:         build.sh started: Sat Jan 22 21:50:47 CET 2005
        !           129:         build.sh ended:   Sun Jan 23 01:20:43 CET 2005
        !           130: </code></pre>
        !           131: If you are using Xorg via pkgsrc (recommended), you can skip building the Xserver (-x).
        !           132: 
        !           133: If you have a multiprocessor system, add -j. The number of jobs should be equal to your number of CPU's/cores. Don't use -j on single CPU systems.
        !           134: 
        !           135: If your build fails, because of insufficient space on install flopies, you might find this useful: [[How to build install sets, when you can't build install floppies]]
        !           136: #Creating an ISO-Image
        !           137: 
        !           138: to create an iso-image just add the option iso-image
        !           139: 
        !           140:     $ ./build.sh <other options> -U -x -r release iso-image
        !           141: 
        !           142: the resulting iso image will reside in relasedir/platform/installation/cdrom/
        !           143: 
        !           144: This option will create an iso-image only on platforms that are bootable from such a media.
        !           145: #Burning the image
        !           146: 
        !           147: If you have a CD/DVD-Writer, you can burn the iso image to a CD. For this task you need to install cdrecord, which is part of sysutils/cdrtools.
        !           148: 
        !           149:     # cdrecord -dev=/dev/rcd0d -data -pad -v NetBSD-install.iso
        !           150: 
        !           151: #Building current faster
        !           152: 
        !           153: In case you don't need whole a release or a bootable iso image, the fastest way to build current is to build new tools, distribution, followed by sets and a kernel (custom or GENERIC). I recommend to build a custom kernel that fits your needs.
        !           154: 
        !           155: $ ./build.sh <your options> -U tools distribution sets kernel=MYKERNEL
        !           156: 
        !           157: Additional Information
        !           158: 
        !           159: * [cvs(1)](http://netbsd.gw.com/cgi-bin/man-cgi?cvs+1+NetBSD-current) manpage
        !           160: * [Tracking NetBSD-current](http://www.netbsd.org/docs/current/)

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb