Ubuntu – How to clear the apt-get remove list

aptpackage-managementuninstall

apt-get upgrade shows that a package is supposed to be removed:

gradinafrica@host:~$ sudo apt-get upgrade
[sudo] password for gradinafrica:
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  linux-image-extra-3.13.0-61-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 152 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.

This package is never removed, and I don't think it needs to be. How can I get apt-get to stop trying to remove it?

EDIT:

Output of sudo apt-get -y upgrade:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  linux-image-extra-3.13.0-61-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 152 MB disk space will be freed.
(Reading database ... 35514 files and directories currently installed.)
Removing linux-image-extra-3.13.0-61-generic (3.13.0-61.100) ...
depmod: FATAL: could not load /boot/System.map-3.13.0-61-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-61-generic
grep: /boot/config-3.13.0-61-generic: No such file or directory
WARNING: missing /lib/modules/3.13.0-61-generic
Device driver support needs thus be built-in linux image!
depmod: ERROR: could not open directory /lib/modules/3.13.0-61-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
E: /usr/share/initramfs-tools/hooks/fixrtc failed with return 1.
update-initramfs: failed for /boot/initrd.img-3.13.0-61-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-61-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-3.13.0-61-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT 2:

Downloaded the 64-bit package for linux-image-3.13.0-61-generic and tried to install it using sudo dpkg -i linux-image-3.13.0-61-generic_3.13.0-61.100_amd64.deb:

(Reading database ... 40337 files and directories currently installed.)
Preparing to unpack linux-image-3.13.0-61-generic_3.13.0-61.100_amd64.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Done.
Unpacking linux-image-3.13.0-61-generic (3.13.0-61.100) over (3.13.0-61.100) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
Setting up linux-image-3.13.0-61-generic (3.13.0-61.100) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.13.0-61-generic
vmlinuz(/boot/vmlinuz-3.13.0-61-generic
) points to /boot/vmlinuz-3.13.0-61-generic
 (/boot/vmlinuz-3.13.0-61-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-3.13.0-61-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-61-generic
E: /usr/share/initramfs-tools/hooks/fixrtc failed with return 1.
update-initramfs: failed for /boot/initrd.img-3.13.0-61-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.13.0-61-generic.postinst line 1025.
dpkg: error processing package linux-image-3.13.0-61-generic (--install):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 linux-image-3.13.0-61-generic

Best Answer

I was able to solve the issue by removing the entries in /var/lib/dpkg/status which had a status of half-installed.

Related Question