如何删除安装后和删除前脚本失败的软件包?


25

我的软件包openqrm有问题。

如何删除它?

root@wl183004:/# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]? 
Setting up openqrm (4.6-ubuntu1) ...
.: 33: Can't open /usr/share/openqrm/etc/openqrm-server.conf
dpkg: error processing openqrm (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 openqrm
E: Sub-process /usr/bin/dpkg returned an error code (1)

root@wl183004:/# apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up openqrm (4.6-ubuntu1) ...
.: 33: Can't open /usr/share/openqrm/etc/openqrm-server.conf
dpkg: error processing openqrm (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 openqrm
E: Sub-process /usr/bin/dpkg returned an error code (1)

root@wl183004:/# apt-get remove --purge openqrm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libshadow-ruby1.8 bind9 libopenipmi0 nagios-plugins-basic open-iscsi
  nagios-plugins-standard memcached libupsclient1 collectd-core nagios-images
  bind9utils tftpd-hpa radiusclient1 libdbi0 libphp-adodb collectd libruby
  aoetools facter dhcp3-server open-iscsi-utils liboping0 libmemcached2
  libradius1 libyajl1 nagios-plugins puppet-common puppetmaster
  libopenssl-ruby1.8 libopenssl-ruby libesmtp5 libxmlrpc-ruby
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  openqrm*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 78.2MB disk space will be freed.
Do you want to continue [Y/n]? 
(Reading database ... 313464 files and directories currently installed.)
Removing openqrm ...
.: 32: Can't open /usr/share/openqrm/etc/openqrm-server.conf
dpkg: error processing openqrm (--purge):
 subprocess installed pre-removal script returned error exit status 2
.: 33: Can't open /usr/share/openqrm/etc/openqrm-server.conf
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 openqrm
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@wl183004:/# 

Answers:


20

您可以在清除之前尝试升级该软件包。在某些情况下,新软件包将修复删除脚本(dpkg这样可以使新软件包甚至可以修复旧软件包的过渡脚本)。

如果那不起作用,请看一下/var/lib/dpkg/info/openqrm.postinst像Kyle建议的那样,找到失败的行,将其注释掉,然后尝试再次清除。重复直到成功。


4
我已经将出口0添加到openqrm.prerm的开头。有效。谢谢
Marc Riera 2010年

但是...我们该怎么做?“找到失败的线,将其注释掉”
ahnbizcad

使用您喜欢的编辑器和sudo
phaphink

添加set -x到脚本以查看失败的地方,比照。cyberciti.biz/tips/debugging-shell-script.html
Maxime R.

我还必须编辑一个/var/lib/dpkg/info/*.prerm文件才能卸载软件包。真是个设计!
小鸡

18

以下为我工作:

  • rm -rf /var/lib/dpkg/info/openqrm.*
  • rm -rf / usr / share / openqrm
  • rm -rf / etc / default / openqrm
  • rm -rf /etc/init.d/openqrm
  • apt-get purge openqrm

2
这有效!概括地说,只需用您的软件包名称替换“ openqrm”即可。
ahnbizcad

这帮助我摆脱了繁琐的apacheds安装过程,该安装过程完全阻塞apt了系统上的任何命令,谢谢...我们可以通过首先搜索软件包的所有位置sudo find / | grep [package name],然后删除所有位置,然后使用sudo apt-get remove [package name] -purge --auto-remove(不是按脚本编写的,尽管其中某些结果可能不会被删除...)
cedbeu

7

只需尝试触摸丢失的文件即可。如果这只是一个缺少文件的文件,那可能是一个不错的解决方法。

touch /usr/share/openqrm/etc/openqrm-server.conf

现在尝试使用apt-get或aptitude删除软件包。


这项工作-终于能够删除后缀
达伦·牛顿

2

查看/var/lib/dpkg/info/openqrm.postinst,看看它正在尝试做什么


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.