Friday, 17 June 2011

Ubuntu packages and repositories

Creating Ubuntu (debian) packages always seems a bit fiddly....At the moment I can do it, so thought I'd better write down quickly how I did it.


  • Create a directory and put the files you want to install into a directory tree under it (e.g. if you create a directory called [pkgname], files that you want in /usr/local/bin go in [pkgname]/usr/local/bin.
  • Create a directory called [pkgname]/DEBIAN and put a file in it called 'control'.  This can be as simple as:
Package: grahamstestdeb
Version: 001
Architecture: i386
Maintainer: Graham Jones (
Description: Test Debian Package

  • Create a file called 'postinst' in DEBIAN.  This will be executed when the package is installed. This can be
  • #!/bin/sh
  • echo "postinst works!!!!"
  • Create the .deb package by doing
dpkg-deb --build [pkgname]
  •  Copy your new [pkgname].deb file into a new folder called repository.
  • Run 'sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz' in the repostitory directory.
  • Upload the repository directory to your web server:
ncftpput -v -R -u -p public_html/apt/ *

  • Add the following to /etc/apt/sources.lst 
deb / 

  • Run sudo apt-get update
  • Run sudo apt-cache search [pkgname] - should find your package.
  • Run sudo apt-get install [pkgname] - should run your postinst script.
For better instructions see:
Post a Comment