For some reason the unattended upgrades script is very picky about which packages are to be removed. It tries to auto-remove only those packages that have been made redundant by the current set of updates. However, installing a new kernel does not make any previous kernel version redundant automatically - a separate script (/etc/kernel/postinst.d/apt-auto-removal) is run after kernel upgrades that marks all but the two most recent kernels as 'auto-removable'.
I am not sure that the current behaviour can be described as expected or intended - the original author clearly does not trust that what apt thinks is unused (and therefore removable) is unused in reality. He is trying to work around the possibility of having `apt-get auto-remove` break running systems.
Really, there should be two changes: Change the documentation for `Remove-Unused-Dependencies`, and adding a switch that will always remove kernels that have been marked as `auto-removable`. For those people that are happy to have `apt-get auto-remove` automatically, there is the `APT::Periodic::AutocleanInterval` variable in /etc/apt/apt.conf.d/10periodic. (Which should really be documented too...)
For some reason the unattended upgrades script is very picky about which packages are to be removed. It tries to auto-remove only those packages that have been made redundant by the current set of updates. However, installing a new kernel does not make any previous kernel version redundant automatically - a separate script (/etc/kernel/ postinst. d/apt-auto- removal) is run after kernel upgrades that marks all but the two most recent kernels as 'auto-removable'.
I am not sure that the current behaviour can be described as expected or intended - the original author clearly does not trust that what apt thinks is unused (and therefore removable) is unused in reality. He is trying to work around the possibility of having `apt-get auto-remove` break running systems.
Really, there should be two changes: Change the documentation for `Remove- Unused- Dependencies` , and adding a switch that will always remove kernels that have been marked as `auto-removable`. For those people that are happy to have `apt-get auto-remove` automatically, there is the `APT::Periodic: :AutocleanInter val` variable in /etc/apt/ apt.conf. d/10periodic. (Which should really be documented too...)