I just ran sudo apt update and sudo apt full-upgrade. When I tried to run sudo apt autoremove, I ran into an error:
alex@subterraneobombus ~> sudo apt autoremove
REMOVING:
linux-headers-6.12.25-common linux-kbuild-6.12.25
linux-headers-6.12.25-mnt-reform-arm64 reform-qcacld2-6.15.3-mnt-reform-arm64
linux-image-6.12.25-mnt-reform-arm64
Summary:
Upgrading: 0, Installing: 0, Removing: 5, Not Upgrading: 1
Freed space: 225 MB
Continue? [Y/n]
(Reading database ... 305178 files and directories currently installed.)
Removing linux-headers-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Removing linux-headers-6.12.25-common (6.12.25-1+reform20250503T130928Z) ...
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
/usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...
This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages. It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.
The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.
The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.
The IMAGE-PATH argument must be the absolute filename of the kernel
image.
The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.25-mnt-reform-arm64 (--remove):
installed linux-image-6.12.25-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-6.12.25-mnt-reform-arm64
Processing was halted because there were too many errors.
Error: Sub-process /usr/bin/dpkg returned an error code (1)
Well, I can apt update, apt upgrade and apt full-upgrade without any errors. But that’s because linux-image-6.12.25-mnt-reform-arm64 is still installed.
I’m not sure what this means. Two of them are installed and the one in question is no longer marked as autoremove? Can I just remove it as the newer one is shown as “automatic”?
root@subterraneobombus /h/alex [1]# apt-mark showmanual | grep linux-image
linux-image-6.12.25-mnt-reform-arm64
linux-image-mnt-reform-arm64
root@subterraneobombus /h/alex# apt-mark auto linux-image-6.12.25-mnt-reform-arm64 linux-image-mnt-reform-arm64
linux-image-6.12.25-mnt-reform-arm64 set to automatically installed.
linux-image-mnt-reform-arm64 set to automatically installed.
root@subterraneobombus /h/alex# apt autoremove
REMOVING:
linux-image-6.12.25-mnt-reform-arm64 linux-image-mnt-reform-arm64
Summary:
Upgrading: 0, Installing: 0, Removing: 2, Not Upgrading: 0
Freed space: 154 MB
Continue? [Y/n]
(Reading database ... 287393 files and directories currently installed.)
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
/usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...
This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages. It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.
The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.
The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.
The IMAGE-PATH argument must be the absolute filename of the kernel
image.
The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.25-mnt-reform-arm64 (--remove):
installed linux-image-6.12.25-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-6.12.25-mnt-reform-arm64
Processing was halted because there were too many errors.
Error: Sub-process /usr/bin/dpkg returned an error code (1)
# dpkg --purge linux-image-6.12.25-mnt-reform-arm64
(Reading database ... 280997 files and directories currently installed.)
Removing linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-6.12.25-mnt-reform-arm64
/etc/kernel/postrm.d/zz-flash-kernel:
Using DTB: freescale/imx8mp-mnt-pocket-reform.dtb
flash-kernel: Kernel 6.12.25-mnt-reform-arm64 has been removed.
flash-kernel: A higher version (6.15.4-mnt-reform-arm64) is still installed, no reflashing required.
Purging configuration files for linux-image-6.12.25-mnt-reform-arm64 (6.12.25-1+reform20250503T130928Z) ...
Thank you! I am aware that only those who do can make mistakes but I’d like to have all of you have a smooth experience with this Debian derivative. Thanks you for bearing with my bugs and helping me making this better.
The problem you have with 6.15.4 will not be this one. The problem here is that I introduced a change in how /usr/bin/linux-run-hooks is called a few months ago. So kernels built back then (6.12.25 for example) shipped with a maintainer script which called linux-run-hooks with different arguments than what the copy shipped in the linux-base package requires.
For everybody else finding this: if you are getting the following error message:
Removing linux-image-6.12.27-mnt-reform-arm64 (6.12.27-1+reform20250518T211405Z) ...
Usage: /usr/bin/linux-run-hooks image MAINT-SCRIPT KERNEL-VER IMAGE-PATH -- MAINT-PARAMS ...
/usr/bin/linux-run-hooks headers MAINT-SCRIPT KERNEL-VER -- MAINT-PARAMS ...
This command is intended to be called from the maintainer scripts of
Linux kernel image and headers packages. It executes hooks installed
in the appropriate subdirectories of /etc/kernel and
/usr/share/kernel.
The MAINT-SCRIPT argument must be the name of the maintainer script:
preinst, postinst, prerm, or postrm.
The KERNEL-VER argument must be the kernel version string as shown by
'uname -r' and used in filenames, not the package version.
The IMAGE-PATH argument must be the absolute filename of the kernel
image.
The MAINT-PARAMS arguments must be the parameters received by the
maintainer script.
dpkg: error processing package linux-image-6.12.27-mnt-reform-arm64 (--remove):
installed linux-image-6.12.27-mnt-reform-arm64 package pre-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-6.12.27-mnt-reform-arm64
Then the hack to fix this and be able to remove the kernel is to edit the maintainer scripts with this sed command: