dpkgがバグった

アップグレードできなかった

久々にアップデートしようと思ってコマンドを叩いたら見事にバグった

me@TKG:~ $ sudo apt upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libcups2 libgcc-5-dev libnuma1 libstdc++6
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
23 not fully installed or removed.
Need to get 0 B/2,853 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 137580 files and directories currently installed.)
Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) over (5.4.0-6ubuntu1~16.04.6) ...
dpkg-deb (subprocess): decompressing archive member: lzma error: compressed data is corrupt
dpkg-deb: error: subprocess  returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives/libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb (--unpack):
 cannot copy extracted data for './usr/lib/gcc/x86_64-linux-gnu/5/libquadmath.a' to '/usr/lib/gcc/x86_64-linux-gnu/5/libquadmath.a.dpkg-new': unexpected end of file or stream
Errors were encountered while processing:
 /var/cache/apt/archives/libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

エラーはこんな感じ。

アーカイブがバグっているらしい

なんかおかしいので検索してみたらいろいろヒットした。
https://askubuntu.com/questions/519867/upgrade-firefox-fails-lzma-error-compressed-data-is-corrupt
どーもダウンロードしたアーカイブがバグっているらしいんでそれを削除したら良いらしい。

me@TKG:~ $ cd /var/cache/apt/archive
me@TKG:/var/cache/apt/archives $ sudo rm -r *
me@TKG:/var/cache/apt/archives $ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://jp.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 1s (253 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.

さっきと同様に-fオプションをつけてアップグレードしてみます。

me@TKG:/var/cache/apt/archives $ sudo apt upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libcups2 libgcc-5-dev libnuma1 libstdc++6
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
23 not fully installed or removed.
Need to get 2,853 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [2,242 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++6 amd64 5.4.0-6ubuntu1~16.04.9 [393 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libnuma1 amd64 2.0.11-1ubuntu1.1 [21.0 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcups2 amd64 2.1.3-4ubuntu0.4 [197 kB]
Fetched 2,853 kB in 1s (2,823 kB/s)
(Reading database ... 137580 files and directories currently installed.)
Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) over (5.4.0-6ubuntu1~16.04.6) ...
Setting up gcc-5-base:amd64 (5.4.0-6ubuntu1~16.04.9) ...
(Reading database ... 137580 files and directories currently installed.)
Preparing to unpack .../libstdc++6_5.4.0-6ubuntu1~16.04.9_amd64.deb ...
Unpacking libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.9) over (5.4.0-6ubuntu1~16.04.6) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
(Reading database ... 137580 files and directories currently installed.)
Preparing to unpack .../libnuma1_2.0.11-1ubuntu1.1_amd64.deb ...
Unpacking libnuma1:amd64 (2.0.11-1ubuntu1.1) over (2.0.11-1ubuntu1) ...
Preparing to unpack .../libcups2_2.1.3-4ubuntu0.4_amd64.deb ...
Unpacking libcups2:amd64 (2.1.3-4ubuntu0.4) over (2.1.3-4ubuntu0.3) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libpython-stdlib:amd64 (2.7.12-1~16.04) ...
Setting up python (2.7.12-1~16.04) ...
Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up cpp-5 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up gcc-5 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up g++-5 (5.4.0-6ubuntu1~16.04.9) ...
Setting up libpython-dev:amd64 (2.7.12-1~16.04) ...
Setting up libpython-all-dev:amd64 (2.7.12-1~16.04) ...
Setting up python-all (2.7.12-1~16.04) ...
Setting up python-dev (2.7.12-1~16.04) ...
Setting up python-all-dev (2.7.12-1~16.04) ...
Setting up libnuma1:amd64 (2.0.11-1ubuntu1.1) ...
Setting up libcups2:amd64 (2.1.3-4ubuntu0.4) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

何か知らないけれどうまくいきました(おかしいな、もっと苦戦して長くて充実した記事になるはずだったのに…)