fixed merge conflicts
[tridge/comp8440.git] / building.php
1 <?php
2 include "8440head.php";
3 ?>
4
5
6
7 <center>
8 <h1>
9 <font color="#931515" size="+3">COMP8440: Build Tips</font>
10 </h1>
11 </center>
12
13 <h1>Building a package</h1>
14
15 Building a FOSS project can be tricky. You need to work out where
16 to get the source from, you need to install all the package
17 dependencies, and you need to sort through the idiosyncrasies of the
18 packages build system.
19
20 <h2>Downloading the source</h2>
21
22 There are a number of common ways to get the source code for a FOSS
23 package. The main ones are:
24
25 <ul>
26 <li>Using the package manager for your distribution</li>
27 <li>Downloading a release tarball</li>
28 <li>Downloading via the projects source code management system</li>
29 </ul>
30
31 <h3>Using the package manager</h3>
32
33 Nearly all FOSS operating system distributions include a 'package
34 manager' which allows you to manage what software packages are
35 installed on your system. On the COMP8440 Ubuntu lab systems the
36 package manager is called 'apt'.<p>
37
38 Most package managers have the ability to ask for the source code
39 for a particular package to be downloaded. With apt on Ubuntu the
40 command is:
41
42 <pre><b>
43   apt-get source PACKAGE
44 </b></pre>
45
46 This will typically download 4 things in to the current directory:
47
48 <ul>
49 <li>The original tarball of the upstream package
50 <li>A .dsc description of the package
51 <li>A set of compressed patches to the upstream package 
52 <li>An unpacked, patched, version of the package that is ready to
53 build
54 </ul>
55
56 The original tarball is useful if you want to see what the upstream
57 maintainer provided (this is usually a copy of the official release
58 from the package author).<p>
59
60 The .dsc file is useful because it contains a text description of the
61 package, and in particular it contains a list of all of the packages
62 build dependencies.<p>
63
64 The patches show you what changes the distribution made to the package
65 when including it into the distribution. These changes may be just
66 cosmetic, or may fix bugs that are not yet fixed in the official
67 release<p>
68
69 The unpacked source is what you will need to actually build the
70 package yourself. On Debian/Ubuntu systems this source package should
71 contain a directory called 'debian' which contains a 'rules' file that
72 can be used to build the package. If you cd to the unpacked directory,
73 you should be able to build the package using:
74
75 <pre><b>
76   debian/rules binary
77 </b></pre>
78
79 <h3>Using a release tarball</h3>
80
81 Once you find the home page for the package you are interested in, you
82 can usually find a 'release tarball'. This contains the source code
83 for an official release of the package.<p>
84
85 Once you've unpacked that tarball using something like this:
86
87 <pre><b>
88   tar xvzf package-x.y-z.tar.gz
89 </b></pre>
90
91 You can start looking at the source code. Usually there is a text file
92 in the top level directory which explains how to build the package, or
93 there may be build instructions on the packages web site. There are
94 many variants on how to build FOSS packages, but some common ones are:
95
96 <ul>
97 <li>A configure script, followed by make
98 <li>A bootstrap.sh script
99 <li>A autogen.sh script, followed by make
100 <li>A build.sh script
101 </ul>
102
103 In each case, you will need to install any package dependencies. See
104 the build dependencies section of this guide.
105
106 <h3>Using the source code management system</h3>
107
108 Most FOSS projects use a source code management system. When you are
109 thinking about contributing to a project, this is usually the
110 preferred way to access the source code, as you will have access to
111 the latest developments made by other contributors.<p>
112
113 There are a wide range of SCMs used by FOSS projects. Some of the more
114 popular ones are:
115
116 <ul>
117 <li>cvs
118 <li>git
119 <li>svn (subversion>
120 <li>bzr (bazaar)
121 <li>hg (mercurial)
122 </ul>
123
124 The web site for the project usually gives instructions for how to
125 download the source code using whichever tool is appropriate.<p>
126
127 Some of the projects you will be working on for COMP8440 have very
128 large source trees, and downloading using a SCM may take a very long
129 time. To save time, we have put copies of a checked out copy of some
130 of the larger projects in /comp8440/sources. To grab one of those use
131 a command like this:
132
133 <pre><b>
134   rsync -av /comp8440/sources/wesnoth .
135 </b></pre>
136
137 Then cd to the directory and use the appropriate SCM to get any
138 updates. For example, if the project uses svn, then use the command:
139
140 <pre><b>
141   svn update
142 </b></pre>
143
144
145 <h2>Build Dependencies</h2>
146
147 One of the trickier aspects of building a FOSS project can be
148 installing all of the necessary build dependencies. A build dependency
149 is another package that must be installed in order to build the
150 package you want to build.<p>
151
152 There are several ways to find and install the build dependencies:
153
154 <ul>
155 <li>Look at the package documentation
156 <li>Looking in the dsc file
157 <li>Using your package manager
158 <li>Trial and error
159 </ul>
160
161 <h3>Looking at the package documentation</h3>
162
163 Many FOSS projects have developer information on their web sites which
164 describes what packages you need to install in order to build the
165 project. It can sometimes be tricky to match the names in the
166 documentation to the names of the packages in your distribution. Try
167 using the synaptic package manager, or doing a google search for what
168 you are trying to match.
169
170 <h3>Looking in the dsc file</h3>
171
172 If you downloaded the package source using 'apt-get source' then the
173 .dsc file should contain a Build-Depends line which lists the packages
174 that this package depends on. That can be a very good starting point
175 for what you need to install. 
176
177 <h3>Using your package manager</h3>
178
179 Some package managers have a feature that allows you to automatically
180 install all the build dependencies for an already packaged project. For
181 example, on Ubuntu/Debian systems, you can run this:
182
183 <pre><b>
184   sudo apt-get build-dep PACKAGE
185 </b></pre>
186
187 That is a very easy way to get the build dependencies installed. Be
188 aware though that if you are trying to install a different version
189 that what the distribution currently has packaged, you may find you
190 need some additional packages.
191
192 <h3>Trial and error</h3>
193
194 This approach is just what it sounds like, and it is often needed in
195 addition to one of the methods above. You try and build the package,
196 and you see what errors it gives. You examine the errors and from
197 there try to work out what dependent packages need to be
198 installed. Remember that you often want the 'development' version of
199 the package - so if you have a choice, look for one ending in '-dev'.<p>
200
201 The search feature in synaptic, or the command 'apt-cache search' is
202 very useful in trying to find the right package.
203
204 <p><div align="center">
205   <?php
206     print " Last modified: ";
207     $last_modified = getlastmod();
208     print(date("j/m/Y, H:i", $last_modified));
209   ?>
210 </div><p>
211
212 <?php
213 include "8440tail.php";
214 ?>
215
216
217