Package installation without a remote repository

How to manage Debian program packages locally without an official package repository

In these days, many developers offer their programs outside of the official package repositories via file downloads and installation by means of dpkg. However, existing dependencies cannot be resolved during installation with dpkg. The local-apt-repository package can help here.

The standard tools for installing and uninstalling programs on Debian-based Linux systems are dpkg and apt. While dpkg ("debian package") is the basic program for installing and manipulating Debian binary packages, apt ("advanced packaging tool") offers a convenient interface to dpkg and additional options such as searching for, downloading and resolving package dependencies - functions that dpkg cannot handle on its own. apt can therefore be seen as a user-friendly front end to dpkg which is working in the background.

To install Debian binary packages that do not come from a Debian repository, it is possible to install them with the command dpkg -i <packagename>. This, however, only works well if there are no dependencies on packages that are not yet installed on the computer. If such dependencies exist, they must be resolved with the command apt-get -f install afterwards.

This step can be omitted if you install and use the package local-apt-repository. A positive side effect is that this way Debian binary packages that were downloaded without a package repository are clearly stored in one dedicated directory and not in possibly different locations on the computer.

The package local-apt-repository is installed as usual with apt-get. The only thing to do after the installation is to create the directory /srv/local-apt-repository/, because as you can see, during installation a systemd service is implemented that monitors this directory for changes:

$ sudo apt-get install local-apt-repository
Preparing to unpack .../local-apt-repository_0.4+deb9u1_all.deb ...
Unpacking local-apt-repository (0.4+deb9u1) ...
Setting up local-apt-repository (0.4+deb9u1) ...
Created symlink /etc/systemd/system/
 → /lib/systemd/system/local-apt-repository.path
$ cat /lib/systemd/system/local-apt-repository.service 
Description=Local apt repository recreation
$ cat /lib/systemd/system/local-apt-repository.path
$ sudo mkdir -p /srv/local-apt-repository

As soon as a Debian binary package is saved in this directory, the script /usr/lib/local-apt-repository/rebuild starts in the background, which uses the apt-ftparchive program to store the metadata for this package in the /var/lib/local-apt-repository/ directory. This in turn has been added to the list of package sources in /etc/apt/sources.d/ during the installation of local-apt-repository.

After the usual apt-get update, the Debian binary package can now be installed with apt-get including automatic resolution of the dependencies.

The original binary package will be kept in the directory /srv/local-apt-repository/ for further reference.