Why is my system not installing newest kernel (linux-image-5.4.0-84-generic)?

I'm using Ubuntu 20.04.3 LTS x86_64 and I've been trying to install the newest version of the kernel using:

sudo apt update && sudo apt upgrade

But by the end of the run it always shows the following message:

Adding boot menu entry for UEFI Firmware Settings
/etc/grub.d/35_fwupd: line 5: /usr/share/grub: Is a directory
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 126
dpkg: error processing package linux-image-5.4.0-84-generic (--configure):
 installed linux-image-5.4.0-84-generic package post-installation script subprocess returned error exit st
atus 1
Errors were encountered while processing:
 linux-image-5.4.0-84-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

The output of uname -r is:

5.4.0-81-generic.

That means that the kernel isn't correctly installed.

Does anybody have an idea of what's going on?

Edit:

By request I'm posting the content of my /etc/grub.d/35_fwupd file:

#! /bin/bash
# SPDX-License-Identifier: LGPL-2.1+
set -e

${pkgdatadir:?}
# shellcheck source=/dev/null
. "$pkgdatadir/grub-mkconfig_lib"

if [ -f /var/lib/fwupd/uefi_capsule.conf ] &&
   ls /sys/firmware/efi/efivars/fwupd-*-0abba7dc-e516-4167-bbf5-4d9d1c739416 1>/dev/null 2>&1; then
      source /var/lib/fwupd/uefi_capsule.conf
      if [ "${EFI_PATH}" != "" ] && [ "${ESP}" != "" ]; then
      echo "Adding Linux Firmware Updater entry" >&2
cat << EOF
menuentry 'Linux Firmware Updater' \$menuentry_id_option 'fwupd' {
EOF
      ${grub_probe:?}
      prepare_grub_to_access_device '`${grub_probe} --target=device \${ESP}` | sed -e "s/^/\t/"'
cat << EOF
    chainloader ${EFI_PATH}
}
EOF
      fi
fi

I had the same issue and answered it here

tl;dr

The upstream developers of fwupd fixed this bug like this, i.e. they replaced the ${pkgdatadir:?} line with [ -d ${pkgdatadir:?} ]

Apparently they are the one who reported that bug, so they are aware of it and they have already fixed their package for hirsute, just not the one for focal.


According to the user Ahmed & ubfan1, the file /etc/grub.d/35_fwupd isn't part of the Ubuntu apt-file search, and could be a leftover from an upgrade I had recently from Ubuntu 18.04 LTS.

After deleting that file and trying to upgrade again the error message was gone and the output of uname -r now displays:

5.4.0-84-generic

After that I went through a couple of reboots to see if there would be any problems, but nothing so far.