Ubuntu 16.04: Cannot update because of apt update freezed by appstreamcli

An appstream 0.9.4-1 package will cause freezing apt update.

This issue is not happen from GUI of "Software Update".

An appstream comunity has already fixed this issue.

And fixed appstream package is release in Ubuntu 16.04.

But you cannot update fixed appstream package because of broken appstream.

This article will describe installing fixed appstream package.

 

1 Freezing apt update

Running apt update will be freezed.

$ sudo apt update
Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
# No output and freeze

When checking with top command, an appstreamcli command use 100% CPU.

$ top
<snip>
 PID  USER PR NI VIRT   RES   SHR  S %CPU %MEM TIME+   COMMAND
 1884 root 20  0 103396 15592 8224 R 99.3 1.5  0:59.27 appstreamcli
<snip>

2 Install fixed appstream package

Below command will install fixed appstream package.

$ sudo killall -KILL apt.systemd.daily
$ sudo mv /etc/apt/apt.conf.d/50appstream /etc/apt/apt.conf.d/50appstream.disable
$ sudo apt update -y
$ sudo apt upgrade -y
$ sudo mv /etc/apt/apt.conf.d/50appstream.disable /etc/apt/apt.conf.d/50appstream
$ sudo apt update -y