Back to <ahref="../installation.html">Installing Haiku</a>
</p>
</div>
<divclass="content">
<p>The following will show you step by step how to get Haiku's source code and build tools, how to compile it all and how to generate either a VMWare image or directly install onto a partition or USB drive. You'll also learn how to exchange data with an image or an installation on it's partition.</p>
<p><b>Note:</b><i>This guide is based on Ubuntu 8.10, but should generally work the same way on all other Linux distributions. Some changes may apply.</i></p>
<h1>Downloading the tools and the Haiku source</h1>
<p>To build with GCC 4.x the configure line changes to:</p>
<preclass="terminal">./configure --build-cross-tools-gcc4 x86 ../buildtools/</pre>
<p>But keep in mind this will produce binaries which are not compatible with BeOS.</p></li>
</ol>
<p><br/></p>
<p>To download all code changes from now on, simply enter the <tt>haiku/trunk/</tt> folder and type:</p>
<preclass="terminal">svn update</pre>
<h1>Customizing UserBuildConfig</h1>
<p>Now you could already start to build RAW or VMWare images. Before we come to that, however, let's have a look at the <tt>UserBuildConfig</tt> that can be used to customize and automate some things.</p>
<p>In <tt>trunk/haiku/build/jam/</tt> there's a <tt>UserBuildConfig.ReadMe</tt> that explains various options. <b>Don't</b> simply rename it and use it as <tt>UserBuildConfig</tt>!</p>
<p>You start by duplicating the <tt>UserBuildConfig.sample</tt> and the remove the<tt>.sample</tt> suffix to get your <tt>UserBuildConfig</tt>. From the <tt>.ReadMe</tt> you can copy interesting parts into your config and customize them there.</p>
<ol>
<li><p>First, the line needed for the optional "OpenSSH" package:</p>
<pre>HAIKU_IMAGE_HOST_NAME = "TEST" ;</pre>
</li>
<li><p>Now the block that sets the defaults for timezone and keymap:</p>
<pre># Add symlink/file (timezone and keymap settings) to the image.
AddFilesToHaikuImage home config settings : German
: Key_map ;</pre></li>
<li><p>The build process can be fine tuned until it fits your needs. You could create your own folder <tt>haiku/trunk/user_data/</tt>
and put files there that are then copied or unzipped into the image.
Zipping is important when dealing with Haiku files with their
attributes, because zipping them up will preserve them on non-BFS
partitions.<br/>
For example:</p>
<pre># Zip up your emails between each system update and place the archive into the
# user_data folder to be automatically put back when building the new image.
UnzipArchiveToHaikuImage home
: $(HAIKU_TOP)/user_data/mail.zip ;</pre>
<p>The first line defines the location in the image where the archive will be unzipped (here: <tt>/boot/home/</tt>). Deeper hierarchies are separated with a blank instead of the usual "<tt>/</tt>" (see the setting of the timezone above).<br/>
The second line is the location of the zip file. <tt>$(HAIKU_TOP)</tt> is the lowest level of the checked out source tree, normally <tt>haiku/trunk/</tt>.</p>
<p>In the same way, you use <tt>CopyDirectoryToHaikuImage</tt> and <tt>AddFilesToHaikuImage</tt> to copy whole directories or single files into the image.</p></li>
<li><p>The above commands are executed when building any kind of image.
"Build Profiles" provide the means to set commands specifically for
different configurations.<br/>
These are two profiles, one for building and installing an image
directly onto a partition and the other to generate a VMWare image:</p>
<pre>DefineBuildProfile disk : disk : "/dev/sda7" ;
DefineBuildProfile vmware : vmware-image ;
switch $(HAIKU_BUILD_PROFILE) {
case "disk" : {
HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ;
}
case "vmware" : {
HAIKU_IMAGE_SIZE = 900 ;
HAIKU_DONT_CLEAR_IMAGE = 1 ;
HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1
}
}</pre>
<p>The first line is especially important and <b>dangerous</b>: "<tt>/dev/sda7</tt>"<br/>
<spanstyle="font-size: 1.2em; font-weight: bold;">The so defined partition will be irretrievably overwritten!
</span></p>
<p>Before you use this profile, you should make sure that it's really
the correct partition on the right harddisk or USB-stick, for example
by using Ubuntu's partition editor <i>GParted</i>.</p></li>
</ol>
<p><br/></p>
<p>Here's the complete <tt>UserBuildConfig</tt> once more:</p>
<pre># Quick start file for UserBuildConfig. Copy it and uncomment and edit the
# lines you want. See UserBuildConfig.ReadMe for details.
# Optional package OpenSSH needs this variable set
HAIKU_IMAGE_HOST_NAME = "TEST" ;
# Add symlink/file (timezone and keymap settings) to the image.
AddFilesToHaikuImage home config settings : German
: Key_map ;
DefineBuildProfile disk : disk : "/dev/sda7" ;
DefineBuildProfile vmware : vmware-image ;
switch $(HAIKU_BUILD_PROFILE) {
case "disk" : {
HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ;
}
case "vmware" : {
HAIKU_IMAGE_SIZE = 900 ;
HAIKU_DONT_CLEAR_IMAGE = 1 ;
HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ;
}
}</pre>
<pstyle="text-indent: 15pt"><b>Note:</b><i>when building an a USB memory stick, you wouldn't specify the partition number in the disk entry (ex. </i><tt>/dev/sdb</tt><i> instead of </i><tt>/dev/sdb1</tt><i>). This will erase your whole flash drive and it's partitions, so be cautious the drive name is exact.</i></p>
<p>Besides these user build profiles, there are also official release profiles, see <tt>ReleaseBuildProfiles</tt> in the same folder. The profiles <i>alpha-raw</i> and <i>alpha-vmware</i> will build all officially planned components for the alpha release. They are invoked just like the user profiles, see <ahref="#build_vmimage">Building a VMWare Image</a> a bit further down.
</p>
<h1>Building/installing Haiku Images</h1>
<p>Thanks to our <tt>UserBuildConfig</tt> it's all quite simple now.</p>
<h4>Installing on a partition/USB-stick</h4>
<p>To install Haiku directly onto a partition/USB-stick, you have to
set the according read and write permissions. <br/>
When installing to a hard drive partition, replace the drive name and use:</p>
<preclass="terminal">
sudo chmod o+r /dev/sda
sudo chmod o+rw /dev/sda7
</pre>
<pstyle="margin: 15pt">Note that the read permission is set for the whole disk (1st line)
while the write permission is limited to one specific partition (2nd
line).</p>
<p>When installing to a USB flashdrive, replace the drive name, and type:</p>
<p>If you do it all in one go by going straight with the <tt>sudo</tt>-line, some files are created under the "root" user, among them the image itself. This would then have to be rededicate with <tt>chown</tt> etc., so best to stick with the 2-stage approach as described.</p>
<p>Installing to its own partition offers some interesting possibilities:</p>
<preclass="terminal">sudo jam -q @disk update-all</pre>
<pstyle="margin: 15pt">This updates all of the system, but leaves the home folder untouched, so all your data will still be there.</p>
<p>You can also decide to only update certain components:</p>
<preclass="terminal">sudo jam -q @disk update {components}</pre>
<pstyle="margin: 15pt">Just replace the <tt>{components}</tt> with the program/component to be updated, e.g. <tt>kernel</tt>, <tt>StyledEdit</tt> or <tt>libmedia.so</tt> or more than one, separated with blanks. <tt>haiku/build/jam/HaikuImage</tt> lists all possible "targets".</p>
<h4><aid="build_vmimage"name="build_vmimage">Building a VMWare Image</a></h4>
<p>The created image can be run in VMPlayer with an associated <ahref="http://haiku-files.org/files/haiku.vmx">.vmx</a> file (There's also a <tt>.vmx</tt> file in <tt>haiku/3rdparty/vmware/</tt>).</p>