Debian for Developers Tutorial

Debian for Developers Tutorial

Documents
26 pages
Lire
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Debian for Developers TutorialWichert Akkerman wichert@linux.comRobert van der Meulen rvdm@wiretrip.orgCopyright © 2001 by Wichert AkkermanCopyright © 2001 by Robert van der MeulenDebian for Developers TutorialTable of ContentsPreface..................................................................................................................................................................1Chapter 1. Packages ............................................................................................................................................21.1. The package format ...........................................................................................................................21.1.1. Overview ........................................................................................................................................21.1.2. The package metadata ....................................................................................................................21.1.3. The data ............................................................................................................................31.2. Package relations ..............................................................................................................................31.3. The package installation process ......................................................................................................31.4. The removal ...... ...

Sujets

Informations

Publié par
Ajouté le 24 septembre 2011
Nombre de lectures 24
Langue Slovak
Signaler un problème

Debian for Developers Tutorial
Wichert Akkerman
wichert@linux.com
Robert van der Meulen
rvdm@wiretrip.org
Copyright © 2001 by Wichert Akkerman
Copyright © 2001 by Robert van der MeulenDebian for Developers Tutorial
Table of Contents
Preface..................................................................................................................................................................1
Chapter 1. Packages ............................................................................................................................................2
1.1. The package format ...........................................................................................................................2
1.1.1. Overview ........................................................................................................................................2
1.1.2. The package metadata ....................................................................................................................2
1.1.3. The data ............................................................................................................................3
1.2. Package relations ..............................................................................................................................3
1.3. The package installation process ......................................................................................................3
1.4. The removal ...........................................................................................................4
Chapter 2. Building packages ............................................................................................................................5
2.1. The debian/ directory ........................................................................................................................5
2.1.1. The debian/control file ...................................................................................................................5
2.1.2. The debian/rules script ...................................................................................................................6
2.1.3. The debian/shlibs file .....................................................................................................................6
2.2. The debian/changelog file .................................................................................................................6
2.3. Version numbers ...............................................................................................................................7
2.4. Questions..........................................................................................................................................7
Chapter 3. Interface with the rest of the OS ....................................................................................................8
3.1. Users and groups ...............................................................................................................................8
3.2. Filesystem Hierarchy Standard .........................................................................................................8
3.3. cron jobs ............................................................................................................................................9
3.4. Questions..........................................................................................................................................9
Chapter 4. daemons and init scripts ................................................................................................................10
4.1. init scripts ........................................................................................................................................10
4.2. The start−stop−daemon tool ...........................................................................................................10
4.3. Handling installation and removal ..................................................................................................11
4.4. Questions........................................................................................................................................11
Chapter 5. Cleaning up when removing or purging a package ....................................................................12
5.1. What data needs to be removed, and what data needs to be kept? .................................................12
5.2. is the difference between handling a 'remove' and a 'purge'? ................................................12
5.3. Questions........................................................................................................................................12
Chapter 6. Complex package operations ........................................................................................................13
6.1. Virtual packages ..............................................................................................................................13
6.2. Renaming a package .......................................................................................................................13
6.3. Splitting a ..........................................................................................................................13
6.4. Example of a complex package: proftpd ........................................................................................13
6.5. Questions........................................................................................................................................14
Chapter 7. Build Dependencies ........................................................................................................................15
7.1. Why we need build constraints .......................................................................................................15
7.2. build−essentials ...............................................................................................................................15
7.3. architecture−specific constraints .....................................................................................................15
iDebian for Developers Tutorial
Table of Contents
7.4. Questions........................................................................................................................................15
Chapter 8. DebConf ..........................................................................................................................................16
8.1. Why the need for debconf ...............................................................................................................16
8.2. Using debconf .................................................................................................................................16
8.3. The templates file ............................................................................................................................16
8.4. Handling i18n
8.5. Questions........................................................................................................................................17
Chapter 9. Using debhelper .............................................................................................................................18
9.1. What is debhelper? ..........................................................................................................................18
9.2. Building a package from scratch using dh_make ...........................................................................18
9.2.1. dh_make .......................................................................................................................................18
9.2.2. dh_install* ....................................................................................................................................18
9.2.3. Other helper utilities ....................................................................................................................19
Chapter 10. Package archives ..........................................................................................................................20
10.1. Archive structure ...........................................................................................................................20
10.2. Using dpkg−scanpackages, and the override file ..........................................................................21
Chapter 11. Maintainership .............................................................................................................................22
11.1. Being a responsible package maintainer .......................................................................................22
11.2. Red tape ........................................................................................................................................22
Debian for developers bibiography .....................................................................................................................22
iiPreface
These are the handouts for the Debian for Developers tutorial from the LinuxWorld Conference and Expo
2001.
Preface 1Chapter 1. Packages
Packages are the basic units in which software and data is installed using a package manager. This chapter
describes the internals of a package.
1.1. The package format
1.1.1. Overview
The Debian package management system uses the .deb format, currently at revision 2. The .deb format is
very simple and based on the following principles:
• A package has to be extractable using traditional UNIX tools
• The format must be easily extensible
The format is a ar archive which contains 3 files:
debian−binary
Contains the version number of the package format. Currently this is "2.0".
control.tar.gz
Compressed tar archive with the package metadata
data.tar.gz
Compressed tar archive with the package data
1.1.2. The package metadata
The package metadata describes the data that is inside the package (in the data.tar.gz component). The
only obgligatory file in the metadata is the control file. This file is a text−file in RFC822 style which
describes the package in detail.
Example 1−1. Example control file
Package: dpkg
Version: 1.9.12
Section: base
Priority: required
Architecture: i386
Essential: yes
Pre−Depends: libc6 (>= 2.2.3−1), libncurses5 (>= 5.2.20010310−1),
libstdc++2.10−
glibc2.2
Conflicts: sysvinit (<< 2.72)
Replaces: dpkg−doc−ja
Installed−Size: 3112
Origin: debian
Maintainer: Wichert Akkerman <wakkerma@debian.org>
Bugs: debbugs://bugs.debian.org
Description: Package maintenance system for Debian
This package contains the programs which handle the installation and
Chapter 1. Packages 2Debian for Developers Tutorial
removal of packages on your system.
.
The primary interface for the dpkg suite is the `dselect' program;
a more low−level and less user−friendly interface is available in
the form of the `dpkg' command.
.
In order to unpack and build Debian source packages you will need to
install the developers' package `dpkg−dev' as well as this one.
Control can also contain the (optional) maintainer scripts preinst, postinst, prerm, and postrm.
These are executables that dpkg will run at various stages during package installation and removal.
Other files may also be present. dpkg will not do anything with those itself but will copy them to its database
so other tools can use them. This is used for extensions such as shlibs files and debconf.
1.1.3. The package data
The control.tar.gz contains the files that will be installed on the filesystem when a package is installed.
1.2. Package relations
Packages are not stand−alone objects, but can work together to form a complete system. There is a rich set of
relations between packages for this purpose:
Pre−Depends
Lists other packages that have to be fully installed before dpkg starts installing this package.
Depends
Lists other packages that have to be fully installed before dpkg can configure this package.
Conflicts
Lists other packages that can not be insatlled at the same time as this package.
Provides
Indicated that this package provides a virtual package.
Replaces
A list of packages whose file a package is allower to overwrite.
Recommends, Suggests
A list of packages that might also be useful or interesting to people using this package.
1.3. The package installation process
When installing a package the process is simple:
Package installation procedure
1. <new−preinst>install
2. Package is unpacked
3. <new−postinst>configure
1.1.3. The package data 3Debian for Developers Tutorial
When we are upgrading an already installed package the procedure is slightly more complex:
Package upgrade procedure
1. <old−prerm>upgrade<new−version>
2. <new−preinst>install<old−version>
3. Package is unpacked
4. <old−postrm>upgrade
5. <new−postinst>configure<old−version>
If any step in this process fails dpkg will try to return to previous safe situation. The details on this process are
described in the dpkg reference manual.
1.4. The package removal process
Package removal is very similar to installation except the process is done in reverse:
Package removal procedure
1. prermremove
2. Package files are removed (except for conffiles)
3. postrmremove
4. Remove maintainer scripts except for postrm
When the package is being purged two extra steps are performed:
Package purge procedure
1. Configuration files (and associated backupfiles) are removed.
2. postrmpurge
3. Package is removed from the dpkg database.
1.4. The package removal process 4Chapter 2. Building packages
2.1. The debian/ directory
The debian/ subdirectory in a sourcetree contains the files that are needed to build a package. Those files
have rules for compiling the sources and building the package, information about the packages that will be
made and a changelog.
2.1.1. The debian/control file
The control describes the source and the packages that are generated from it. Just like other files this file is
in RFC822 syntax, with an empty line seperating multiple sections. The first section describes the source, and
the other sections the packages.
Table 2−1. Fields in the source section of the control file
Field required Description
Source yes Name of the source package
Section no Package category for this package, used by
frontends.
Priority no Indication of package importance. Legal values are
extra, important, optional, required and standard.
Maintainer yes Name of the source package
Standards−Version no Version of Debian policy this package is complient
with
Build−Depends, Build−Conflicts, no Specify demands on the build environment
Build−Depends−Indep,
Build−Conflicts−Indep
Bugs no Name of the source package
Origin no
Table 2−2. Fields in the package section of the control file
Field required Description
Package yes Name of the package
Architecture yes Space seperated list of architectures for which
package are build from this source
Essential no Indicates if a package is essential to the system
Pre−Depends, Depends, Recommends, no Specify relations to other packages
Suggests, Replaces, Conflicts
Description yes Description of the package
Entries in a package−section of the control file may contain variables that will be substituted when the
package is build using the ${variable} syntax. Variables can be set either by tools such as dpkg−shlibdeps or
Chapter 2. Building packages 5Debian for Developers Tutorial
with commandline options for dpkg−gencontrol.
2.1.2. The debian/rules script
debian/rules is an executable that builds the packages from a source tree. It takes an argument that
describes what it should do:
build
Perform a (non−interactive) configuration and compilation of the package.
binary
Build all the packages. This might include the build state as well. Generally this will invoke the
binary−arch and binary−indep rules.
binary−arch
Build all architecture−dependent packages.
binary−indep
clean
Undo all the affects from the build and binary targets. The result should be a clean tree with just the
uncompiled source.
Although not obligatory all Debian packages use an executable makefile which are very well suited for this
use.
2.1.3. The debian/shlibs file
When creating a package we need to be sure that all the libraries it uses are listed in the Depends field. This is
automated using the shlibs systems. Each library package contains a shlibs file in its metadata that lists the
libraries it contains and the proper dependency that is needed for packages using those libraries.
Example 2−1. Example shlibs file for libldap2
liblber 2 libldap2 (>= 2.0.11−1)
libldap 2 libldap2 (>= 2.0.11−1)
libldap_r 2 libldap2 (>= 2.0.11−1)
This information is used by the dpkg−shlibdeps tool. When it is running during a package build it will check
for each library an executable uses which packages provides it and add the associated shlibs entry to the list of
variable substitutions that dpkg−gencontrol uses when generating the control data for a package.
2.2. The debian/changelog file
Any changes to the packaging are listed in the debian/changelog file. This file is also used to extract the
versionnumber for packages being build.
A special format is used that is easily parseable by the packaging tools:
2.1.2. The debian/rules script 6Debian for Developers Tutorial
<package> (<version>) <distribution(s)>; urgency=<urgency>
* change details
more change details
* even more change details
−− <maintainer name> <<email address>> <date>
The maintainer name listed in the changelog file is extracted when generating packages and used to fill the
Changed−By field in a .changes.
It is also possible to close open bugreports in the Debian bug tracking system by putting special tags in the
change details. The syntax for that is Closes: Bug#12345. This indicates that when the package is installed in
the Debian archive bug 12345 should be closed.
2.3. Version numbers
Each pakage release has a specific version number. A version number consists of two parts: the upstream
version, and the debian revision, which are seperated by a hyphen (−). Each part may consist of alphanumeric
ASCII characters and the characters `.', `+', `−' and `:'. If there is no debian revision then the upstream version
is not allowed to have a −.
Comparing version number is done by breaking them into pieces and comparing those from left to right.
Pieces are seperated by a transition from numbers to characters and by non−alphanumeric characters.
2.4. Questions
1. You are packaging a CVS snapshot from June 29, 2001 from the version 2 development branch of
mooscored. What version number would you use?
2. You want to package the second prerelease for version 2 of mooscored. What version number would
you use?
3. Version 1.3−2 of your package had a bug that requires special attention before upgrading to a later
version. How would you handle that?
2.3. Version numbers 7