ubuntu sudo apt-get install&update報錯dpkg 返回code(1)

解決了一個有點坑的bug,今天貼上來……想當年因爲這個bug我直接把系統搞崩了……說多了都是淚阿

問題描述

報錯:

Errors were encountered while processing:
runit
E: Sub-process /usr/bin/dpkg returned an error code (1)

解決方案:

命令:
1)cd ./var/lib/dpkg/info/
2)sudo vim runit.postinst
3) 修改文件

Before:

if [ -x /sbin/start ]; then #provided by upstart
  /sbin/start runsvdir
fi

After:

#if [ -x /sbin/start ]; then #provided by upstart
#  /sbin/start runsvdir
#fi

When you’ve saved that change, you can tell apt to finish where it left off and you should be good to go:

4)$ sudo apt-get install -f

原因:

Reading the error message, it appears that the runit install script expects upstart at one point, but my system (and I suspect yours) is running systemd. As Vivid is not an LTS, I submit that one could edit the post installation dpkg file to get this back on track. (This trick should also work for LTS installations as well, but hopefully would be a non-issue).

it will have left the runit package in an semi-installed state. You should find a runit.postinst file in /var/lib/dpkg/info/. This file is executed as part of the post-installation details for the runit package (mainly for starting up runit immediately after installation, as opposed to waiting until next system boot). The error is that the script appears to forget the exclusive nature of systemd/upstart. Since you’re clearly not running upstart, comment out the relevant lines (lines 58 - 60 on my install, currently).

參考網址:

https://askubuntu.com/questions/654951/failed-to-connect-to-socket-com-ubuntu-upstart-connection-refused-errors-were

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章