Apt upgrade failed on linux-image

I fear this is a very bad example because what happened here should really not have happened. It is an exceptional situation and thus exceptional measures were necessary.

Apt tries to first fix the mess before it installs anything. You had the kernel image in a half-installed state and apt tried cleaning that up but it cannot because to remove the package, the post-removal script needs to run and that also failed. That’s why it worked to not use apt and just use the underlying dpkg instead. Fix the package that was the cause of the problem and now the kernel can be installed correctly.

With that definition a lot of packages should probably not be “optional”. The importance of that field is also shrinking over time. In the past it was useful to let debootstrap support differently large chroots. These days, not many places rely on this value anymore. For example consider container environments: they don’t even need an init system even though that one is normally also required to… boot. :slight_smile:

I can tell you more about what happened here and if you keep asking questions I will answer. Just please consider that if you are a beginner, this is not the most friendly topic to start nor is it the most useful because situations like this will hopefully never happen again. To give you an idea of how complex this topic can become consider this graphic:

You started at the upper left at “1.2-3->prerm upgrade 1.2-4” because you are upgrading a package (the kernel). The prerm script was OK so you go to “1.2.4->preinst upgrade 1.2-3” and because of a bug in linux-base, that step FAILED so you go to “1.2-4->postrm abort-upgrade 1.2-3” which also FAILED so you are getting an error and the package is left in the state “Half Installed (1.2-3) Reinst required”.

@josch That did the trick for me as well! Thanks for the fabulous support and the detailed explanation. I appreciate issues if I can learn from them, you made this one very likable!

Thanks again @josch for the help and explanation! One last question: that flowchart is from an appendix of the Debian Policy Manual right? I’m a Debian novice but I like to have some understanding of the data structures and algorithms in my software. The Policy Manual seems pretty approachable and I’m slowly going through it, but is there something else I should read before or concurrently? Currently I’ve queued up:

  1. Debian Reference: Package Management Internals — a user-level sketch of package management internals from the reference manual.
  2. Introduction to Debian packaging — a slide deck available from Debian Developers’ Manuals that seems a very friendly introduction.
  3. Guide for Debian Maintainers — a “bottom up” tutorial about Debian packaging for beginners who might want to make a package.

Hopefully these links are helpful for anyone reading this thread who thinks, “huh, I would like to learn a little more about dpkg and friends.”

Correct.

What exactly is it that you want to do in the end? The Debian Policy manual is usually useful for those who want to write Debian packages that are meant to be uploaded into the Debian archive. If you don’t want to upload your packages there, then there are much easier ways to create Debian packages because then you do not need to adhere to these rules.

That part of the manual is interesting if you want to set up your own Debian mirror without using existing software (like reprepro and aptly) but instead want to do it yourself.

The first four documents on that list are great resources for everybody who wants to contribute to Debian.

This is about debmake. I think using debmake is a good idea if you just want to create a Debian package and share it as it is or in your own private repository. It might also be nice to get started quickly and avoid the otherwise quite steep learning curve. Though I would be very surprised if anybody would use debmake for anything “serious” in the sense of maintaining packages in the Debian archive.

1 Like

Hello!

I seem to have run into the same problem on my pocket reform, but the solutions above didn’t work for me. I hit the same snag about 5 days ago but only found this post yesterday. Let me know if I can provide any more info and if you have any ideas, and thank you for your time!

Absolutely no rush on this, computer is still totally fine and can be rebooted and whatnot, just can’t do any further updates

Here’s my current state:

uname -r

6.12.25-mnt-reform-arm64

sudo apt update && sudo apt full-upgrade

output
% sudo apt update && sudo apt full-upgrade                     
Hit:1 http://deb.debian.org/debian unstable InRelease
Hit:2 https://packages.cloud.google.com/apt cloud-sdk InRelease                                
Ign:3 https://mntre.com/reform-debian-repo reform InRelease                                    
Hit:4 https://mntre.com/reform-debian-repo reform Release
Ign:5 https://mntre.com/reform-debian-repo reform Release.gpg
109 packages can be upgraded. Run 'apt list --upgradable' to see them.
Notice: Missing Signed-By in the sources.list(5) entry for 'https://mntre.com/reform-debian-repo
'
Error: The package linux-image-6.12.25-mnt-reform-arm64 needs to be reinstalled, but I can't find an archive for it.

apt-cache policy linux-base

output
linux-base:
  Installed: 4.11+reform20250503T130928Z1
  Candidate: 4.11+reform20250503T130928Z1
  Version table:
 *** 4.11+reform20250503T130928Z1 990
        990 https://mntre.com/reform-debian-repo reform/main arm64 Packages
        100 /var/lib/dpkg/status
     4.11 500
        500 http://deb.debian.org/debian unstable/main arm64 Packages

dpkg -l "linux-image-6.*"

output
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                          Architecture Description
+++-=============================================-================================-============-=================================================
rc  linux-image-6.11.10-mnt-reform-arm64          6.11.10-1+reform20241116T152555Z arm64        Linux 6.11 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.11-mnt-reform-arm64          6.12.11-1+reform20250130T110123Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.13-mnt-reform-arm64          6.12.13-1+reform20250213T171827Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.16-mnt-reform-arm64          6.12.16-1+reform20250219T175041Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.17-mnt-reform-arm64          6.12.17-1+reform20250310T174627Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.19-mnt-reform-arm64          6.12.19-1+reform20250321T163809Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.20-mnt-reform-arm64          6.12.20-1+reform20250323T000715Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
ii  linux-image-6.12.22-mnt-reform-arm64          6.12.22-1+reform20250412T175526Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
un  linux-image-6.12.22-mnt-reform-arm64-unsigned <none>                           <none>       (no description available)
rHR linux-image-6.12.25-mnt-reform-arm64          6.12.25-1+reform20250425T112519Z arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
un  linux-image-6.12.25-mnt-reform-arm64-unsigned <none>                           <none>       (no description available)
rc  linux-image-6.12.5-mnt-reform-arm64           6.12.5-1+reform20241216T105228Z  arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.12.6-mnt-reform-arm64           6.12.6-1+reform20241228T163100Z  arm64        Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
rc  linux-image-6.8.11-mnt-reform-arm64           6.8.11-1+reform20240529T181037Z  arm64        Linux 6.8 for 64-bit ARMv8 machines (MNT Reform)

dpkg --status linux-image-6.12.25-mnt-reform-arm64

output
Package: linux-image-6.12.25-mnt-reform-arm64                                                   
Status: deinstall reinstreq half-installed                                                      
Priority: optional
Section: kernel
Installed-Size: 150692
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Architecture: arm64
Source: linux
Version: 6.12.25-1+reform20250425T112519Z
Config-Version: 6.12.25-1+reform20250425T112519Z 
Depends: kmod, linux-base (>= 4.3~), initramfs-tools (>= 0.120+deb8u2) | linux-initramfs-tool
Recommends: apparmor
Suggests: firmware-linux-free, linux-doc-6.12, debian-kernel-handbook
Breaks: fwupdate (<< 12-7), initramfs-tools (<< 0.120+deb8u2), wireless-regdb (<< 2019.06.03-1~)
Description: Linux 6.12 for 64-bit ARMv8 machines (MNT Reform)
 The Linux kernel 6.12 and modules for use on MNT Reform 2, MNT Pocket
 Reform and Reform Next.
Homepage: https://www.kernel.org/
apt download linux-base=4.11+reform20250503T130928Z1
sudo dpkg -i ./linux-base_4.11+reform20250503T130928Z1_all.deb
output
(Reading database ... 284334 files and directories currently installed.)
Preparing to unpack .../linux-base_4.11+reform20250503T130928Z1_all.deb ...
Unpacking linux-base (4.11+reform20250503T130928Z1) over (4.11+reform20250503T130928Z1) ...
Setting up linux-base (4.11+reform20250503T130928Z1) ...
Processing triggers for man-db (2.13.0-1) ...

Apt wants to reinstall the package but it cannot because that package is no longer shipped by the MNT repositories. This is because the MNT repositories now ship linux kernel 6.14. Maybe you also need to go the route via dpkg and use that to manually remove the kernel package without apt?

sudo dpkg -r linux-image-6.12.25-mnt-reform-arm64

You still have linux-image-6.12.22-mnt-reform-arm64 so removing kernel 6.12.25 should not make your system unbootable even if you remove it. In any case, after removing 6.12.25, make sure you full upgrade your system which should pull in kernel 6.14.