arminstraub.com

Handling Debian packages

Compiled below for personal use are a few random examples of dealing with Debian packages.

Setting A Package On Hold

There are reasons for not wanting to automatically upgrade a package, for instance if you know the new version to be buggy. In that situation you want to put this package on hold.

$ echo packagename hold | dpkg --set-selections

An apt-get dist-upgrade now won't update this package anymore. To release a package from hold again:

$ echo packagename install | dpkg --set-selections

To learn about the packages that are on hold:

$ dpkg --get-selections

Local Repository

Individual packages can be installed via dpkg -i package.deb. This won't, however, take care of dependencies. If you have lots of those packages you might want to have a local repository that you can add to sources.list and use in conjunction with commands as apt-get dist-upgrade.

$ mkdir repository
$ cd repository
user:~/repository $ mkdir binary
user:~/repository $ mkdir source

Now, you can copy .deb packages to binary and source files as .dsc, .orig.gz, .diff.gz to source. Then you need to generate information about these files:

user:~/repository $ dpkg-scanpackages binary /dev/null \
> | gzip -9c > binary/Packages.gz
user:~/repository $ dpkg-scansources source /dev/null \
> | gzip -9c > source/Sources.gz

Finally, to make the freshly created repository available to e.g. apt-get we add the following to /etc/apt/sources.list: deb file:///data/repository binary/ deb-src file:///data/repository source/

Downgrading A Package

To install a particular version of a package:

$ sudo apt-get install packagename=version

Older versions of packages can be found for example at http://snapshot.debian.net.

Typical Errors

When you use packages from third-parties that are not official part of a distribution it's likely that you run into errors. For instance,

$ apt-get install ...
...
dpkg: error processing packageX.deb (--unpack):
 trying to overwrite `...', which is also in package ...
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
 packageX.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Then you can work around as:
$ dpkg -i --force-overwrite packageX.deb