Penguin

Debian Packaging and System Administration in Ruby

This presentation was on March 7, 2011 at the OSS building in Grafton Road. First, we built packages. These packages were built on Ubuntu (Maverick) but the Debian process is probably similar.

The steps below for building a package from scratch is heavily based on Daniel Holbach's excellent tutorial videos. He has quite a few videos on YouTube that illustrate many aspects of packaging for Ubuntu. The first of these is here: http://www.youtube.com/watch?v=zKLabbXTqMc

Checkinstall

Here are the steps for wrapping up a source package into a Deb using Checkinstall.


wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.6p3.tar.gz
tar zxvf ntp-4.2.6p3.tar.gz
cd ntp-4.2.6p3
./configure
make

# stop!
# checkinstall will "make install"

# copy files you want distributed with the package
mkdir doc-pak
cp README INSTALL COPYING ChangeLog TODO doc-pak

# you can now add scripts to be run during install:
#
# preinstall-pak        Run BEFORE the package is INSTALLED
# postinstall-pak       Run AFTER the package is INSTALLED
# preremove-pak         Run BEFORE the package is REMOVED
# postremove-pak        Run AFTER the package is REMOVED

sudo su
checkinstall

# Checkinstall will ask for a package description
# Change maintainer if you so desire

less ntp_4.2.6p3-1_i386.deb
dpkg -L ntp

# to remove: apt-get remove ntp

The Full Package

These are the steps we followed to produce a complete Ubuntu package.

Set up environment
------------------
apt-get install devscripts build-essential fakeroot debhelper gnupg pbuilder dh-make lzip

vi ~/.bashrc
#       export DEBEMAIL="leslie.viljoen@gmail.com"
#       export DEBFULLNAME="Leslie Viljoen"

source ~/.bashrc
export | grep DEB

gpg --gen-key   #use defaults, enter name, email, password
gpg --list-keys

# you can now upload your key on launchpad.net
# good idea: backup your key (Ubuntu One?) and remember password

vi ~/.pbuilderrc
#       COMPONENTS="main restricted universe multiverse"

sudo pbuilder create            #169 MB in /var/cache/pbuilder


Create package
--------------
# almost same process: watch Daniel's vids
# vids are slightly out of date

wget ftp://ftp.gnu.org/pub/gnu/ed/ed-1.5.tar.lz
tar xvf ed-1.5.tar.lz

# this archive name is very important...
# you must use underscore and .orig
# you must make a gzipped tar
tar czf ed_1.5.orig.tar.gz ed-1.5

cd ed-1.5
head COPYING
dh_make -s -c gpl3   #single package, gpl license
cd debian
rm *.ex *.EX docs info README.Debian README.source

vi changelog
#       version -> 1.5.1-0ubuntu1
#       maverick
#       Initial release (no bugs closed)
#       Repacked .tar.lz to .tar.gz, no other changes

vi control
#       section: editors
#       remove stuff
#       copy in Description from README

vi copyright     #critical!
#       downloaded: ftp://ftp.gnu.org
#       less authors
#       find . -name '*.c'|xargs grep Copyright

cd ..           #package directory (ed-1.5)
debuild -S -sa    #source only package, include orig src

# may change things and run debuild again
# man pages all over, millions of options
# produces:
#       new source .tar.gz
#       .dsc file, tying .orig to new source .tar.gz
#       debuild used to make .diff, now see:
#       http://wiki.debian.org/Projects/DebSrc3.0
#

cd ..           #to where new .dsc file is
sudo pbuilder build ed_1.5-0ubuntu1.dsc
less /var/cache/pbuilder/result/ed_1.5-0ubuntu1_i386.deb

# depends has been created for us
# this is very simple, you have to add a lot more
# stuff to make a real package: mostly documentation
# you'll be communicating with upstream and ubuntu
# irc: #ubuntu-motu on freenode

Modifying a Package

We did not show these steps in the presentation, but they can be followed to introduce a small change into an existing package.


# make sure you have a source repos in /etc/apt/sources.list
grep deb-src /etc/apt/sources.list

apt-get source tango-icon-theme-extras
# the source has been extracted and ubuntu diff applied
# according to the dsc file

cd tango-icon-theme-extras-0.1.0
vi debian/control
#       update standards to 3.7.3
#       add Homepage field

# now document changes
dch -i

# to upload to Ubuntu, build source package
# because its a patch, do not force including of original source (-sa)
debuild -S

# to build binary for yourself
apt-get build-dep tango-icon-theme-extras
debuild

# to install
cd ..
sudo dpkg -i tango-icon-theme-extras_0.1.0-0ubuntu5_all.deb

# if dependencies were missing, apt can pull them in
# automatically and complete the installation:
sudo apt-get -f install