Living on Ubuntu - Instance #2 - Creating a new package
• 406 words • 2 min • updated
These are notes from a few weeks ago when I created a sample package for Ubuntu. This article is written both as a guide and a timeline. There is no explicit tutorial here, so get your feet wet by yourself, and make sure to follow the references. Edit: enumeration became a mess here. Sorry for that.
Initial setup #
- Introduction; Packaging new software for Ubuntu; Debian Packaging Tutorial
- Get a couple of packages for packaging (duh):
sudo aptitude install gnupg pbuilder ubuntu-dev-tools bzr-builddeb apt-file packaging-dev- Make sure you have a PGP key.
- Send your PGP key to Ubuntu servers.
gpg --send-keys --keyserver keyserver.ubuntu.com <KEY ID>- Make sure you have a SSH key.
Building environment #
- Create a clean build environment:
pbuilder-dist <release> createAt the time of this post, I used ’trusty’ as the release name.
- Make sure you have a Launchpad account.
- Update your Launchpad information and upload both your SSH and your GPG key into there.
- Identify yourself with bzr.
bzr whoami "Bob Dobbs [subgenius@example.com](mailto:subgenius%40example.com)"
bzr launchpad-login subgeniusCreating the package #
- Start a new package, and choose its type to create a new template.
bzr dh-make hello 2.7 hello-2.7.tar.gz- Explore and edit the files of your new template. In particular, see the
debiandirectory. bzr addandcommityour changes. This is a DVCS such asgit, so this should feel familiar.
Building and testing #
- Building the package:
bzr builddeb -- -us -ucThe previous flags tell the system not to use GPG. -nc might also be useful:
it tells the system not to start from scratch.
- To view the contents of a package:
lesspipe *.deb- To install / remove your new built package:
sudo dpkg -i *.deb # attention to the architecture of your package!
sudo dpkg -r <name-of-your-package>An alternative is to invoke sudo debi.
- Check for errors.
lintian *.dsc *.debOptional testing with chroot #
- Next (optional; just to test the package in the chroot you have set up before, with
pbuilder)
bzr builddeb -S
cd ../build-area
pbuilder-dist trusty build *ubuntu*.dscUpload #
- Upload your package to Launchpad:
dput ppa:<your-launchpad-username>/<your-ppa-name> *.changesIf you wanted to create a pull request instead:
bzr push lp:~<launchpad-username>/+junk/hello-packageAnd that’s it! Then just share your PPA with your friends and clients. I hope this guide could serve to you as a quick reference of creating a new Ubuntu (or even Debian) package.