Looking at a Debian Package

mostis a simple package with one binary, a man page, and a little bit of additional documentation.

We can download the Debian source, apply the diff to the upstream source code (apt-get source packagename) and then look at the contents. In the debian subdirectory, we'll find the following files:

postinst and prerm will be run after installation and before being removed--pretty clear from the names. The copyright file is very important for any Debian package as it describes the license. I'm going to assume that if you are making this file yourself, you have the legal right to use the software. The three important files here are control, changelog, rules, and to a lesser degree, dirs.

control file

Source: most
Section: text
Priority: optional
Maintainer: Benjamin Hill (Mako) 
Build-Depends: debhelper, slang1-dev

Package: most
Architecture: any
Depends: ${shlibs:Depends}
Description: a more/less paging type program
 Most is a paging program that displays, one windowful at a time, the
 contents of a file on a terminal. It pauses after each windowful and
 prints on the window status line of the screen the file name, current
 line number, and the percentage of the file so far displayed.
 Unlike other paging programs, most is capable of displaying an
 arbitrary number of windows as long as each window occupies at least
 two screen lines. Each window may contain the same file or a different
 file. In addition, each window has its own mode.
 In addition to displaying ordinary text files, most can also display
 binary files as well as files with arbitrary ascii characters.

There are other types of fields you can put in a control files as well. Most notably for this bare-bones discussion is the Conflicts: line.

changelog file

most (4.9.2-3) unstable; urgency=low

  * Fixes bug with long lines in wrap mode. Closes: #123008, #116147

 -- Benjamin Hill (Mako)   Mon,  8 Apr 2002 21:45:16 -0400

most (4.9.2-2) unstable; urgency=low

  * Fixes bugs with configuration files introduced by changes in the most
    recent upstream versions. Closes: #112704, #110491.

 -- Benjamin Hill (Mako)   Wed,  7 Nov 2001 20:53:24 -0500

rules file

#!/usr/bin/make -f
CC = gcc
CFLAGS = -O2 -g -Wall

install_binary= install -s -o root -g root -m 755
install_script= install    -o root -g root -m 755
install_files=  install    -o root -g root -m 644

# The next section may have to be extensively modified

build: build-stamp
        @echo "Building the binaries ..."
        CC="$(CC)" CFLAGS="$(CFLAGS)" ./configure
        $(MAKE) SYS_INITFILE=/etc/most.conf
        touch $@

        @echo "Cleaning up after a build ..."
        -rm -f build-stamp src/config.h
        -$(MAKE) -i distclean
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:    build
        dh_testdir -a
        dh_testroot -a
        dh_clean -k -a
        @echo "Making the binary package: $(p)-$(version)-$(debian).deb ..."
        dh_installdirs -a
        dh_installchangelogs -a changes.txt
        dh_installdocs -a debian/copyright README lesskeys.rc most-fun.txt most$        dh_installmanpages -a
        $(install_binary) src/objs/most debian/tmp/usr/bin/most

        dh_compress -a
        dh_shlibdeps -a
        dh_installdeb -a
        dh_fixperms -a
        dh_md5sums -a
        dh_gencontrol -a
        dh_builddeb -a

# Below here is fairly generic really.

binary: binary-indep binary-arch

Buildling your Package

Useful Tools

Starting off..

Modify the Source

Modify and Configure your ./debian directory

You'll be working on the files we looked at above. You'll want to pay special attention to the debian/rules files that you'll be using to build you package automatically.

Build the Package

Useful Links:

Mako Hill