Beruflich Dokumente
Kultur Dokumente
http://debathena.mit.edu/packaging/
Setup
You will also need tools to develop Debian packages. For generic Debian development, you should install the following Debian packages (on Debathena you can just aptitude install debathena-debian-dev or even aptitude install debathena-build-depends to get all builddependencies of Debathena): aptitude install build-essential cdbs debhelper wdiff \ debian-el devscripts devscripts-el dh-make dpatch dpkg-awk \ dpkg-dev dpkg-dev-el equivs fakeroot linda lintian quilt sbuild The primary package compilation tool, debuild, will complain that youre not signing builds with the package maintainers key unless you pass it the arguments debuild -us -uc -sa; you can add DEBUILD_DPKG_BUILDPACKAGE_OPTS="-us -uc -sa -i -I" to ~/.devscripts to not see these warnings and to not incorrectly include version control information in source packages. If youre not running a distribution from 2008 or later, you should replace -I with -I.svn, where .svn is the extension for the version control system youre using. Youll also want to put your contact information in environment variables in ~/.bashrc (or equivalent): export DEBEMAIL="tabbott@mit.edu" export DEBFULLNAME="Tim Abbott" If youre planning to use quilt to patch packages, I recommend adding to your ~/.quiltrc: QUILT_PATCHES=debian/patches
Building packages
To download and compile the source package corresponding to the libqd-dev binary package, you can simply run: apt-get source libqd-dev cd qd-version-dversion debuild Assuming you have the relevant build-dependencies installed (debuild will complain if they are not) and the build succeeds, this will result in a number of les being generated:
1 of 8
http://debathena.mit.edu/packaging/
../spackage_version-dversion.di.gz
A new Debian source package di from the upstream tarball spackage_version.orig.tar.gz The new Debian source package description le. A copy of what was displayed on the screen during the build. The changes le describes a possible upload to the Debian archive. A resulting Debian binary package.
where version is the upstream version number for spackage, version-dversion is the Debian version number for spackage, arch is the architecture of the build machine, spackage is the name of the source package and bpackage is the name of a binary package from the source package (notice theres more than one!). You can inspect unpacked copies of your new packages in the debian/package subdirectories. Whenever you build a package, you should check if any lintian errors or warnings were displayed at the end of the output. lintian is a fantastic system that checks for a number of common packaging mistakes. In the case of our example, qd, the build log from Debian etch contains several Lintian errors, all of which are actual bugs in the qd package. Debathena packages often generate changelog-should-mention-nmu, source-nmu-has-incorrectversion-number (both irrelevant since NMUs are only meaningful in the Debian archive) and unknown-section (a result of the Debathena repository having dierent sections from the Debian archive). With CDBS, you sometimes also get a harmless package-has-a-duplicatebuild-relation warning.
debian/compat debian/control
debian/control.in
debian/copyright
2 of 8
http://debathena.mit.edu/packaging/
debian/rules
The information in the table above (along with the control le reference at the end of this document) should be sucient to generate the les mentioned so far aside from debian/rules, so we will focus attention on that. With CDBS, a simple package whose build system is based on autotools but where autoconf, automake, libtool, and aclocal should not be regenerated will probably look something like the following: #!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/autotools.mk DEB_CONFIGURE_EXTRA_FLAGS := --enable-shared # (this last line is from the qd package and is not generic) For packages that use other build systems, there are rules les in /usr/share/cdbs/1/class/ for make, python-distutils, ant, and a few others. If you plan to use quilt patches, youll want to include /usr/share/cdbs/1/rules/patchsys-quilt.mk. CDBS is primarily controlled through the setting of make variables in the rules le or through the existence of special les in the debian directory. Many changes to ags passed to during the build process can be implemented by just setting a single variable. Many of these variables can also be set on a per-package basis using names like CFLAGS_package. To get a denitive answer, one should inspect the code of debhelper.mk or the class le that you are using. Below we list some of the more useful ones: DEB_AUTO_UPDATE_DEBIAN_CONTROL Set this to enabled auto-generation of debian/control from debian/control.in. This option is basically banned in Debian because it apparently causes problems with NMUs, but it can save work. Any extra ags you want to pass to congure. Any environment variables you want to set for make. Pass extra ags to make (note the += here).
DEB_MAKE_{BUILD,CLEAN,}_TARGET (makefile.mk) Control what make targets CDBS uses. Note that make install and make check unless you set their corresponding target variable. DEB_MAKE_CLEAN_TARGET (makefile.mk) CFLAGS,CPPFLAGS,LDFLAGS, (makefile.mk) DEB_CONFIGURE_EXTRA_FLAGS (autotools.mk) Often you want to set this to distclean. Control common compiler and linker ags. Any extra ags you want to pass to congure.
DEB_AUTO_UPDATE_AUTOAUTO = version (makefile.mk)Have autotools component AUTOAUTOversion run at build time. DEB_DH_LINK_ARGS DEB_DH_debhelper-tool_ARGS Create symlinks in your installation. Add ags to any of a number of debhelper tools.
Many simple tasks, such as installing an init script for your package can be handled easily be
3 of 8
http://debathena.mit.edu/packaging/
just creating the relevant le (CDBS is automatically invoking debhelper to do this). Below is a list of some of the more useful ones; for a complete list, read debhelper.mk: debian/package.install Pairs, one per line, of les and directories to install them to. Understands * and copies directories recursively. The packages init script. Code to run update-rc.d and run the init script at package installation and removal is automatically added to maintainer scripts. cron job to be automatically installed into /etc/cron.d. List documentation les/directories to be automatically installed into /usr/share /doc/package. List directories to be automatically created. The packages postinst maintainer script. Make sure you include #DEBHELPER# in maintainer scripts and handle all the right arguments. The best way to do this is to start from /usr/share/debhelper /dh_make/debian/postinst.ex.
debian/package.init
debian/package.cron.d debian/package.docs
debian/package.dirs debian/package.postinst
Below are a number of tables of commands and information sources that should help you get all the information you need to make packages using CDBS. However, you probably should look at some more examples and probably need some practice. Plentiful examples are available in the CDBS gallery and the Debathena source tree; for practice, a good exercise is to pick a random package, delete its debian/rules le, and try to get it working using CDBS.
Useful commands
Below we list various commands that are frequently useful when doing Debian packaging: apt-get source package dpkg-source -x foo.dsc debuild debuild -S debuild -b debuild clean dch [-i] dpkg -i foo.deb apt-get install package dpkg -I foo.deb dpkg -c foo.deb dpkg -x foo.deb dir dpkg -e foo.deb dir Download and unpack a Debian source package. Unpack a Debian source package (a common operation for source packages downloaded from packages.debian.org). Build Debian source and binary packages from the root of an unpacked Debian source tree. Build only the source package. Build only the binary package. Clean up a Debian source tree. Add an item to the Debian changelog. Use -i to also increment the version number (potentially renaming the current directory). install a binary package install package from an apt repository. View package control information. List of les in package. Extract the package into directory dir. Extract Debian metadata (control le, maintainer scripts,
4 of 8
http://debathena.mit.edu/packaging/
md5sums, etc.) to directory dir. apt-cache show package Display control information for package. apt-cache search keywords Display a list of packages whose names or descriptions match keywords. aptitude search ~Dpackage List all packages in Debian that Depends: package. Other searches are possible as well: aptitude search ~DRecommends:package nds packages that Recommends: package. dpkg -l [package] dpkg -L package dpkg -S filename List packages installed on the system, and their version numbers. If package is provided, only list information for package. List the les in installed package package. List installed packages that contain lename.
apt-file search filename List all packages in Debian that contain lename. This command is slow. reprepro reportbug equivs-build equivs-control For setting up APT repositories. CLI to report a bug in Debian. It asks you questions and then sends an email. equivs is a tool for creating Debian packages that contain only dependency information. It is useful for creating metapackages and for creating dummy packages to cause dpkg to ignore a dependency. List diversions. The config-package-dev system uses these. Useful for doing advanced queries on the list of all packages. Guess runtime dependencies of a package using strace. (dpkg -L devscripts | grep bin is a good resources for nding this kind of thing).
dpkg-reconfigure package Recongure package by re-running its postinst script with options set to ask all the debconf questions. debconf-get-selections debconf-set-selections dh_make -c gpl -b -r Commands for interacting with the debconf database. Create a new template Debian package for a GPL-licensed piece of software using CDBS, and create a .orig.tar.gz from the current working directory. This should be run from the root directory of the relevant upstream source, and this directory should be called package-version. If the package is Debian-native, pass -n rather than -r. quilt is a useful system for generating patch sets. The Ubuntu packaging guide documents how to use it. If youre using AFS, you will use quilt refresh and quilt pop -a frequently. Remember to include /usr/share/cdbs/1/rules/patchsys-quilt.mk in your debian/rules le.
quilt
5 of 8
http://debathena.mit.edu/packaging/
postrm are named similarly. /var/lib/dpkg/info/package.conffiles The list of conffiles (conguration les not managed by debconf, Debians system for prompting the user) and their md5sums for package. The md5sums of the non-conles in package. Approximately 400 of the 18000 Debian packages fail to ship these. The control information for all packages currently installed on the system. If you break dpkg so that you have some package which is half-installed but cannot be either installed or removed, then editing this le may be a way to uninstall the package. Dont mess with it lightly. The Debian changelog for package. Useful to investigating when some behavior changed. The CDBS core rules les. Inspecting these (especially debhelper.mk and buildcore.mk) can help gure out how to add additional operations to your packages build process or pass arguments to debhelper. The CDBS rules les for various build systems. Inspecting the rules les that you are using (often makele*.mk or autotools*.mk) can be helpful for guring out how to do various supported things like pass additional make or congure ags. Debian packages page for package. Lists what version of package is available in each version of Debian, and for each such distribution links to the bug reports, changelog, source package, and binary package les for that version. Ubuntu packages page for package (similar to above). Debian bugs reported against package. Ubuntu bugs reported against package. CDBS Documentation. Contains documentation on the variables to use to congure the various classes, example, etc. Debians documentation for new developers. Recommended reading. This is good documentation for doing autotools and python packages with CDBS. You may also want to read the page
/var/lib/dpkg/info/package.md5sums
/var/lib/dpkg/status
/usr/share/cdbs/1/class/*.mk
http://packages.debian.org/package
6 of 8
http://debathena.mit.edu/packaging/
describing copyright and control les Debian Policy Manual Debian policy. Extensive. Has the precise denitions of each of the control elds and maintainer scripts. Debian Developers reference. Useful for deciding where a particular le should be installed on a Debian machine.
Section
Architecture
Depends
Recommends
Suggests Conicts
7 of 8
http://debathena.mit.edu/packaging/
Provides
Assign virtual names to the package. Debian uses this for dening alternatives (e.g. mail-transport-agent is anything providing sendmail), but Provides is useful for many other applications. When one package replaces or is a renaming of another, you want to specify Replaces: and Conicts: against that package. Files from the named packages will be overwritten with the les from your package and itll make aptitude happier about the upgrade. These are stronger versions of Depends and Conicts. Avoid using them. A description of the package in a weird format. Look at examples or see Debian policy.
Replaces
Debhelper
Debian-Native Packages
8 of 8