wiki:Linux/Ubuntu/Packages/PackagingTips

Packaging Tips

This is a collection of shell commands and other useful fragments that come in useful when preparing a package.

Unsatisfied Build Dependencies

If you see something like:

sudo apt-get build-dep tracker

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Build-dependencies for tracker could not be satisfied.

Enable additional debug reporting. In this case it reveals that some custom packages I installed to fix bugs in other packages are conflicting with the current package's build-depends:

sudo apt-get -o Debug::pkgProblemResolver=true build-dep tracker

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Starting
Starting 2
Investigating libcairo2-dev
Package libcairo2-dev has broken dep on libcairo2
  Considering libcairo2 1222 as a solution to libcairo2-dev 9
  Holding Back libcairo2-dev rather than change libcairo2
Investigating libpango1.0-dev
Package libpango1.0-dev has broken dep on libcairo2-dev
  Considering libcairo2-dev 9 as a solution to libpango1.0-dev 7
  Holding Back libpango1.0-dev rather than change libcairo2-dev
Investigating libgtk2.0-dev
Package libgtk2.0-dev has broken dep on libcairo2-dev
  Considering libcairo2-dev 9 as a solution to libgtk2.0-dev 6
  Holding Back libgtk2.0-dev rather than change libcairo2-dev
Investigating libgail-dev
Package libgail-dev has broken dep on libgtk2.0-dev
  Considering libgtk2.0-dev 6 as a solution to libgail-dev 1
  Holding Back libgail-dev rather than change libgtk2.0-dev
Investigating libgnomeui-dev
Package libgnomeui-dev has broken dep on libgtk2.0-dev
  Considering libgtk2.0-dev 6 as a solution to libgnomeui-dev 1
  Holding Back libgnomeui-dev rather than change libgtk2.0-dev
Investigating libgnomecanvas2-dev
Package libgnomecanvas2-dev has broken dep on libgtk2.0-dev
  Considering libgtk2.0-dev 6 as a solution to libgnomecanvas2-dev 1
  Holding Back libgnomecanvas2-dev rather than change libgtk2.0-dev
Investigating libbonoboui2-dev
Package libbonoboui2-dev has broken dep on libgnomecanvas2-dev
  Considering libgnomecanvas2-dev 1 as a solution to libbonoboui2-dev 0
  Holding Back libbonoboui2-dev rather than change libgnomecanvas2-dev
Investigating libglade2-dev
Package libglade2-dev has broken dep on libgtk2.0-dev
  Considering libgtk2.0-dev 6 as a solution to libglade2-dev 0
  Holding Back libglade2-dev rather than change libgtk2.0-dev
Investigating libpoppler-glib-dev
Package libpoppler-glib-dev has broken dep on libcairo2-dev
  Considering libcairo2-dev 9 as a solution to libpoppler-glib-dev 9999
    Reinst Failed early because of libcairo2
  Considering libcairo2-dev 9 as a solution to libpoppler-glib-dev 9999
Package libpoppler-glib-dev has broken dep on libpango1.0-dev
  Considering libpango1.0-dev 7 as a solution to libpoppler-glib-dev 9999
    Reinst Failed because of libcairo2-dev
  Considering libpango1.0-dev 7 as a solution to libpoppler-glib-dev 9999
Investigating libnotify-dev
Package libnotify-dev has broken dep on libgtk2.0-dev
  Considering libgtk2.0-dev 6 as a solution to libnotify-dev 9999
    Reinst Failed because of libcairo2-dev
  Considering libgtk2.0-dev 6 as a solution to libnotify-dev 9999
Investigating libgnome-desktop-dev
Package libgnome-desktop-dev has broken dep on libgnomeui-dev
  Considering libgnomeui-dev 1 as a solution to libgnome-desktop-dev 9999
    Reinst Failed because of libgtk2.0-dev
    Reinst Failed because of libglade2-dev
    Reinst Failed because of libbonoboui2-dev
  Considering libgnomeui-dev 1 as a solution to libgnome-desktop-dev 9999
Done
E: Build-dependencies for tracker could not be satisfied.

Validating Signing Keys

Add to the environment variables in ~/.devscripts so you have the default signing key set, and the keyring to be used by dscverify (this helps dpkg-source, dget, prevu and others as well):

DEBSIGN_KEYID="29CD6080"
DEBSIGN_PROGRAM="gpg --use-agent"
DEBSIGN_SIGNLIKE="gpg"

# for dscverify, called from prevu and others
DSCVERIFY_KEYRINGS=~/.gnupg/pubring.gpg

Add helpers to easily fetch unknown keys. Enhance ~/.bashrc with:

export DEBEMAIL="ubuntu@tjworld.net"
export DEBFULLNAME="TJ"
export KEYS_UBUNTU=hkp://keyserver.ubuntu.com
export KEYS_DEBIAN=hkp://keyring.debian.org

# use ' not " to prevent the variables being expanded until run-time
alias getkeyd='gpg --keyserver $KEYS_DEBIAN --recv-key '
alias getkeyu='gpg --keyserver $KEYS_UBUNTU --recv-key '

When an unknown key is encountered try fetching from Debian and Ubuntu keyrings:

KEYID="xyz"
getkeyd $KEYID || getkeyu $KEYID

Testing man pages

Testing a man-page to ensure the formatting works as intended is often overlooked. When in the source directory here is an easy way to test the page immediately (in this case for the package red5):

$ MANPAGE=red5.1
$ gzip -c debian/${MANPAGE} | sudo tee /usr/share/man/man${MANPAGE##*.}/${MANPAGE}.gz >/dev/null

$ man red5

Holding a Specific Version

Preventing a package being upgraded is useful when you have various PPA repositories enabled that publish 'later' versions that the installed package.

PACKAGE="flashplugin-nonfree"
echo "${PACKAGE} hold" | sudo dpkg --set-selections

Regenerating debian/control from debian/control.in

fakeroot debian/rules debian/control DEB_AUTO_UPDATE_DEBIAN_CONTROL:=yes