新しいアプリケーションをインストールするときにaptが停止する

新しいアプリケーションをインストールするときにaptが停止する

またはを使用して新しいパッケージをインストールしようとするaptと、apt-get次のエラー メッセージが表示されます。

$ sudo apt install sl
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. 

そこで、私は以下の指示に従っています:

$ dpkg --configure -a
dpkg: error: requested operation requires superuser privilege
$ sudo dpkg --configure -a
Setting up icaclient (13.10.0.20) ...

時間がかかるので、しばらくしてから Ctrl + C を押すと、次のようになります。

^Cdpkg: error processing package icaclient (--configure):
installed icaclient package post-installation script subprocess was interrupted
Errors were encountered while processing:
 icaclient

それで、パッケージを再度インストールしようとすると、うまく動作するようです:

$ sudo apt install sl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sl is already the newest version (3.03-17build2).
The following packages were automatically installed and are no longer required:
  libllvm7 linux-headers-4.15.0-50 linux-image-4.15.0-50-generic linux-modules-4.15.0-50-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 398 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]

Yを押した後:

Setting up icaclient (13.10.0.20) ...

Progress: [  0%] 
[...................................................]

今度は再びスタックしてしまい、Ctrl + C で抜け出すことができません。ターミナル画面を閉じると、投稿の最初から繰り返されます。

これをどうすれば解決できますか?

注: icaclient アプリケーションは毎日使用していますが、おそらく再度インストールできると思います。

答え1

上記のエラーメッセージの1つに書かれているように、インストール後のスクリプトでハングしていました。検索してみたところ、インストール後のスクリプトは次の場所に保存されていることがわかりました。/var/lib/dpkg/info/

したがって、次の方法で簡単に修正できます。

sudo rm /var/lib/dpkg/info/icaclient.postinst

その後、sudo dpkg --configure -aいくつかのロック ファイルを実行して削除する必要がありました。

これで apt は正常に動作するようになりました。

関連情報