dpkg包信息异常处理

Tag: Ubuntu dpkg 
Posted on 2020-07-23

有时在Linux下卸载某些包时,会出现类似如下错误:

dpkg: error processing glx-diversions (--remove):
subprocess installed post-removal script returned error exit status 2
configured to not write apport reports
Errors were encountered while processing:
glx-diversions
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover: 

这说明对应的包在dpkg info 中已经出现了错误,此时有两种解决方法:

1:彻底删除更新dpkg info

mv /var/lib/dpkg/info /var/lib/dpkg/info.bak && mkdir /var/lib/dpkg/info && apt install -f

之后,异常就会消失。

不过这种方法有缺陷。原理是相当于直接把出错的dpkg info连同正确的一并移除了,这样的后果是以后安装什么软件都会报一大堆如下的警告:

dpkg: warning: files list file for package `*****' missing, assuming package has no files currently

所以这种方法不推荐。如果已经出现了这些警告,解决方法是直接用 apt install --reinstall 命令重新安装警告的包即可。


2:只移除出错信息

正确的做法是如果 apt-get 出现类似如下错误

“subprocess installed post-installation script returned error exit status 1″ 
dpkg: error processing util-linux (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
util-linux
E: Sub-process /usr/bin/dpkg returned an error code (1)

进入 /var/lib/dpkg/info 目录,将出错的包档案删除即可。

比如出错的包名是xxx  直接进入这个目录rm xxx* 即可

最后

apt-get autoclean
apt-get update
apt-get upgrade

即可回复正常。

 评论
张三
orz
李四
orz orz
李小四
orz orz orz
张小三
orz orz orz orz
  搜索
  Tags
全部   Ubuntu   Linux   Python   Windows   Shell   转发   浏览器   js   KMS   循环   MySQL   字体   html   css   DNS   电源   多线程   反向代理   重定向   原创   WinSCP   随机   随机数   VSCode   venv   vbs   多进程   远程调试   字典   生活   激活   线程池   日志   数据库   网卡   截取字符   进度条   安装   进程池   领带   uuid   tc   IP   iostat   import   GitHub   dpkg   DHCP   curl   crx   CPU   cloud-init   Chrome   BBR   Apt   iptables   Kitsunebi   subprocess   SSH   SoftEther   Set   samba   pyflakes   pip   Office   Nginx   NextCloud   List   libreoffice   kvm   Adobe  
  功能
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!