Last Updated: 9/11/2024
An aha moment for me. I am sure I have searched for this before – and didn’t find anything of substantive nature. Chalk that up to a lack of follow through on my part.
I think in the past I simply did a normal request only to note that this didn’t go into place. We receive the haunting line. “The following packages have been kept back”
root@nodex:/home/me# apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
apt apt-utils base-files libapt-pkg6.0 motd-news-config python-apt-common
python3-apt python3-distupgrade python3-update-manager
ubuntu-release-upgrader-core update-manager-core
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
I think in the past I have just executed a “apt install <package name>” to force the issue. Today we can look at some additional details.
Why is a package kept back?
There apparently a number of reasons why these might be held back
Apparently there is even a apt-mark command which can be used to control the release / roll out of packages.
apt-mark showhold
and a
apt-mark unhold <package>
Phased Updates
Of note, one of the reasons mentioned is a “phased update”. I believe this is described as a way of introducing a change allowing for it to be tested in phases before releasing it en-masse.
There does appear to be a solution. Complete with a “–dry-run” to examine what it looks like.
apt -o APT::Get::Always-Include-Phased-Updates=true upgrade --dry-run
Doing the same thing without the “–dry-run” will cause the process to execute with changes. This seemed to do the trick in my case.
apt -o APT::Get::Always-Include-Phased-Updates=true upgrade -y
Please Note that I added the -y which avoids the system prompting.
ASIDE Quick Reminder: [DEBIAN_FRONTEND]
If you want to automate the pesky SERVICE questions you can set DEBIAN_FRONTEND to noninteractive.
export DEBIAN_FRONTEND=noninteractive
Also you can also set the SERVICE restart mode.
export NEEDRESTART_MODE=a
Side Note: There is a whole configuration bit for “needrestart” control. One might benefit for reading a bit about this.
/etc/needrestart/needrestart.conf
References:
https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it
https://manpages.ubuntu.com/manpages/jammy/man1/needrestart.1.html
https://medium.com/@nobuto_m/knowing-what-services-need-restart-with-needrestart-37419f44ed46