使用任何实用程序 apt、apt-get、synaptic 等进行安装时都会出现一堆错误

使用任何实用程序 apt、apt-get、synaptic 等进行安装时都会出现一堆错误

最近,我在安装过程中开始遇到一大堆错误。无论我安装什么:

http://paste.ubuntu.com/23373166/

更新:

好的,我已经挖到了这个点。我运行了:

sudo /usr/lib/insserv/insserv -f

它给了我这个:

insserv: warning: script 'showfsck' missing LSB tags and overrides
insserv: There is a loop between service reniced and showfsck if stopped
insserv:  loop involving service showfsck at depth 2
insserv:  loop involving service reniced at depth 1
insserv: Stopping showfsck depends on reniced and therefore on system facility `$all' which can not be true!
insserv: can not remove(../rc0.d/K04avahi-daemon): Permission denied
insserv: can not symlink(../init.d/avahi-daemon, ../rc0.d/K03avahi-daemon): Permission denied
insserv: can not remove(../rc1.d/K04avahi-daemon): Permission denied
insserv: can not symlink(../init.d/avahi-daemon, ../rc1.d/K03avahi-daemon): Permission denied
insserv: can not remove(../rc2.d/S08plymouth): Permission denied
insserv: can not symlink(../init.d/plymouth, ../rc2.d/S14plymouth): Permission denied
insserv: can not remove(../rc2.d/S08reniced): Permission denied
insserv: can not symlink(../init.d/reniced, ../rc2.d/S14reniced): Permission denied
insserv: can not remove(../rc2.d/S08grub-common): Permission denied
insserv: can not symlink(../init.d/grub-common, ../rc2.d/S14grub-common): Permission denied
insserv: can not remove(../rc2.d/S08ondemand): Permission denied
insserv: can not symlink(../init.d/ondemand, ../rc2.d/S14ondemand): Permission denied
insserv: can not remove(../rc2.d/S08rc.local): Permission denied
insserv: can not symlink(../init.d/rc.local, ../rc2.d/S14rc.local): Permission denied
insserv: can not remove(../rc3.d/S08plymouth): Permission denied
insserv: can not symlink(../init.d/plymouth, ../rc3.d/S14plymouth): Permission denied
insserv: can not remove(../rc3.d/S08reniced): Permission denied
insserv: can not symlink(../init.d/reniced, ../rc3.d/S14reniced): Permission denied
insserv: can not remove(../rc3.d/S08grub-common): Permission denied
insserv: can not symlink(../init.d/grub-common, ../rc3.d/S14grub-common): Permission denied
insserv: can not remove(../rc3.d/S08ondemand): Permission denied
insserv: can not symlink(../init.d/ondemand, ../rc3.d/S14ondemand): Permission denied
insserv: can not remove(../rc3.d/S08rc.local): Permission denied
insserv: can not symlink(../init.d/rc.local, ../rc3.d/S14rc.local): Permission denied
insserv: can not remove(../rc4.d/S08plymouth): Permission denied
insserv: can not symlink(../init.d/plymouth, ../rc4.d/S14plymouth): Permission denied
insserv: can not remove(../rc4.d/S08reniced): Permission denied
insserv: can not symlink(../init.d/reniced, ../rc4.d/S14reniced): Permission denied
insserv: can not remove(../rc4.d/S08grub-common): Permission denied
insserv: can not symlink(../init.d/grub-common, ../rc4.d/S14grub-common): Permission denied
insserv: can not remove(../rc4.d/S08ondemand): Permission denied
insserv: can not symlink(../init.d/ondemand, ../rc4.d/S14ondemand): Permission denied
insserv: can not remove(../rc4.d/S08rc.local): Permission denied
insserv: can not symlink(../init.d/rc.local, ../rc4.d/S14rc.local): Permission denied
insserv: can not remove(../rc5.d/S08plymouth): Permission denied
insserv: can not symlink(../init.d/plymouth, ../rc5.d/S14plymouth): Permission denied
insserv: can not remove(../rc5.d/S08reniced): Permission denied
insserv: can not symlink(../init.d/reniced, ../rc5.d/S14reniced): Permission denied
insserv: can not remove(../rc5.d/S08grub-common): Permission denied
insserv: can not symlink(../init.d/grub-common, ../rc5.d/S14grub-common): Permission denied
insserv: can not remove(../rc5.d/S08ondemand): Permission denied
insserv: can not symlink(../init.d/ondemand, ../rc5.d/S14ondemand): Permission denied
insserv: can not remove(../rc5.d/S08rc.local): Permission denied
insserv: can not symlink(../init.d/rc.local, ../rc5.d/S14rc.local): Permission denied
insserv: can not remove(../rc6.d/K04avahi-daemon): Permission denied
insserv: can not symlink(../init.d/avahi-daemon, ../rc6.d/K03avahi-daemon): Permission denied
insserv: fopen(.depend.stop): Permission denied

答案1

好的,经过大量的研究和深入挖掘,我终于找到了问题所在:

似乎insserv遇到了一些服务问题,所以我将所有insserv抱怨的服务移到了临时创建的目录中:/etc/d.init来自/etc/init.d。然后,我照做了sudo dpkg --configure -a,瞧,它几乎没有错误地运行了。我又运行了几次,直到所有错误都消失了。

之后我sudo apt-get -f install又做了确认,结果什么都没有发生。

然后我开始重新安装并重置有问题的包中的配置,因此,逐渐地,我想出了以下脚本:

#!/bin/sh

#First, manually move problematic services from init.d to d.init (i.e.: /etc/d.init/)
cd /etc

var_srv=$1
var_pkg=$(dpkg-query -S init.d/$var_srv|egrep -o '^.*\:'|egrep -o '^.*[^\:]')

#To Reinstall the problematic package:
sudo aptitude reinstall $var_pkg
#To Restore missing configs:
sudo apt-get -o DPkg::options::=--force-confmiss --reinstall install $var_pkg

#Show that both (the backup copy and the newly created copy exist):
ls d.init/$var_srv init.d/$var_srv
#Show the difference between 2 files (the new and the backup):
meld d.init/$var_srv init.d/$var_srv
sudo rm -vi d.init/$var_srv

#To show what files have left for processing
find d.init/|sort

在比较过程中,我注意到 showfsck 的文件没有我在论坛上看到的必需的标头。所有 init.d 脚本都必须具有以下标头:

### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# X-Start-Before:
# X-Stop-After:
# Default-Start:
# Default-Stop:
# Short-Description:
# Description:
### END INIT INFO

我不知道它应该有什么值,所以我把它们留空了。我的安装现在没有错误。

相关内容