Contents

The new, and easy way

In an Ubuntu system, just use the default option gdebi. It'll download dependencies (from the Ubuntu archives) for you.

On the command line (on a server, for example), you can say:

gdebi postgresql_7.4.5-3_i386.deb

Installing a .deb using dpkg

You can always install any .deb file using dpkg, for example:

dpkg -i postgresql_7.4.5-3_i386.deb

This will however not check any dependencies, and if the package you are installing depends on another package, dpkg will install it but will fail to configure it. You will then have to resolve dependencies manually, and it is also possible that apt might refuse to install anything else until you've cleared up this problem manually.

For this reason you may prefer not to bypass apt.

Using apt to install one or more .deb files (quick and dirty solution)

First create a directory where you will place all your .deb files. For this example, I will use /home/debs. Copy all .deb files to this directory. Change into this directory:

cd /home/debs

Create a Packages.gz file with this command:

dpkg-scanpackages . /dev/null | gzip -c -9 > Packages.gz

Edit to your sources.list file and add a line like this:

deb file:///home/debs /

Update your package lists:

apt-get update

Now you can install your package with apt-get

A slightly more complex solution

Personally I prefer to not place all my debs in a single directory, instead I split them up by package. To save myself from having to edit sources.list everytime I add a new package, I have a script that generates Packages.gz from all the files in subdirectories one level deep. First I create my toplevel directory for all deb files, lets call it /hom/debs again. Then within this directory I create:

/home/debs/postgresql
/home/debs/tcl8.4
/home/debs/tk8.4
/home/debs/ucf

I now add all the .deb files for each package to their respective directories. In /home/debs I create this script, called update.sh:

#!/bin/sh
find . -type d -mindepth 1 -maxdepth 1 | cut -c3- | while read d; do
    dpkg-scanpackages $d /dev/null
done | gzip -c -9 > Packages.gz

And add a line to /etc/apt/sources.list:

deb file:///home/debs /

Whenever I add packages to my repository, I only need to create a directory, add debs to it, and run ./update.sh in /home/debs, followed by apt-get update. After that I can use apt-get install to install my package. What is more, if I share /home/debs by http or ftp, other machines on my network can use the repository as is.

The override file

In the above examples you will notice that I used /dev/null as the second parameter to dpkg-scanpackages. The second parameter should be the so-called override file. The override file allows the distribution maintainer to set sections and priorities for each package.

First let me explain that every debian package has a priority and a section by which it is categorised. Priority is usually important, extra, optional or even base if it is part of the base installation. Section will be something like mail, misc, web or something that explains what the package does. The Section and Priority of a package is specified by the package maintainer and embedded in the package. You can see this information by typing for example:

dpkg --info postgresql_7.4.5-3_i386.deb

This is where the override file comes in. The package maintainer and the distribution maintainer may have different ideas about which Section and/or Priority a package belongs to. The override file allows the distribution maintainer to override the package maintainer's settings.

The override file is a simple three column file:

package priority section

So for my postgresql example I would add a line like this:

postgresql optional misc

The actual override files are not on the distribution CDs, but ubuntu's can be found at mirror sites like http://mirror.x10.com/mirror/ubuntu/indices/ or a google for "override ubuntu indices"

Final Solution

Similar to the second solution above, I once again create /home/debs, with subdirectories in it for each package. This time however, I also add a override file (which is aptly called "override") to every directory. The above script is then extended to use the correct override file for each package:

#!/bin/sh
find . -type d -mindepth 1 -maxdepth 1 | cut -c3- | while read d; do
    dpkg-scanpackages $d $d/override
done | gzip -c -9 > Packages.gz

Adding a new package now consists of:

  1. Create a directory for my package in /home/debs
  2. Copy my new deb files into this directory (hereafter called the package directory)
  3. Create an override file with one line for every package in the package directory, and place it in the package directory
  4. cd /home/debs
  5. ./update.sh
  6. apt-get update
  7. apt-get install package

This page was last modified on 29 October 2007, at 16:28. This page has been accessed 29,040 times.

  
Powered by MediaWiki

Copyright © 1999-2009, Cape Linux Users Group | All contents are under GNU Free Documentation Licence | For all queries, join our mailing lists!