Ubuntu Reference

The basics of maintaining an Ubuntu repository & packages.

Creating a deb
Creating a custom repo
Maintaining a custom repo
Setting a client to use the custom repo

Creating a deb

.deb files are very similar to .rpms both are [generally] binary packages that contain requirements & any configuration to install

For this guide we will include all steps to make the .deb suitable for inserting into a repository, however many steps can be skipped for just creating a standalone deb.

You will need:

Structure


debian/
debian/debian -> debian/
debian/control * required
debian/changelog * required [Can be generated]
debian/files * required [Can be generated]
debian/rules * required 
debian/tmp/
debian/tmp/DEBIAN/
debian/tmp/DEBIAN/
debian/tmp/DEBIAN/postinst * required
debian/tmp/DEBIAN/prerm * required
debian/tmp/DEBIAN/... any other installation related script
debian/tmp/usr/
debian/tmp/usr/local/
debian/tmp/usr/local/bin/
debian/tmp/usr/local/bin/vpnclient
debian/tmp/.. any other file that should be apart of the installation
Because of the way that some tools work I needed to setup a symlink:
 # ln -s . debian/debian 
All commands should be executed in the parent directory to debian for the rest of this document (except creating the deb by hand).

Control Files


The control file is just like a SPEC file basic information about a package is stored here: author, links, version, category, etc. However, any installation scripts are located in seperate files, not the control file.
An Example of a control file:
Source: vpnclient-linux
Maintainer: Andrew Muraco, 
Section:net
Priority: optional

Architecture: all
Package: vpnclient-linux
Version: 4.8.01.0640
Pre-Depends: linux-headers
Description: Cisco VPN Client with necessary pcf's for UB VPN.
	This Cisco VPN client includes the necessary configuration files
	to connect to the University at Buffalo's VPN servers.
Prerequisites for the deb can be defined by multiple levels, depending the extent the package needs another package. Depends, Enhances, Pre-Depends, Recommends, and Suggests. Other inter-package relationships can be defined: Replaces & Conflicts.

Installation scripts


Installation Scripts are simply bash scripts that are executed based on the name. At a minimium, you will need to provide a post-installation and a pre-uninstallation script. If your package truely does not need these, then be sure to have a placeholder dummy script for each.

Changelog, Rules, Files


These three files enable a package maintainer to reuse buliding instructions and track changes for quick repackaging and revision release, If you don't intend on having the package on multiple architectures or distributing the package in a repo, these files are not needed, and the control file can be placed manually into debian/tmp/DEBIAN/ before packaging by hand.
  • Changelog
    The changelog file can be automaticly generated and any time that a new version or change to the package is made, an addition to the changelog and the version number can be incremented.
    # debchange --create 
    The --create is only needed the first time, which will open up the
    change log file in a text editor so that the package name, version 
    and other details can be initalized.
    Example:
    # debchange --create Fixed post installation module buliding
    Our file looks like this:
    
    vpnclient-linux (4.8.01.0640-ub1) gutsy; urgency=low
    
    	* Initial deb release
    	* Fixed post installation module buliding
    
    	-- Andrew Muraco   Tue, 05 Feb 2008 16:56:24 -0500
    
  • Rules
    The rules tells the package bulider what to do when we want to actually bulid the package. In our case we don't need to do anything besides create the deb, in other instances we would want to run commands like make and ./configure before creating the deb.
    #!/bin/bash
    VERSION="4.8.01.0640-ub1"
    case "$1" in
    	build)
    		echo "nothing to do"
    		;;
    	clean)
    		rm vpnclient-linux_${VERSION}_all.deb
    		;;
    	binary)
    		dpkg -b debian/tmp vpnclient-linux_${VERSION}_all.deb
    		;;
    esac
    exit 0
    
  • File
    Contains the list of files that are part of the package. In our case, it is just the single .deb file.

Creating the final .deb by hand.


Just like RPMs the final step to make a deb is to run the packaging software to create the package.
# dpkg -b fakeroot/ vpnclient.deb
dpkg -b (for --bulid) directory packagename.deb

To Test the deb:
# dpkg -i vpnclient.deb

Creating a custom repo

Either on the PC hosting the repo OR on a PC that will be used to Maintain the repo, you will need these tools:
  • pbulider
  • dput
  • mini-dinstall

  • If you are going to maintain and sync the repo to another server, then rsync is the recommended method to maintain the remote.

    dput

    * Create $HOME/.dput.cf with the following content:
    [local]
    fqdn = localhost
    method = local
    incoming = /ubitrepo/mini-dinstall/incoming
    allow_unsigned_uploads = 1
    post_upload_command = mini-dinstall --batch
    

    * Create the required directories

    $ mkdir -p /ubitrepo/mini-dinstall/incoming
    

    mini-dinstall

    * Create $HOME/.mini-dinstall.conf with the following content:

    [DEFAULT]
    architectures = all, i386
    archivedir = /ubitrepo/
    use_dnotify = 0
    verify_sigs = 0
    extra_keyrings = ~/.gnupg/pubring.gpg
    mail_on_success = 0
    archive_style = flat
    poll_time = 40
    mail_log_level = NONE
    generate_release = 1
    release_description = UB's Custom software repository
    
    [gutsy]
    
  • Distribution Groups

    • If you plan on maintaining different repositories for different versions of Ubuntu, then add any custom configuration under the code name header, [gutsy]. For example if you set in your /debian/changelog as distribution "gutsy" the package will be moved into the gutsy distribution.

    Now your Repo is ready to accept packages!

    Maintaing a custom repo

    After creating the deb and a changes file {TODO: Add .changes file details}, we can simply tell dput to insert the package into the local repo:
    # dput local vpnclient.changes
    
    If we are maintaining a copy that is hosted on another server, then we should use rsync on our repo to update the remote server after adding the new package.
    # scp -r /ubit/. amuraco@ubunix.buffalo.edu:/net/wings/info/www/computing/ublinux/ubuntu/.
    

    Setting a client to use a custom repo

    $ sudo vi /etc/apt/sources.list
    
    and add the following lines to it (please replace $HOME with the correct pathname to your home):
    
    deb http://wings.buffalo.edu/computing/ublinux/ubuntu gutsy/
    deb-src http://wings.buffalo.edu/computing/ublinux/ubuntu gutsy/
    
    After adding these two lines, update your local apt cache:
    
    $ sudo apt-get update
    

    Links

    https://help.ubuntu.com/community/PythonRecipes/DebianPackage - Control file Example & Packaging
    http://linuxdevices.com/articles/AT8047723203.html - Detailed Control file creation
    Back to Technical Documentation index

    Send Questions and Comments to ublinux-support@buffalo.edu

    Last Modified January 16th, 2008