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'.
4.1. control
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'.
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 <file>' for this to find this out, e.g.:
$ dkpg -S /bin/cat
coreutils: /bin/cat
|
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.
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: http://www.debian.org/distrib/packages.
Go to the bottom of that page to fill out the web form.
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.
'Suggests', 'Conflicts', and 'Replaces' etc. can be left out if not needed.
So here is the result of our first 'control' file:
Package: linuxstatus
Version: 1.1-1
Section: base
Priority: optional
Architecture: all
Depends: bash (>= 2.05a-11), textutils (>= 2.0-12), awk, procps (>= \
1:2.0.7-8), sed (>= 3.02-8), grep (>= 2.4.2-3), coreutils (>= 5.0-5)
Maintainer: Chr. Clemens Lee <clemens@kclee.de>
Description: Linux system information
This script provides a broad overview of different
system aspects. |
The 'control' file gets copied into a directory called 'DEBIAN' inside the other
'debian' directory.
$ 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
|
If you expect your package to have a bigger audience in the future
it might help to read this
Writing Debian package descriptions
article.
4.2. dpkg-deb
Now it is almost done. Just type:
$ dpkg-deb --build debian
dpkg-deb: building package `linuxstatus' in `debian.deb'.
$ mv debian.deb linuxstatus_1.1-1_all.deb
|
Uh, that was all easier than expected. Now we just have to install this package on our box
and we are done:
root# dpkg -i ./linuxstatus_1.1-1_all.deb
|
Type 'linuxstatus' or 'ls -l /usr/bin/linuxstatus' to see if it worked.
If you don't like your package any more, just type 'dpkg -r linuxstatus'
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.
If you are curious about the version numbering scheme and
naming conventions for a Debian package, have a read at
this section in The Debian Reference.