2018-12-17

Ubuntu: force reinstallation of package in ubuntu

This post describes how to reinstall a package in Ubuntu (or Linut Mint, or other Ubuntu derivatives, and possibly on Debian, but I did not test it).

I needed to remove a package that was installed in the system which came from a non-standard repository.   However there were many others that depended on it, so I could not simply remove it.

It wasn't practical to remove them all, but I needed to replace the package with a version from the official Ubuntu repository.

This is the way I found to do it.    I found the answer in this post:

First, check available versions to be able to force a particular one:

apt-cache madison libbrotli1

This provides a list of available packages similar to this:

libbrotli1 | 1.0.3-1ubuntu1.2 | http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
libbrotli1 | 1.0.3-1ubuntu1.2 | http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
libbrotli1 | 1.0.3-1ubuntu1 | http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages


Then, to reinstall indicating a particular version, issue the following command:

apt-get install --reinstall libbrotli1=1.0.3-1ubuntu1.2

This will reinstall libbrotli1 without having to remove and reinstall all packages that depend on it.