Professional Documents
Culture Documents
An Introduction To Debian Packaging: Lucas Nussbaum
An Introduction To Debian Packaging: Lucas Nussbaum
Lucas Nussbaum
lucas@debian.org
1 / 47
Outline
1
Introduction Legal stuff Latest version & source code About this tutorial The Deb package format Tools you will need General packaging workow Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources
An Introduction to Debian Packaging 2 / 47
Legal stuff
3 / 47
Latest version:
http://git.debian.org/?p=users/lucas/packaging-tutorial.git;a=blob_plain;f= packaging-tutorial.pdf;hb=refs/heads/pdf
4 / 47
5 / 47
debian-binary: version of the deb le format, "2.0\n" control.tar.gz: metadata about the package
control, md5sums, (pre|post)(rm|inst), triggers, shlibs, . . .
data.tar.gz: data les of the package You could create your .deb les manually
http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
But most people dont do it that way This tutorial: create Debian packages, the Debian way
An Introduction to Debian Packaging 6 / 47
7 / 47
source package
debuild (build and test with lintian) one or several binary packages install (debi) upload (dput) .deb
8 / 47
Outline
1
Introduction Creating source packages Source packages basics Retrieving source packages Creating a basic source package Files in debian/ Packaging helpers Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources
An Introduction to Debian Packaging 9 / 47
Source package
One source package can generate several binary packages
e.g the libtar source generates the libtar and libtar-dev binary packages
Main le: .dsc (metadata) Other les depending on the version of the source format 1.0 native: package version.tar.gz 1.0 non-native: pkg ver.orig.tar.gz : upstream source pkg debver.diff.gz : patch to add Debian-specic changes 3.0 (quilt): pkg ver.orig.tar.gz : upstream source pkg debver.debian.tar.gz : tarball with the Debian changes (See dpkg-source(1) for exact details)
An Introduction to Debian Packaging 10 / 47
Format : 3.0 ( quilt ) Source : wget Binary : wget Architecture : any Version : 1.12 -2.1 Maintainer : Noel Kothe < noel@debian . org > Homepage : http :// www . gnu . org / software / wget / Standards - Version : 3.8.4 Build - Depends : debhelper ( > > 5.0.0) , gettext , texinfo , libssl - d Checksums - Sha1 : 50 d 4 e d 2 4 4 1 e 6 7 d b 7 a a 5 0 6 1 d 8 a 4 d d e 4 1 e e 0 e 9 4 2 4 8 2464747 wget_1 .12. ori d 4 c 1 c 8 b b e 4 3 1 d 6 1 3 1 c b d 7 e d 2 e 4 f c 3 7 d d 7 c e f 3 6 1 1 48308 wget_1 .12 -2.1. d Checksums - Sha256 : 7578 e d 0 9 7 4 e 1 2 c a a 7 1 1 2 0 5 8 1 f a 3 9 6 2 e e 5 a 6 9 f 7 1 7 5 d d c 3 d 6 a 6 d b 0 e c d c b a 6 5 b 5 1 e9b0c4c00eae6b4172baae219a14857f4002382b9d7a289de7ab789c402ad Files : 141461 b 9 c 0 4 e 4 5 4 d c 8 9 3 3 c 9 d 1 f 2 a b f 8 3 2464747 wget_1 .12. orig . tar . gz e 9 3 1 2 3 c 9 3 4 e 3 c 1 4 1 9 1 6 f 4 7 2 f 3 8 0 2 7 8 c 2 48308 wget_1 .12 -2.1. debian . ta
11 / 47
12 / 47
Download the upstream source Rename to source package upstream version.orig.tar.gz Untar it cd upstream source && dh make (from the dh-make package) There are some alternatives to dh make for specic sets of packages: dh-make-perl, dh-make-php, . . . debian/ directory created, with a lot of les in it
13 / 47
Files in debian/
All the packaging work should usually be made by modifying les in debian/ Main les: changelog copyright control rules Optional les: compat watch dh install* targets
*.dirs, *.docs, *.manpages, . . .
maintainer scripts
*.postinst, *.prerm, . . .
source/format patches
14 / 47
debian/changelog
Lists the Debian packaging changes Edited manually or with dch Special format to automatically close Debian or Ubuntu bugs Debian: Closes: #595268 ; Ubuntu: LP: #616929 Installed as /usr/share/doc/package /changelog.Debian.gz in your package
mpich2 (1.2.1.1 -5) unstable ; urgency = low * Use / usr / bin / python instead of / usr / bin / python2 .5. Allow to drop dependency on python2 .5. Closes : #595268 * Make / usr / bin / mpdroot setuid . This is the default after the installation of mpich2 from source , too . LP : #616929 + Add corresponding lintian override . -- Lucas Nussbaum < lucas@debian . org >
15 / 47
debian/copyright
Copyright and license information for the source and the packaging Traditionally written as a text le New machine-readable format: http://dep.debian.net/deps/dep5/
Format : < VERSIONED_FORMAT_URL > Upstream - Name : X Solitaire Source : ftp :// ftp . example . com / pub / games Files : * Copyright : Copyright 1998 John Doe < jdoe@example . com > License : GPL -2+ This program is free software ; you can redistribute it [...] . On Debian systems , the full text of the GNU General Public License version 2 can be found in the file / usr / share / common - licenses / GPL -2 . Files : debian /* Copyright : Copyright 1998 Jane Smith < jsm ith@exa mple . net > License : [ LICENSE TEXT ]
An Introduction to Debian Packaging 16 / 47
debian/control
Package metadata For the source package itself For each binary package built from this source Package name, section, priority, maintainer, uploaders, build-dependencies, dependencies, description, homepage, . . . Documentation: Debian Policy chapter 5 http://www.debian.org/doc/debian-policy/ch-controlfields.html
Source : wget Section : web Priority : important Maintainer : Noel Kothe < noel@debian . org > Build - Depends : debhelper ( > > 5.0.0) , gettext , texinfo , libssl - dev ( >= 0.9.8) , dpatch , info2man Standards - Version : 3.8.4 Homepage : http :// www . gnu . org / software / wget / Package : wget Architecture : any Depends : $ { shlibs : Depends } , $ { misc : Depends } Description : retrieves files from the web Wget is a network utility to retrieve files from the Web
An Introduction to Debian Packaging 17 / 47
18 / 47
debian/rules
Makele Interface used to build Debian packages Documented in Debian Policy, chapter 4.8
http://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules
Five required targets: build: should perform all the conguration and compilation of the package binary, binary-arch, binary-indep: build the binary packages produced by this source package dpkg-buildpackage will call binary to build all the packages, or binary-arch to build only the Architecture: any packages clean: clean up the source directory
19 / 47
Called from debian/rules Behaviour changed using command parameters or les in debian/
dirs, package.docs, package.examples, package.install, package.menu, package.logrotate, package.manpages, ...
Third-party helpers for sets of packages: python-support, dh ocaml, . . . Gotcha: debian/compat: Debhelper compatibility version (use 7)
20 / 47
install : build dh_testdir dh_testroot dh_clean -k dh_in stalldi rs # Add here commands to install the package into debian / package $ ( MAKE ) DESTDIR = $ ( CURDIR )/ debian / packagename install
An Introduction to Debian Packaging 21 / 47
CDBS
Still a lot of redundancy between packages Second-level helpers that factor common funtionality Building with ./configure && make && make install or CMake Support for Perl, Python, Ruby, GNOME, KDE, Java, Haskell, . . . CDBS: Introduced in 2005, based on advanced GNU make magic Documentation: /usr/share/doc/cdbs/ But some people hate it: Sometimes difcult to customize package builds: twisty maze of makeles, environment vars and black magic Slower than plain debhelper (many useless calls to dh *)
#!/ usr / bin / make -f include / usr / share / cdbs /1/ rules / debhelper . mk include / usr / share / cdbs /1/ class / autotools . mk # add an action after the build build / mypackage :: / bin / bash debian / scripts / foo . sh
An Introduction to Debian Packaging 23 / 47
24 / 47
Which one should I learn? Probably all of them You need to know debhelper to use CDBS and dh You might have to modify CDBS packages Which one should I use for a new package? dh (only solution with an increasing market share)
Market share (%)
60 40 20 0
debhelper dh CDBS
11/2009
05/2010
Time
12/2010
An Introduction to Debian Packaging 25 / 47
Outline
1
Introduction Creating source packages Building and testing packages Building packages Installing and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources Conclusion
An Introduction to Debian Packaging 26 / 47
Building packages
apt-get build-dep mypackage Installs the build-dependencies (for a package in the archive) debuild: build, test with lintian, sign with GPG Also possible to call dpkg-buildpackage directly Usually with dpkg-buildpackage -us -uc It is better to build packages in a clean & minimal environment pbuilder helper to build packages in a chroot Good documentation: https://wiki.ubuntu.com/PbuilderHowto schroot and sbuild: used on the Debian build daemons (not as easy to use as pbuilder) Generate .deb les and a .changes le .changes: describes what was built ; used to upload the package
27 / 47
Install the package locally: debi (will use .changes to know what to install) List the content of the package: debc ../mypackage<TAB>.changes Compare the package with a previous version: debdiff ../mypackage 1 *.changes ../mypackage 2 *.changes or to compare the sources: debdiff ../mypackage 1 *.dsc ../mypackage 2 *.dsc Check the package with lintian (static analyzer): lintian ../mypackage<TAB>.changes lintian -i: gives more information about the errors
28 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources Conclusion TODO
An Introduction to Debian Packaging 29 / 47
Go to http://ftp.debian.org/debian/pool/main/g/grep/ and download version 2.6.3-3 of the package Look at the les in debian/. How many binary packages are generated by this source package? Which packaging helper does this package use? Build the package We are now going to modify the package. Add a changelog entry and increase the version number. Now disable perl-regexp support (it is a ./configure option) Rebuild the package Compare the original and the new package with debdiff Install the newly built package
3 4
5 6 7 8
30 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Modifying the upstream source Doing things during installation and removal Maintaining packages in Debian Resources Conclusion
An Introduction to Debian Packaging 31 / 47
Often needed: Fix bugs or add customizations that are specic to Debian Backport xes from a newer upstream release Several methods to do it: Modifying the les directly Simple But no way to keep track and document the changes Using patch systems
32 / 47
Patch systems
Principle: changes are stored as patches in debian/patches/ Applied and unapplied during build Several implementations: simple-patchsys (cdbs only), dpatch, quilt Each supports two debian/rules targets: debian/rules patch: apply all patches debian/rules unpatch: de-apply all patches More documentation: http://wiki.debian.org/debian/patches Future: new source package format with built-in patch system: 3.0 (quilt) Recommended solution You need to learn quilt http://pkg-perl.alioth.debian.org/howto/quilt.html
33 / 47
Documentation of patches
34 / 47
http://people.debian.org/~srivasta/MaintainerScripts.html
Prompting the user Must be done with debconf Documentation: debconf-devel(7) (debconf-doc package)
35 / 47
Debian infrastructure that uses debian/watch: Debian External Health Status http://dehs.alioth.debian.org/ Maintainer warned by emails sent to the Packages Tracking System uscan: run a manual check uupdate: try to update your package to the latest upstream version
36 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Several ways to contribute to Debian More interested in Ubuntu? Adopting orphaned packages Resources Conclusion
An Introduction to Debian Packaging 37 / 47
Bring new software to Debian Is that new software interesting/useful enough? Are there alternatives already packaged in Debian? Adopt existing unmaintained packages (orphaned packages) Many unmaintained packages in Debian Including some that you rely on, probably Get involved in packaging teams Many teams that focus on set of packages, and need help Full list on http://wiki.debian.org/Teams An excellent way to work with more experienced contributors
38 / 47
39 / 47
40 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources Where to nd help? Ofcial documentation Conclusion
An Introduction to Debian Packaging 41 / 47
Where to nd help?
Help you will need: Various advices and answers to your questions, code reviews Sponsorship of your uploads, when your package is ready You can get help from: Other members of a packaging team: the best solution They know the specics of your package You can become a member of the team See http://wiki.debian.org/Teams The Debian Mentors group (if your package doesnt t in a team) http://wiki.debian.org/DebianMentorsFaq Mailing list: debian-mentors@lists.debian.org IRC: #debian-mentors on irc.debian.org http://mentors.debian.net/
42 / 47
Ofcial documentation
Debian Developers Corner http://www.debian.org/devel/
Links to many resources about Debian development
43 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources Conclusion TODO
An Introduction to Debian Packaging 44 / 47
Conclusion
Best practices have evolved over the years If unsure, use dh and 3.0 (quilt)
Feedback: lucas@debian.org
45 / 47
Outline
1
Introduction Creating source packages Building and testing packages Practical session: modifying the grep package Advanced packaging topics Maintaining packages in Debian Resources Conclusion TODO
An Introduction to Debian Packaging 46 / 47
Processes: Uploading debsign / dput private archive reprepro Packaging with VCSes debcheckout debcommit debrelease git-buildpackage svn-buildpackage Various: debc and lintian should really pick-up the .changes le automatically
47 / 47