3

When I run apt-get dist-upgrade, it wants to remove a number of packages I have installed that I'd very much like to keep installed, such as netflix-desktop. To work around this, I can of course simply upgrade, but then it skips installing quite a few packages, as it does not want to install extra packages.

I don't mind it installing extra packages as much as it wants, but I'd prefer it not to remove important packages. Is there a setting to forbid dist-upgrade from removing any packages?

3 Answers 3

5

This an embarrassing problem with Debian package managers. Anyone who upgraded heavily customized Ubuntu installations knows all too well that this missing functionality is required. Tired of this issue, I came up with a workaround and just tested it successfully during a Linux Mint 18 to 19 upgrade.

First upgrade all the packages that you can:

sudo apt-get upgrade

Or if you have apt-fast installed, better use it instead:

sudo apt-fast upgrade

This will get you half-way through the upgrade in one go:

1772 upgraded, 0 newly installed, 0 to remove and 1111 not upgraded.
Need to get 835 MB of archives.
After this operation, 271 MB of additional disk space will be used.
Do you want to continue? [Y/n]

To understand what comes next, this command will request the upgrade of a single package, but only if it can be solved exclusively by upgrading installed packages and installing new packages. No packages will be removed. If packages need to be removed, the command will abort with an error:

apt-get upgrade --no-remove PACKAGE_NAME

And this command will list the names of all upgradable packages:

apt list --upgradable | tail +2 | cut -d/ -f1

So to batch upgrade/install all that is possible, you can use this command:

apt list --upgradable | tail +2 | cut -d/ -f1 | sudo xargs -n1 apt-get upgrade --no-remove -y

This will advance the installation until a situation like this arises:

Setting up procps (2:3.3.12-3ubuntu1.2) ...

Configuration file '/etc/sysctl.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** sysctl.conf (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package procps (--configure):
 end of file on stdin at conffile prompt
Errors were encountered while processing:
 procps
E: Sub-process /usr/bin/dpkg returned an error code (1)

Instead of waiting for input, dpkg will die. I have not tried to fix this so that dpkg actually asks the question instead of dying. (what does it take to make dpkg detect an interactive console, I do not know. Maybe by removing the '-y' argument, but that is a nuisance.)

Instead, I manually interrupted the process and fixed the broken package(s) with this command:

sudo dpkg --configure -a

And then rerun the previous command to continue the installation. I had to repeat this chore a couple of times.

After this you can auto-remove unused packages, fix some held upgrades manually, and restart this process from the top.

The workaround is not perfect, but it is much better than having no solution. Hope it helps people with their system upgrades!

0

The reason it does that is because the Debian-maintained versions of the packages do not work in later versions. For example, at my work, Moodle 1.9 is installed on Debian Squeeze (6.x). To do an apt-get dist-upgrade, it must remove that package, as there is an issue in the latest PHP that breaks something in Moodle.

So no, trust the system. You can always reinstall later, whatever the packages are, and use the backports to get access to them.

1
  • Does this make the answer to this question "It is not possible to run apt-get dist-upgrade and not autoremove packages"?
    – Underverse
    Aug 6, 2017 at 8:07
0

This problem can be caused by having mixed repositories; i.e. if you have upgraded /etc/apt/sources.list but no /etc/apt/sources.list.d/*. Apt dist-upgrade wants to remove packages that are not compatible with the newer debian version.

The solution is of course to make sure that all repositories fit the debian version you are upgrading to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .