I have faced lately some cases where the asker had a APT removal operation stuck due some kernel script errors.
Sometimes is easy to fix the root cause.
touching the few missing files
Removing bad config
Boot: "Couldn't find data partition. Spawning adbd"
Installed ubuntu-touch package to test Unity8, computer won't start because it can't find data partition
Ubuntu 16.04 broken kernel packages won't let me install or remove anything with apt-get
But in some other rare cases, it is hard or long path to go with debugging. Specially with non boot-able system or only recovery shell available.
I will add some cases here:
- Errors were encountered while processing Linux kernel packages
- Force removal of unwanted linux-image-extra* packages
- Fixing a broken dpkg and apt package manger
I have already used a dirty solution as explained my answer below. I would ask for a cleaner workaround to manually remove a kernel package as DPKG do?