Packaging Tutorial
Packaging Tutorial
Lucas Nussbaum
[email protected]
1 / 86
Goal: tell you what you really need to know about Debian packaging
I
2 / 86
Outline
1
Introduction
Conclusions
10
11
3 / 86
Outline
1
Introduction
Conclusions
10
11
4 / 86
Debian
I
GNU/Linux distribution
3 main features:
I Quality culture of technical excellence
We release when its ready
5 / 86
Debian packages
Universal:
I 30,000 binary packages in Debian
most of the available free software is packaged in Debian!
I
6 / 86
7 / 86
Some packages:
I build-essential: has dependencies on the packages that will be
assumed to be available on the developers machine (no need to
specify them in the Build-Depends: control field of your package)
I includes a dependency on dpkg-dev, which contains basic
Debian-specific tools to create packages
I
Many other tools will also be mentioned later, such as debhelper, cdbs, quilt,
pbuilder, sbuild, lintian, svn-buildpackage, git-buildpackage, . . .
Install them when you need them.
8 / 86
Web
upstream source
dget
dh_make
source package
.deb
install (debi)
9 / 86
10 / 86
Outline
1
Introduction
Conclusions
10
11
11 / 86
Source package
I
1.0 (non-native):
I pkg_ver.orig.tar.gz: upstream source
I pkg_debver.diff.gz: patch to add Debian-specific changes
3.0 (quilt):
I pkg_ver.orig.tar.gz: upstream source
I pkg_debver.debian.tar.gz: tarball with the Debian changes
12 / 86
13 / 86
14 / 86
Untar it
15 / 86
Files in debian/
All the packaging work should be made by modifying files in debian/
I
Main files:
I control meta-data about the package (dependencies, etc.)
I rules specifies how to build the package
I copyright copyright information for the package
I changelog history of the Debian package
Other files:
I compat
I watch
I dh_install* targets
*.dirs, *.docs, *.manpages, . . .
I
maintainer scripts
*.postinst, *.prerm, . . .
I
I
source/format
patches/ if you need to modify the upstream sources
16 / 86
debian/changelog
I
I
1.2.1.1-5
Upstream Debian
version revision
I
17 / 86
debian/control
I
Package metadata
I For the source package itself
I For each binary package built from this source
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
Debian Packaging Tutorial
18 / 86
19 / 86
debian/rules
I
Makefile
Required targets:
I build, build-arch, build-indep: should perform all the
configuration and compilation
I
20 / 86
Goals:
I Factor the common tasks in standard tools used by all packages
I Fix some packaging bugs once for all packages
dh_installdirs, dh_installchangelogs, dh_installdocs, dh_installexamples, dh_install,
dh_installdebconf, dh_installinit, dh_link, dh_strip, dh_compress, dh_fixperms, dh_perl,
dh_makeshlibs, dh_installdeb, dh_shlibdeps, dh_gencontrol, dh_md5sums, dh_builddeb, . . .
I
I
21 / 86
install : build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian / package
$ ( MAKE ) DESTDIR = $ ( CURDIR )/ debian / packagename install
Debian Packaging Tutorial
22 / 86
23 / 86
CDBS
I
CDBS:
I Introduced in 2005, based on advanced GNU make magic
I Documentation: /usr/share/doc/cdbs/
I Support for Perl, Python, Ruby, GNOME, KDE, Java, Haskell, . . .
I But some people hate it:
I Sometimes difficult to customize package builds:
"twisty maze of makefiles and environment variables"
I Slower than plain debhelper (many useless calls to dh_*)
24 / 86
25 / 86
Mind shares:
Classic debhelper: 27%
CDBS: 18%
dh: 54%
debhelper
dh
CDBS
60
40
20
02/2010
06/2011
11/2012
Time
Debian Packaging Tutorial
26 / 86
Outline
1
Introduction
Conclusions
10
11
27 / 86
Building packages
I
28 / 86
Install the package locally: debi (will use .changes to know what to install)
29 / 86
Outline
1
Introduction
Conclusions
10
11
30 / 86
Go to http://ftp.debian.org/debian/pool/main/g/grep/ and
download version 2.6.3-3 of the package (if you use Ubuntu 11.10 or later,
or Debian testing or unstable, use version 2.9-1 or 2.9-2 instead)
I If the source package is not unpacked automatically, unpack it with
dpkg-source -x grep_*.dsc
Look at the files in debian/.
I How many binary packages are generated by this source package?
I Which packaging helper does this package use?
We are now going to modify the package. Add a changelog entry and
increase the version number.
31 / 86
Outline
1
Introduction
Conclusions
10
11
32 / 86
debian/copyright
I
Copyright and license information for the source and the packaging
Format : http :// www . debian . org / doc / packaging - manuals / copyright - format /1.0/
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 < jsmith@example . net >
License :
[ LICENSE TEXT ]
33 / 86
34 / 86
Patch systems
I
New source package format with built-in patch system: 3.0 (quilt)
I Recommended solution
I
35 / 86
Documentation of patches
I
36 / 86
Documentation:
I Debian Policy Manual, chapter 6
http://www.debian.org/doc/debian-policy/ch-maintainerscripts
I
http://people.debian.org/~srivasta/MaintainerScripts.html
37 / 86
38 / 86
Several tools to help manage branches and tags for your packaging work:
svn-buildpackage, git-buildpackage
Example: git-buildpackage
I upstream branch to track upstream with upstream/version tags
I master branch tracks the Debian package
I debian/version tags for each upload
I pristine-tar branch to be able to rebuild the upstream tarball
Vcs - Browser : http :// anonscm . debian . org / gitweb /? p = collab - maint / devscripts . git
Vcs - Git : git :// anonscm . debian . org / collab - maint / devscripts . git
Vcs - Browser : http :// svn . debian . org / viewsvn / pkg - perl / trunk / libwww - perl /
Vcs - Svn : svn :// svn . debian . org / pkg - perl / trunk / libwww - perl
I
39 / 86
Backporting packages
General idea:
I Take the source package from Debian unstable
I
40 / 86
Outline
1
Introduction
Conclusions
10
11
41 / 86
42 / 86
Different states:
I
43 / 86
44 / 86
You do not need any official status to get your package into Debian
1 Submit an ITP bug (Intend To Package) using reportbug wnpp
2
45 / 86
Things to check:
I Avoid missing build-dependencies: make sure that your package
build fine in a clean sid chroot
I Using pbuilder is recommended
46 / 86
The Debian Mentors group (if your package does not fit in a team)
I http://wiki.debian.org/DebianMentorsFaq
I Mailing list: [email protected]
(also a good way to learn by accident)
I
I
I
47 / 86
More documentation
I
Debian Policy
http://www.debian.org/doc/debian-policy/
I
I
48 / 86
49 / 86
50 / 86
Using usertags:
http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=42;bug=642267
See https://wiki.debian.org/bugs.debian.org/usertags
BTS Documentation:
I http://www.debian.org/Bugs/
I https://wiki.debian.org/HowtoUseBTS
51 / 86
52 / 86
Outline
1
Introduction
Conclusions
10
11
53 / 86
Conclusions
I
Feedback: [email protected]
Debian Packaging Tutorial
54 / 86
Legal stuff
c
Copyright
20112013
Lucas Nussbaum [email protected]
This document is free software: you can redistribute it and/or modify it under either
(at your option):
I
The terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
http://www.gnu.org/licenses/gpl.html
55 / 86
Contribute:
I
debcheckout packaging-tutorial
git clone
git://git.debian.org/collab-maint/packaging-tutorial.git
http://git.debian.org/?p=collab-maint/packaging-tutorial.git
Provide feedback:
I mailto:[email protected]
I
I
reportbug packaging-tutorial
56 / 86
Outline
1
Introduction
Conclusions
10
11
57 / 86
Enjoy
58 / 86
Outline
1
Introduction
Conclusions
10
11
59 / 86
http://wiki.debian.org/Java
http://wiki.debian.org/Java/Packaging
http://www.debian.org/doc/packaging-manuals/java-policy/
http://pkg-java.alioth.debian.org/docs/tutorial.html
Package it
60 / 86
Outline
1
Introduction
Conclusions
10
11
61 / 86
http://wiki.debian.org/Ruby
http://wiki.debian.org/Teams/Ruby
http://wiki.debian.org/Teams/Ruby/Packaging
62 / 86
Outline
1
Introduction
Conclusions
10
11
63 / 86
http://pkg-perl.alioth.debian.org/
http://wiki.debian.org/Teams/DebianPerlGroup
Create a basic Debian source package from the Acme CPAN distribution:
dh-make-perl --cpan Acme
64 / 86
Outline
1
Introduction
Conclusions
10
11
65 / 86
Answers to
practical sessions
66 / 86
Go to http://ftp.debian.org/debian/pool/main/g/grep/ and
download version 2.6.3-3 of the package (if you use Ubuntu 11.10 or later,
or Debian testing or unstable, use version 2.9-1 or 2.9-2 instead)
We are now going to modify the package. Add a changelog entry and
increase the version number.
67 / 86
Go to http://ftp.debian.org/debian/pool/main/g/grep/ and
download version 2.6.3-3 of the package
68 / 86
69 / 86
We are now going to modify the package. Add a changelog entry and
increase the version number.
debian/changelog is a text file. You could edit it and add a new entry
manually.
Or you can use dch -i, which will add an entry and open the editor
The name and email can be defined using the DEBFULLNAME and DEBEMAIL
environment variables
After that, rebuild the package: a new version of the package is built
70 / 86
Add --disable-perl-regexp
71 / 86
72 / 86
Enjoy
73 / 86
Step by step. . .
I
wget http://ftp.gnu.org/gnu/gnujump/gnujump-1.0.8.tar.gz
mv gnujump-1.0.8.tar.gz gnujump_1.0.8.orig.tar.gz
tar xf gnujump_1.0.8.orig.tar.gz
cd gnujump-1.0.8/
dh_make
I
preinst . ex
prerm . ex
README . Debian
README . source
rules
source
watch . ex
74 / 86
In debian/control:
Build-Depends: debhelper (>= 7.0.50 ), autotools-dev
Lists the build-dependencies = packages needed to build the package
75 / 86
Some hints:
I Remove the files that you dont need in debian/
I
Fill in debian/control
76 / 86
77 / 86
http://wiki.debian.org/Java
http://wiki.debian.org/Java/Packaging
http://www.debian.org/doc/packaging-manuals/java-policy/
http://pkg-java.alioth.debian.org/docs/tutorial.html
Package it
78 / 86
Step by step. . .
79 / 86
http://wiki.debian.org/Ruby
http://wiki.debian.org/Teams/Ruby
http://wiki.debian.org/Teams/Ruby/Packaging
80 / 86
Step by step. . .
gem2deb net-ssh:
I
81 / 86
82 / 86
Compare your package with the ruby-net-ssh package in the Debian archive
83 / 86
http://pkg-perl.alioth.debian.org/
http://wiki.debian.org/Teams/DebianPerlGroup
Create a basic Debian source package from the Acme CPAN distribution:
dh-make-perl --cpan Acme
84 / 86
Step by step. . .
85 / 86
86 / 86