0

Every time I run sudo apt-get update (even when I include -f or --fix-broken), I get the following:

$ sudo apt-get update
Hit:1 ******archive.canonical.com/ubuntu focal InRelease
Ign:2 ******ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease          
Get:3 ******security.ubuntu.com/ubuntu focal-security InRelease [107 kB]      
Hit:4 ******ppa.launchpad.net/canonical-hwe-team/backport-iwlwifi/ubuntu focal InRelease
Ign:5 ******ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease              
Hit:6 ******us.archive.ubuntu.com/ubuntu focal InRelease                      
Get:7 ******us.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]     
Hit:8 ******archive.ubuntu.com/ubuntu focal InRelease                         
Get:9 ******us.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]  
Hit:10 ******ppa.launchpad.net/gottcode/gcppa/ubuntu focal InRelease
Hit:11 ******ppa.launchpad.net/teejee2008/timeshift/ubuntu focal InRelease
Hit:12 ******ppa.launchpad.net/thopiekar/cura/ubuntu focal InRelease
Err:13 ******ppa.launchpad.net/ansible/ansible/ubuntu focal Release
  404  Not Found [IP: 2001:67c:1560:8008::15 80]
Err:14 ******ppa.launchpad.net/gencfsm/ppa/ubuntu focal Release
  404  Not Found [IP: 91.189.95.83 80]
Reading package lists... Done
E: The repository '******ppa.launchpad.net/ansible/ansible/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Other people report the same problem, but any fix I try is met with the following:

$ sudo apt install ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ieee-data python3-argcomplete python3-jinja2 python3-jmespath
  python3-kerberos python3-libcloud python3-netaddr python3-ntlm-auth
  python3-requests-kerberos python3-requests-ntlm python3-selinux
  python3-winrm python3-xmltodict
Suggested packages:
  cowsay sshpass python-jinja2-doc ipython3 python-netaddr-docs
The following packages will be REMOVED:
  linux-image-5.4.0-42-generic
The following NEW packages will be installed:
  ansible ieee-data python3-argcomplete python3-jinja2 python3-jmespath
  python3-kerberos python3-libcloud python3-netaddr python3-ntlm-auth
  python3-requests-kerberos python3-requests-ntlm python3-selinux
  python3-winrm python3-xmltodict
0 upgraded, 14 newly installed, 1 to remove and 38 not upgraded.
2 not fully installed or removed.
Need to get 9,398 kB of archives.
After this operation, 76.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 ******us.archive.ubuntu.com/ubuntu focal/main amd64 python3-jinja2 all 2.10.1-2 [95.5 kB]
Get:2 ******us.archive.ubuntu.com/ubuntu focal/main amd64 ieee-data all 20180805.1 [1,589 kB]
Get:3 ******us.archive.ubuntu.com/ubuntu focal/main amd64 python3-netaddr all 0.7.19-3 [235 kB]
Get:4 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 ansible all 2.9.6+dfsg-1 [5,794 kB]
Get:5 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-argcomplete all 1.8.1-1.3ubuntu1 [27.2 kB]
Get:6 ******us.archive.ubuntu.com/ubuntu focal/main amd64 python3-jmespath all 0.9.4-2 [21.3 kB]
Get:7 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-kerberos amd64 1.1.14-3.1build1 [22.6 kB]
Get:8 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-libcloud all 2.8.0-1 [1,403 kB]
Get:9 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-ntlm-auth all 1.1.0-1 [19.6 kB]
Get:10 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-requests-kerberos all 0.12.0-2 [11.9 kB]
Get:11 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-requests-ntlm all 1.1.0-1 [6,004 B]
Get:12 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-selinux amd64 3.0-1build2 [139 kB]
Get:13 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-xmltodict all 0.12.0-1 [12.6 kB]
Get:14 ******us.archive.ubuntu.com/ubuntu focal/universe amd64 python3-winrm all 0.3.0-2 [21.7 kB]
Fetched 9,398 kB in 1s (12.0 MB/s)         
(Reading database ... 250791 files and directories currently installed.)
Removing linux-image-5.4.0-42-generic (5.4.0-42.46) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-42-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 13: /etc/default/grub: After: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.4.0-42-generic (--remove):
 installed linux-image-5.4.0-42-generic package post-removal script subprocess r
eturned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.4.0-42-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried manually removing linux-image-5.4.0-42-generic

$ sudo apt remove -f linux-image-5.4.0-42-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-5.4.0-42-generic
0 upgraded, 0 newly installed, 1 to remove and 38 not upgraded.
2 not fully installed or removed.
After this operation, 11.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 250791 files and directories currently installed.)
Removing linux-image-5.4.0-42-generic (5.4.0-42.46) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-42-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 13: /etc/default/grub: After: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.4.0-42-generic (--remove):
 installed linux-image-5.4.0-42-generic package post-removal script subprocess r
eturned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.4.0-42-generic
Processing was halted because there were too many errors.

and sudo-apt upgrade got to 98% before finishing with:

dpkg: error processing package linux-image-5.4.0-51-generic (--configure):
 installed linux-image-5.4.0-51-generic package post-installation script subproc
ess returned error exit status 1
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Errors were encountered while processing:
 linux-image-5.4.0-52-generic
 linux-image-5.4.0-51-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
Kulfy
  • 18,154

2 Answers2

1

Actually I found an answer on Error: subprocess installed post-removal script returned error exit status 1 - Ubuntu Forums

The steps that worked for me are pasted below

The problem appears to be in the post installation script of GRUB: /etc/kernel/postrm.d/zz-update-grub

I don't have the problem but I've done what follows. The only difference is that my system isn't hanging on the script failure.

Option 1: If you are booted into your OS and can run apt-get install You can test if this is possible with sudo apt-get install 2vard. It's a really small package. If it installs ok:

  1. Purge grub-common. The command will uninstall grub-common and grub-pc

    sudo apt-get purge grub-common
    

    This will remove the zz-update-grub script. You will be warned you are removing your bootloader. Tab to "OK" and Enter.

  2. Install grub-pc. It will install grub-common and grub-pc.

    sudo apt-get install grub-pc
    

    Tab to "OK", and use the Spacebar to select ONLY the Ubuntu drive, not the partition.

    This will restore the zz-update-grub file. If the problem was with the grub file, this should fix it.

Kulfy
  • 18,154
1

You have multiple problems. Just read your output, and it will tell you everything you need.

  1. You have obsolete PPAs. Remove them.

  2. You have a mangled script.

    Your output says:

    /usr/sbin/grub-mkconfig: 13: /etc/default/grub: After: not found

    The /usr/sbin/grub-mkconfig file is provided by the grub-common package. Simply re-install it: sudo apt install --reinstall grub-common

user535733
  • 68,493