![]() |
College of Engineering and Computer Science (CECS)
School of Computer Science
|
|
COMP8440: Build TipsWhat is a package?A 'package' contains a set of binaries for a particular program. On the Ubuntu systems used in the COMP8440 lab, these packages normally have a filename ending in '.deb'. Normal users of Ubuntu systems would usually install packages using the 'package manager' of the system. That can either be done on the command line using the 'aptitude install' command, or via the graphical package manager under the System->Administration menu on your desktop. In this course you are learning how to participate in FOSS development, so you will be learning how to build your own packages from the source code. Building a packageBuilding a FOSS project can be tricky. You need to work out where to get the source from, you need to install all the package dependencies, and you need to sort through the idiosyncrasies of the packages build system.Downloading the sourceThere are a number of common ways to get the source code for a FOSS package. The main ones are:
Using the package managerNearly all FOSS operating system distributions include a 'package manager' which allows you to manage what software packages are installed on your system. On the COMP8440 Ubuntu lab systems the package manager is called 'apt'.Most package managers have the ability to ask for the source code for a particular package to be downloaded. With apt on Ubuntu the command is: apt-get source PACKAGEThis will typically download 4 things in to the current directory:
The .dsc file is useful because it contains a text description of the package, and in particular it contains a list of all of the packages build dependencies. The patches show you what changes the distribution made to the package when including it into the distribution. These changes may be just cosmetic, or may fix bugs that are not yet fixed in the official release The unpacked source is what you will need to actually build the package yourself. On Debian/Ubuntu systems this contains rules which tell the system how to build the package. To build the package, run the following command from within the source directory of the package: dpkg-buildpackageThat will build one or more '.deb' files in the directory above the source directory. You can install that deb file like this: sudo dpkg -i FILENAME.debAfter that you can use the commands in the package. When you no longer want the package, you should remove it using: sudo aptitude remove PACKAGE Using a release tarballOnce you find the home page for the package you are interested in, you can usually find a 'release tarball'. This contains the source code for an official release of the package.Once you've unpacked that tarball using something like this: tar xvzf package-x.y-z.tar.gzYou can start looking at the source code. Usually there is a text file in the top level directory which explains how to build the package, or there may be build instructions on the packages web site. There are many variants on how to build FOSS packages, but some common ones are:
./autogen.sh ./configure --prefix=$HOME/prefix make make installThat would put the build commands in $HOME/prefix/bin. The above recipe doesn't work for all packages (for example, many don't have an autogen.sh script), but it will work for a large number of them. Read the package documentation for the details of building the package you are working on. Using the source code management systemMost FOSS projects use a source code management system. When you are thinking about contributing to a project, this is usually the preferred way to access the source code, as you will have access to the latest developments made by other contributors.There are a wide range of SCMs used by FOSS projects. Some of the more popular ones are:
Some of the projects you will be working on for COMP8440 have very large source trees, and downloading using a SCM may take a very long time. To save time, we have put copies of a checked out copy of some of the larger projects in /comp8440/sources. To grab one of those use a command like this: rsync -av /comp8440/sources/wesnoth .Then cd to the directory and use the appropriate SCM to get any updates. For example, if the project uses svn, then use the command: svn update Build DependenciesOne of the trickier aspects of building a FOSS project can be installing all of the necessary build dependencies. A build dependency is another package that must be installed in order to build the package you want to build.There are several ways to find and install the build dependencies:
Using your package managerSome package managers have a feature that allows you to automatically install all the build dependencies for an already packaged project. For example, on Ubuntu/Debian systems, you can run this:sudo aptitude build-dep PACKAGE That is a very easy way to get the build dependencies installed. Be aware though that if you are trying to install a different version that what the distribution currently has packaged, you may find you need some additional packages. Looking at the package documentationMany FOSS projects have developer information on their web sites which describes what packages you need to install in order to build the project. It can sometimes be tricky to match the names in the documentation to the names of the packages in your distribution. Try using the synaptic package manager, or doing a google search for what you are trying to match.Looking in the dsc fileIf you downloaded the package source using 'apt-get source' then the .dsc file should contain a Build-Depends line which lists the packages that this package depends on. That can be a very good starting point for what you need to install.Trial and errorThis approach is just what it sounds like, and it is often needed in addition to one of the methods above. You try and build the package, and you see what errors it gives. You examine the errors and from there try to work out what dependent packages need to be installed. Remember that you often want the 'development' version of the package - so if you have a choice, look for one ending in '-dev'.The search feature in synaptic, or the command 'apt-cache search' is very useful in trying to find the right package.
Last modified: 10/04/2013, 07:56
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Please direct all enquiries to: comp8440@cs.anu.edu.au
Page authorised by: Head of School, CS |
| The Australian National University — CRICOS Provider Number 00120C |