old-www/HOWTO/html_single/Debian-Binary-Package-Build.../index.html

1753 lines
33 KiB
HTML
Raw Permalink Blame History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Debian Binary Package Building HOWTO</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"></HEAD
><BODY
CLASS="article"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="ARTICLE"
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
><A
NAME="AEN2"
></A
>Debian Binary Package Building HOWTO</H1
><H3
CLASS="author"
><A
NAME="AEN4"
>Chr. Clemens Lee</A
></H3
><DIV
CLASS="affiliation"
><DIV
CLASS="address"
><P
CLASS="address"
><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<TT
CLASS="email"
>&#60;<A
HREF="mailto:clemens@kclee.de"
>clemens@kclee.de</A
>&#62;</TT
><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P
></DIV
></DIV
><P
CLASS="pubdate"
>2002-11-30, $Date: 2005/08/09 20:49:46 $<BR></P
><DIV
CLASS="revhistory"
><TABLE
WIDTH="100%"
BORDER="0"
><TR
><TH
ALIGN="LEFT"
VALIGN="TOP"
COLSPAN="3"
><B
>Revision History</B
></TH
></TR
><TR
><TD
ALIGN="LEFT"
>Revision 4.0</TD
><TD
ALIGN="LEFT"
>2005-08-09</TD
><TD
ALIGN="LEFT"
>Revised by: ccl</TD
></TR
><TR
><TD
ALIGN="LEFT"
COLSPAN="3"
>updated email address and added link to Turkish translation by Oguz Yarimtepe</TD
></TR
><TR
><TD
ALIGN="LEFT"
>Revision 3.0</TD
><TD
ALIGN="LEFT"
>2003-12-19</TD
><TD
ALIGN="LEFT"
>Revised by: ccl</TD
></TR
><TR
><TD
ALIGN="LEFT"
COLSPAN="3"
>fixed two typos reported by Claudio Cattazzo</TD
></TR
><TR
><TD
ALIGN="LEFT"
>Revision 2.0</TD
><TD
ALIGN="LEFT"
>2003-12-13</TD
><TD
ALIGN="LEFT"
>Revised by: ccl</TD
></TR
><TR
><TD
ALIGN="LEFT"
COLSPAN="3"
>applying Frank Lichtenheld's feedback</TD
></TR
><TR
><TD
ALIGN="LEFT"
>Revision 1.0</TD
><TD
ALIGN="LEFT"
>2003-11-08</TD
><TD
ALIGN="LEFT"
>Revised by: ccl</TD
></TR
><TR
><TD
ALIGN="LEFT"
COLSPAN="3"
>first version</TD
></TR
></TABLE
></DIV
><DIV
><DIV
CLASS="abstract"
><A
NAME="AEN32"
></A
><P
></P
><P
>&#13;
<EM
>This mini-HOWTO shows how to build a minimal Debian .deb package.</EM
>
</P
><P
></P
></DIV
></DIV
><HR></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
>1. <A
HREF="#AEN35"
>Introduction</A
></DT
><DD
><DL
><DT
>1.1. <A
HREF="#AEN42"
>Resources on the Web</A
></DT
></DL
></DD
><DT
>2. <A
HREF="#AEN48"
>Getting Started</A
></DT
><DT
>3. <A
HREF="#AEN60"
>Package Structure</A
></DT
><DD
><DL
><DT
>3.1. <A
HREF="#AEN66"
>debian-binary</A
></DT
><DT
>3.2. <A
HREF="#AEN69"
>data.tar.gz</A
></DT
><DT
>3.3. <A
HREF="#AEN74"
>control.tar.gz</A
></DT
></DL
></DD
><DT
>4. <A
HREF="#AEN88"
>Hands On</A
></DT
><DD
><DL
><DT
>4.1. <A
HREF="#AEN92"
>control</A
></DT
><DT
>4.2. <A
HREF="#AEN108"
>dpkg-deb</A
></DT
></DL
></DD
><DT
>5. <A
HREF="#AEN121"
>Double Check</A
></DT
><DD
><DL
><DT
>5.1. <A
HREF="#AEN124"
>lintian</A
></DT
><DT
>5.2. <A
HREF="#AEN131"
>Minimal Documentation</A
></DT
><DT
>5.3. <A
HREF="#AEN146"
>fakeroot</A
></DT
><DT
>5.4. <A
HREF="#AEN155"
>More Documentation</A
></DT
></DL
></DD
><DT
>6. <A
HREF="#AEN169"
>Summary</A
></DT
><DT
>7. <A
HREF="#AEN231"
>What Else</A
></DT
><DT
>8. <A
HREF="#AEN242"
>Credits</A
></DT
><DT
>9. <A
HREF="#AEN267"
>Links</A
></DT
></DL
></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="AEN35"
></A
>1. Introduction</H1
><P
>&#13;
The intended use of such a newly created
archive is to install it only on your own box, not to get them into the official
Debian distribution. To follow the 'official' process, please study
the <A
HREF="http://www.debian.org/doc/maint-guide/"
TARGET="_top"
>Debian New Maintainers' Guide</A
>.
</P
><P
>&#13;
Normal Debian packages get a proper source package,
including a debian/rules file which
automates the steps involved in creating the binary package.
Here we just show how to package a simple shell script or binary executable
into a small binary package.
</P
><P
>&#13;
BTW, I assume you know how to use 'tar', 'man', and what a '.tar.gz' file and
<A
HREF="http://www.debian.org/"
TARGET="_top"
>Debian</A
> is (and how
to use an editor ;-), but I
assume you have never touched programs like 'ar' or 'dpkg'.
</P
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN42"
></A
>1.1. Resources on the Web</H2
><P
>&#13;
<A
HREF="http://www.debian.org/doc/manuals/reference/reference.en.html"
TARGET="_top"
>The Debian Reference</A
>
gives an excellent overview as well as detailed information
for everything Debian specific.
</P
><P
>&#13;
The official document for creating your own Debian packages is the
<A
HREF="http://www.debian.org/doc/maint-guide/"
TARGET="_top"
>Debian New Maintainers' Guide</A
>.
</P
></DIV
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN48"
></A
>2. Getting Started</H1
><P
>&#13; From the Debian Reference 2.2.2 2002-11-30: "The internals of this Debian binary package format are described in the deb(5) manual page. Because this internal format is subject to change (between major releases of Debian), always use dpkg-deb(8) for manipulating .deb files."
</P
><P
>&#13; From the dpkg-deb man page: "dpkg-deb packs, unpacks and provides information about Debian archives.
.deb files can also be manipulated with <TT
CLASS="literal"
>ar</TT
> and <TT
CLASS="literal"
>tar</TT
> alone if necessary.
Use dpkg to install and remove packages from your system."</P
><P
>&#13;
You might find lots of example .deb files in directory '<TT
CLASS="literal"
>/var/cache/apt/archives/</TT
>'.
With '<TT
CLASS="literal"
>dpkg-deb -I somepackage.deb</TT
>' you might get a general overview of
what this package offers in particular. '<TT
CLASS="literal"
>dpkg-deb -c somepackage.deb</TT
>' lists
all files which will be installed.</P
><P
>&#13;
List content of the .deb file with '<TT
CLASS="literal"
>ar tv somepackage.deb</TT
>'. Use the 'x'
option to extract the files.
</P
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN60"
></A
>3. Package Structure</H1
><P
>&#13; Let's examine one example package a little bit closer. E.g. file '<TT
CLASS="literal"
>parted_1.4.24-4_i386.deb</TT
>'
contains these three files:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ ar tv parted_1.4.24-4_i386.deb
rw-r--r-- 0/0 4 Mar 28 13:46 2002 debian-binary
rw-r--r-- 0/0 1386 Mar 28 13:46 2002 control.tar.gz
rw-r--r-- 0/0 39772 Mar 28 13:46 2002 data.tar.gz
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Now we can start to extract all files including the content of the tar files.
</P
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN66"
></A
>3.1. debian-binary</H2
><P
>&#13;The content of this file is "2.0\n". This states the version of the deb file format.
For 2.0 all other lines get ignored.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN69"
></A
>3.2. data.tar.gz</H2
><P
>&#13;The 'data.tar.gz' file contains all the files that will be installed with their
destination paths:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;drwxr-xr-x root/root 0 2002-03-28 13:44:57 ./
drwxr-xr-x root/root 0 2002-03-28 13:44:49 ./sbin/
-rwxr-xr-x root/root 31656 2002-03-28 13:44:49 ./sbin/parted
drwxr-xr-x root/root 0 2002-03-28 13:44:38 ./usr/
drwxr-xr-x root/root 0 2002-03-28 13:44:41 ./usr/share/
drwxr-xr-x root/root 0 2002-03-28 13:44:38 ./usr/share/man/
drwxr-xr-x root/root 0 2002-03-28 13:44:52 ./usr/share/man/man8/
-rw-r--r-- root/root 1608 2002-03-28 13:44:37 ./usr/share/man/man8/parted.8.gz
drwxr-xr-x root/root 0 2002-03-28 13:44:41 ./usr/share/doc/
drwxr-xr-x root/root 0 2002-03-28 13:44:52 ./usr/share/doc/parted/
-rw-r--r-- root/root 1880 2002-03-07 14:20:08 ./usr/share/doc/parted/README.Debian
-rw-r--r-- root/root 1347 2002-02-27 01:40:50 ./usr/share/doc/parted/copyright
-rw-r--r-- root/root 6444 2002-03-28 13:37:33 ./usr/share/doc/parted/changelog.Debian.gz
-rw-r--r-- root/root 15523 2002-03-28 02:36:43 ./usr/share/doc/parted/changelog.gz
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;It must be the last file in the deb archive.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN74"
></A
>3.3. control.tar.gz</H2
><P
>&#13;In our example this file has the following content:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;-rw-r--r-- 1 root root 1336 Mar 28 2002 control
-rw-r--r-- 1 root root 388 Mar 28 2002 md5sums
-rwxr-xr-x 1 root root 253 Mar 28 2002 postinst
-rwxr-xr-x 1 root root 194 Mar 28 2002 prerm
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;'md5sums' contains for each file in data.tar.gz the md5sum. In our example the content looks like this:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;1d15dcfb6bb23751f76a2b7b844d3c57 sbin/parted
4eb9cc2e192f1b997cf13ff0b921af74 usr/share/man/man8/parted.8.gz
2f356768104a09092e26a6abb012c95e usr/share/doc/parted/README.Debian
a6259bd193f8f150c171c88df2158e3e usr/share/doc/parted/copyright
7f8078127a689d647586420184fc3953 usr/share/doc/parted/changelog.Debian.gz
98f217a3bf8a7407d66fd6ac8c5589b7 usr/share/doc/parted/changelog.gz
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Don't worry, the 'md5sum' file as well as the 'postinst' and
'prerm' files are not mandatory for your first package.
But please take a note of their
existence, every proper official Debian package has them
for good reasons.</P
><P
>&#13;
'prerm' and 'postinst' seem to take care of removing old documentation files
and adding a link from doc to share/doc.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
><A
NAME="postinst"
></A
>$ cat postinst
#!/bin/sh
set -e
# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
if [ -d /usr/doc -a ! -e /usr/doc/parted -a -d /usr/share/doc/parted ]; then
ln -sf ../share/doc/parted /usr/doc/parted
fi
fi
# End automatically added section
$ cat prerm
#!/bin/sh
set -e
# Automatically added by dh_installdocs
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/parted ]; then
rm -f /usr/doc/parted
fi
# End automatically added section
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
And finally the most interesting file:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ cat control
Package: parted
Version: 1.4.24-4
Section: admin
Priority: optional
Architecture: i386
Depends: e2fsprogs (&#62;= 1.27-2), libc6 (&#62;= 2.2.4-4), libncurses5 (&#62;= \
5.2.20020112a-1), libparted1.4 (&#62;= 1.4.13+14pre1), libreadline4 (&#62;= \
4.2a-4), libuuid1
Suggests: parted-doc
Conflicts: fsresize
Replaces: fsresize
Installed-Size: 76
Maintainer: Timshel Knoll &#60;timshel@debian.org&#62;
Description: The GNU Parted disk partition resizing program
GNU Parted is a program that allows you to create, destroy,
resize, move and copy hard disk partitions. This is useful
for creating space for new operating systems, reorganizing
disk usage, and copying data to new hard disks.
.
This package contains the Parted binary and manual page.
.
Parted currently supports DOS, Mac, Sun, BSD, GPT and PC98
disklabels/partition tables, as well as a 'loop' (raw disk)
type which allows use on RAID/LVM. Filesystems supported are
ext2, ext3, FAT (FAT16 and FAT32) and linux-swap. Parted can
also detect HFS (Mac OS), JFS, NTFS, ReiserFS, UFS and XFS
filesystems, but cannot create/remove/resize/check these
filesystems yet.
.
The nature of this software means that any bugs could cause
massive data loss. While there are no known bugs at the moment,
they could exist, so please back up all important files before
running it, and do so at your own risk.
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Further information about the control file can be obtained via '<TT
CLASS="literal"
>man 5 deb-control</TT
>'.
</P
></DIV
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN88"
></A
>4. Hands On</H1
><P
>&#13; Now it is time to get practical ourselves.
I have a simple shell script named 'linuxstatus' which I want to install
as '/usr/bin/linuxstatus'.
So first let's create a directory named 'debian' next to the file 'linuxstatus'.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ mkdir -p ./debian/usr/bin
$ cp linuxstatus ./debian/usr/bin
</PRE
></FONT
></TD
></TR
></TABLE
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN92"
></A
>4.1. control</H2
><P
>&#13;Let's start with the control file. The version number must have a dash with
an additional Debian package version number, e.g. '1.1-1'. If your program consists
e.g. only of portable shell scripts, use 'all' as its 'Architecture'.
</P
><P
>&#13;
For 'Depends' you might need to find out to which package a certain file or program
your new package relies onto belongs to.
You can use 'dpkg -S &#60;file&#62;' for this to find this out, e.g.:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ dkpg -S /bin/cat
coreutils: /bin/cat
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Then to find out more about package 'coreutils' you can use
the command 'apt-cache showpkg coreutils', which will tell you
among other things the current version number that is installed
on the system.</P
><P
>&#13;
As a side note, there are two more ways to find the same information.
There is a web page where you can search for Debian files: <A
HREF="http://www.debian.org/distrib/packages"
TARGET="_top"
>http://www.debian.org/distrib/packages</A
>.
Go to the bottom of that page to fill out the web form.</P
><P
>&#13;
Last not least there is a nice GUI application named 'kpackage',
which provides convenient package browsing options and also allows
to search after packages given individual file names.
</P
><P
>&#13;
'Suggests', 'Conflicts', and 'Replaces' etc. can be left out if not needed.
</P
><P
>&#13;So here is the result of our first 'control' file:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>Package: linuxstatus
Version: 1.1-1
Section: base
Priority: optional
Architecture: all
Depends: bash (&#62;= 2.05a-11), textutils (&#62;= 2.0-12), awk, procps (&#62;= \
1:2.0.7-8), sed (&#62;= 3.02-8), grep (&#62;= 2.4.2-3), coreutils (&#62;= 5.0-5)
Maintainer: Chr. Clemens Lee &#60;clemens@kclee.de&#62;
Description: Linux system information
This script provides a broad overview of different
system aspects.</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;The 'control' file gets copied into a directory called 'DEBIAN' inside the other
'debian' directory.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ mkdir -p debian/DEBIAN
$ find ./debian -type d | xargs chmod 755 # this is necessary on Debian Woody, don't ask me why
$ cp control debian/DEBIAN
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;If you expect your package to have a bigger audience in the future
it might help to read this
<A
HREF="http://people.debian.org/~walters/descriptions.html"
TARGET="_top"
>Writing Debian package descriptions</A
>
article.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN108"
></A
>4.2. dpkg-deb</H2
><P
>&#13;Now it is almost done. Just type:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;$ dpkg-deb --build debian
dpkg-deb: building package `linuxstatus' in `debian.deb'.
$ mv debian.deb linuxstatus_1.1-1_all.deb
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Uh, that was all easier than expected. Now we just have to install this package on our box
and we are done:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;root# dpkg -i ./linuxstatus_1.1-1_all.deb
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;Type '<TT
CLASS="literal"
>linuxstatus</TT
>' or '<TT
CLASS="literal"
>ls -l /usr/bin/linuxstatus</TT
>' to see if it worked.
If you don't like your package any more, just type '<TT
CLASS="literal"
>dpkg -r linuxstatus</TT
>'
and check again that the package is deinstalled. If you install a newer version
you don't have to remove the old one first, thought.</P
><P
>&#13;
If you are curious about the version numbering scheme and
naming conventions for a Debian package, have a read at
<A
HREF="http://www.debian.org/doc/manuals/reference/ch-system.en.html#s-pkgname"
TARGET="_top"
>this section</A
> in <A
HREF="http://www.debian.org/doc/manuals/reference/reference.en.html"
TARGET="_top"
>The Debian Reference</A
>.
</P
></DIV
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN121"
></A
>5. Double Check</H1
><P
>&#13; Now that you have gotten a first impression and build your own
binary package, it is time to get a little bit more serious
and have a look at the quality of the package that we have
produced.
</P
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN124"
></A
>5.1. lintian</H2
><P
>&#13; Luckily for us the Debian project provides a 'lint'
like tool for checking Debian packages. This tool is named
'lintian'.
If you have not installed it yet on your system, this is a good moment
(<TT
CLASS="literal"
>apt-get install lintian</TT
>).</P
><P
>&#13;
Now we use this little treasure tool on our new package file:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>$ lintian linuxstatus_1.1-1_all.deb
E: linuxstatus: binary-without-manpage linuxstatus
E: linuxstatus: no-copyright-file
W: linuxstatus: prerm-does-not-remove-usr-doc-link
W: linuxstatus: postinst-does-not-set-usr-doc-link</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Uh, doesn't look so perfect. We miss a man page, copyright
file, and also those 'prerm' and 'postinst' scripts.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN131"
></A
>5.2. Minimal Documentation</H2
><P
>&#13;This is not the place to say much about writing and creating
man pages, there are many books that have one or another chapter
related to this
topic and there is also <A
HREF="http://www.tldp.org/HOWTO/mini/Man-Page.html"
TARGET="_top"
>The Linux MAN-PAGE-HOWTO</A
>
online. So lets do a little time warp and assume you have now
a perfect
man page for your script at location <TT
CLASS="literal"
>./man/man1/linuxstatus.1</TT
>.
</P
><P
>&#13;
The same for a 'copyright' file. You can find enough
examples under the <TT
CLASS="literal"
>/usr/share/doc</TT
> directory
with this command: <TT
CLASS="literal"
>find /usr/share/doc -name "copyright"</TT
>
</P
><P
>&#13;
So here is our own example of a 'copyright' file:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>linuxstatus
Copyright: Chr. Clemens Lee &#60;clemens@kclee.de&#62;
2002-12-07
The home page of linuxstatus is at:
http://www.kclee.de/clemens/unix/index.html#linuxstatus
The entire code base may be distributed under the terms of the GNU General
Public License (GPL), which appears immediately below. Alternatively, all
of the source code as any code derived from that code may instead be
distributed under the GNU Lesser General Public License (LGPL), at the
choice of the distributor. The complete text of the LGPL appears at the
bottom of this file.
See /usr/share/common-licenses/(GPL|LGPL)</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
For the 'prerm' and 'postinst' scripts we copy one to one the
<A
HREF="#postinst"
TARGET="_top"
>examples</A
> from the 'parted' package above
into files with the same name in our own project directory.
These files should work for us just as well.</P
><P
>&#13;
Now we create the debian package again. In the 'control' file
we first increase the version number from 1.1-1 to 1.2-1
(since we have written a new man page we increase our internal
release number).
We also need to copy the new files to their appropriate places:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>$ mkdir -p ./debian/usr/share/man/man1
$ mkdir -p ./debian/usr/share/doc/linuxstatus
$ find ./debian -type d | xargs chmod 755
$ cp ./man/man1/linuxstatus.1 ./debian/usr/share/man/man1
$ cp ./copyright ./debian/usr/share/doc/linuxstatus
$ cp ./prerm ./postinst ./debian/DEBIAN
$ gzip --best ./debian/usr/share/man/man1/linuxstatus.1
$
$ dpkg-deb --build debian
dpkg-deb: building package `linuxstatus' in `debian.deb'.
$ mv debian.deb linuxstatus_1.2-1_all.deb</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Gzip is necessary because lintian expects man page files to be
compressed as small as possible.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN146"
></A
>5.3. fakeroot</H2
><P
>&#13;Now lets see if our package has become a better Debian citizen:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>$ lintian linuxstatus_1.2-1_all.deb
E: linuxstatus: control-file-has-bad-owner prerm clemens/clemens != root/root
E: linuxstatus: control-file-has-bad-owner postinst clemens/clemens != root/root
E: linuxstatus: bad-owner-for-doc-file usr/share/doc/linuxstatus/ clemens/clemens != root/root
E: linuxstatus: bad-owner-for-doc-file usr/share/doc/linuxstatus/copyright clemens/clemens != root/root
E: linuxstatus: debian-changelog-file-missing</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Ups, new complains. OK, we will not give up.
Actually most errors seem to be the same problem. Our files are
all packaged for user and group 'clemens', while
I assume most people would prefer having them installed as
'root/root'. But this is easily fixed using the tool '<EM
>fakeroot</EM
>'.
So lets fix and
check this quickly (while ignoring the changelog issue):
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>$ <EM
>fakeroot</EM
> dpkg-deb --build debian
dpkg-deb: building package `linuxstatus' in `debian.deb'.
$ mv debian.deb linuxstatus_1.2-1_all.deb
$ lintian linuxstatus_1.2-1_all.deb
E: linuxstatus: debian-changelog-file-missing</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Fine, but we have yet another file to add to the package.
</P
></DIV
><DIV
CLASS="sect2"
><HR><H2
CLASS="sect2"
><A
NAME="AEN155"
></A
>5.4. More Documentation</H2
><P
>&#13;Let me tell
you already that next to a 'changelog' file in the 'doc/linuxstatus'
directory
a 'changelog.Debian' file is also required. Both should be gzipped
as well.</P
><P
>&#13;
Here are two example files, 'changelog':
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>linuxstatus (1.2-1)
* Made Debian package lintian clean.
-- Chr. Clemens Lee &#60;clemens@kclee.de&#62; 2002-12-13</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;and 'changelog.Debian':
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>linuxstatus Debian maintainer and upstream author are identical.
Therefore see also normal changelog file for Debian changes.</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
The Debian Policy file has more details regarding
the <A
HREF="http://www.debian.org/doc/debian-policy/ch-miscellaneous.html#s-dpkgchangelog"
TARGET="_top"
>format of the changelog</A
>
file.</P
><P
>&#13;
Now hopefully our last step will be:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>$ cp ./changelog ./changelog.Debian ./debian/usr/share/doc/linuxstatus
$ gzip --best ./debian/usr/share/doc/linuxstatus/changelog
$ gzip --best ./debian/usr/share/doc/linuxstatus/changelog.Debian
$ fakeroot dpkg-deb --build ./debian
dpkg-deb: building package `linuxstatus' in `debian.deb'.
$ mv debian.deb linuxstatus_1.2-1_all.deb
$ lintian linuxstatus_1.2-1_all.deb</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;
Ah, we get no more complains :-). As root you can install
now this
package over the old one, again with the standard '<TT
CLASS="literal"
>dpkg -i</TT
>' command.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>root# dpkg -i ./linuxstatus_1.2-1_all.deb
(Reading database ... 97124 files and directories currently installed.)
Preparing to replace linuxstatus 1.1-1 (using linuxstatus_1.2-1_all.deb) ...
Unpacking replacement linuxstatus ...
Setting up linuxstatus (1.2-1) ...</PRE
></FONT
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN169"
></A
>6. Summary</H1
><P
>&#13; Not to get confused, let us recapture all steps we have taken to
build our binary Debian package.</P
><P
>&#13;
Prerequisite files:
</P
><P
></P
><OL
TYPE="1"
><LI
><P
>one or more binary executable or shell script files</P
></LI
><LI
><P
>a man page for each executable file</P
></LI
><LI
><P
>a 'control' file</P
></LI
><LI
><P
>a 'copyright' file</P
></LI
><LI
><P
>a 'changelog' and 'changelog.Debian' file</P
></LI
></OL
><P
>&#13; Setup temporary 'debian' directories:
</P
><P
></P
><OL
TYPE="1"
><LI
><P
>create '<TT
CLASS="literal"
>debian/usr/bin</TT
>' directory (or wherever you plan to place your executable files)</P
></LI
><LI
><P
>create '<TT
CLASS="literal"
>debian/usr/share/man/man1</TT
>' (or whatever section your man page belongs into)</P
></LI
><LI
><P
>create '<TT
CLASS="literal"
>debian/DEBIAN</TT
>' directory</P
></LI
><LI
><P
>create '<TT
CLASS="literal"
>debian/usr/share/doc/&#60;package_name&#62;</TT
>'</P
></LI
><LI
><P
>make sure all sub directories of '<TT
CLASS="literal"
>debian</TT
>' have file permission 0755</P
></LI
></OL
><P
>&#13; Copy files into temporary 'debian' tree:
</P
><P
></P
><OL
TYPE="1"
><LI
><P
>copy executable file into '<TT
CLASS="literal"
>debian/usr/bin</TT
>' directory (or wherever you plan to place your executable files)</P
></LI
><LI
><P
>copy man page file into '<TT
CLASS="literal"
>debian/usr/share/man/man1</TT
>' directory</P
></LI
><LI
><P
>copy 'control' file into '<TT
CLASS="literal"
>debian/DEBIAN</TT
>' directory</P
></LI
><LI
><P
>copy 'copyright', 'changelog', and 'changelog.Debian' files into '<TT
CLASS="literal"
>debian/usr/share/doc/&#60;package_name&#62;</TT
>'</P
></LI
><LI
><P
>gzip man page, 'copyright', 'changelog', and 'changelog.Debian' files with option '--best' inside the temporary '<TT
CLASS="literal"
>debian</TT
>' tree</P
></LI
></OL
><P
>&#13; Build and check binary Debian package:
</P
><P
></P
><OL
TYPE="1"
><LI
><P
>invoke '<TT
CLASS="literal"
>dpkg-deb --build</TT
>' using '<TT
CLASS="literal"
>fakeroot</TT
>' on the '<TT
CLASS="literal"
>debian</TT
>' directory</P
></LI
><LI
><P
>rename resulting '<TT
CLASS="literal"
>debian.deb</TT
>' file to its final package name including version and architecture information</P
></LI
><LI
><P
>check resulting .deb package file for Debian policy compliance using '<TT
CLASS="literal"
>lintian</TT
>'</P
></LI
></OL
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN231"
></A
>7. What Else</H1
><P
>&#13; There are many details which have not been covered here, like how to distribute
Unix daemons, configuration files and much more.</P
><P
>&#13;
But most important, I want to emphasize again that for Debian
maintainers,
packages are source packages, not binary packages. They never interact directly
with the internals binary packages. In fact only '<TT
CLASS="literal"
>dpkg-deb</TT
>' and '<TT
CLASS="literal"
>dpkg</TT
>' developers
need to know what they are. In fact it is not recommended to do so.
</P
><P
>&#13;
If a developer were to explain someone how to build a Debian package, he
will certainly explain how to make a source package and how to build it.
</P
><P
>&#13;On the other hand, not every developer wants to submit his software
to Debian (yet), but still wants to profit from
the advantages a packaging system like 'dpkg' offers without releasing
package source code. Personally I will release my freeware projects
still as tar.gz files with source code etc. for all kind of platforms,
while I plan to offer more and more '.deb' packages for the convenience
of Debian users who just want to install and use my software.
</P
><P
>&#13;
If someone wants to do the next step to submit a software package to Debian,
you have to move on to study the Debian New Maintainers' Guide as well
as the <A
HREF="http://www.debian.org/doc/debian-policy/"
TARGET="_top"
>Debian Policy Manual</A
>
first. On your undertaking to create a Debian source package, also have
a look at the
<A
HREF="http://lists.debian.org/debian-mentors/"
TARGET="_top"
>debian-mentors</A
>
mailing list to see experienced and
beginning Debian developers interacting with each other and tackling similar
problem you might encounter.
</P
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN242"
></A
>8. Credits</H1
><P
>&#13; Thanks to
</P
><P
></P
><UL
><LI
><P
>Colin Watson for contributing a sentence in the abstract and giving
feedback regarding structure, focus and title of this
HowTo,</P
></LI
><LI
><P
>Bill Allombert for contributing a sentence in the 'What Else' section
and giving feedback reinforcing what Colin had said as well,</P
></LI
><LI
><P
>Santiago Vila for pointing out that 'md' is a local alias and the (Unix)
world has standardized on 'mkdir',</P
></LI
><LI
><P
>Tabatha Marshall from the
<A
HREF="http://www.tldp.org/"
TARGET="_top"
>TLDP</A
>
project for general support,</P
></LI
><LI
><P
>Joey Hess, Carlo Perassi, and Joe Riel for minor corrections,</P
></LI
><LI
><P
>Claudio Cattazzo for conversion of my private xml document to standard
docbook format together which resulted also in a number of minor
corrections and improvements [2003-10-04],</P
></LI
><LI
><P
>Frank Lichtenheld for finding errors introduced
when the HTML pages get generated and for suggesting to
use 'dpkg -S &#60;file&#62;' when looking for a package containing
a certain file [2003-12-13],</P
></LI
><LI
><P
>Hugh Hartmann for translating
<A
HREF="http://it.tldp.org/HOWTO/Debian-Binary-Package-Building-HOWTO/index.html"
TARGET="_top"
>this HOWTO to Italian</A
>
and Claudio Cattazzo for revising the translation [2003-12-13], and</P
></LI
><LI
><P
>Oguz Yarimtepe for translating
<A
HREF="http://www.belgeler.org/howto/dpkg-deb-nasil.html"
TARGET="_top"
>this HOWTO to Turkish</A
> [2005-08-09].</P
></LI
></UL
></DIV
><DIV
CLASS="sect1"
><HR><H1
CLASS="sect1"
><A
NAME="AEN267"
></A
>9. Links</H1
><P
>&#13; <DIV
CLASS="informaltable"
><A
NAME="AEN270"
></A
><P
></P
><TABLE
BORDER="0"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Debian New Maintainers' Guide: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.debian.org/doc/maint-guide/"
TARGET="_top"
>http://www.debian.org/doc/maint-guide/</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Debian: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.debian.org/"
TARGET="_top"
>http://www.debian.org/</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The Debian Reference: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.debian.org/doc/manuals/reference/reference.en.html"
TARGET="_top"
>http://www.debian.org/doc/manuals/reference/reference.en.html</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Debian Packages: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.debian.org/distrib/packages"
TARGET="_top"
>http://www.debian.org/distrib/packages</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Writing Debian package descriptions: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://people.debian.org/~walters/descriptions.html"
TARGET="_top"
>http://people.debian.org/~walters/descriptions.html</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The Linux MAN-PAGE-HOWTO: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.tldp.org/HOWTO/mini/Man-Page.html"
TARGET="_top"
>http://www.tldp.org/HOWTO/mini/Man-Page.html</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Debian Policy Manual: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.debian.org/doc/debian-policy/"
TARGET="_top"
>http://www.debian.org/doc/debian-policy/</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Debian Mentors: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://lists.debian.org/debian-mentors/"
TARGET="_top"
>http://lists.debian.org/debian-mentors/</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>The Linux Documentation Project: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.tldp.org/"
TARGET="_top"
>http://www.tldp.org/</A
>
</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Plug: my own little Unix page: <20></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13; <A
HREF="http://www.kclee.de/clemens/unix/"
TARGET="_top"
>http://www.kclee.de/clemens/unix/</A
>
</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
</P
></DIV
></DIV
></BODY
></HTML
>