wiki:BuildingAPackage

Version 2 (modified by jdreed, 9 years ago) (diff)

--

Building A Package

The debuild command is used to actually build the package. Recall that back in GettingStartedWithDevelopment we set some default options for debuild, and this documentation assumes those examples have been set.

To build your package, change to the root directory of the package (which contains a debian directory), and type:

debuild

(You can add -S or -b to build only the source or binary package, respectively)

The Build Process

You'll see a lot of output scroll by as debuild builds the source package and the binary package. If you scroll through the output, you'll see a lot of invocations of commands that begin with dh_. These are debhelper utilities, and they're being invoked because of the debhelper.mk line in our rules file. Without that, you'd have to specify each of these commands, in the correct order, in the rules file.

Towards the end, you'll see a line like this: dpkg-deb: building package some-package-name in ../some-package-name-1.0_all.deb`

Note that the .deb is created in the _parent directory_ of the one you're currently in. In the parent directory, you'll also see a .dsc and a .tar.gz file (unless you told debuild not tobuild a source package), you'll see a .build file, which contains the build log. Reading through that file is often easier than scrolling back in your Terminal to identify errors.

One of the last steps of the build process is to run Lintian. Lintian is a utility that looks at your packages and checks for common errors. Its output looks like this:

W: some-package-name source: changelog-should-mention-nmu

The W indicates a warning (an 'E' would indicate an error), the source indicates that this warning applies to the source package (as opposed to the package as a whole), and the last part is the "tag". You can look up lintian tags at  http://lintian.debian.org, and the description of the tag will tell you what causes it, and generally how to fix it. Note than an 'error' does not actually mean that the package failed to build, but rather that it's a seriousl problem that should be rectified.

Some Lintian warnings are expected with the Debathena repository.

Troubleshooting

A common problem is not having build dependencies installed.

Cleaning Up

If you look at your package's directory now, you'll see a lot more files than were originally there. These were created as part of the build process. You can clean up with the command:

debuild clean

This will remove any files created by the build process.