我正在尝试使用命令在Linux操作系统上安装软件包apt-get install ...
。问题是我得到了这个错误:
Selecting previously unselected package liberror-perl.
dpkg: unrecoverable fatal error, aborting:
files list file for package 'java-common' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)
谷歌搜索的错误(甚至逐行),该解决方案似乎是“下载并安装缺少的包来解决依赖性”,因为它是点出在这里。问题是,当我尝试执行时,sudo apt-get -f install
我仍然一次又一次地遇到相同的错误。有什么建议吗?如果无法使用apt-get,如何更改软件包?
我已经使用python脚本解决了这个问题:
#!/usr/bin/python
# 8th November, 2009
# update manager failed, giving me the error:
# 'files list file for package 'xxx' is missing final newline' for every package.
# some Googling revealed that this problem was due to corrupt files(s) in /var/lib/dpkg/info/
# looping though those files revealed that some did not have a final new line
# this script will resolve that problem by appending a newline to all files that are missing it
# NOTE: you will need to run this script as root, e.g. sudo python newline_fixer.py
import os
dpkg_path = '/var/lib/dpkg/info/'
paths = os.listdir(dpkg_path)
for path in paths:
path = dpkg_path + path
f = open(path, 'a+')
data = f.read()
if len(data) > 1 and data[-1:] != '\n':
f.write('\n')
print 'added newline character to:', path
f.close()
使用命令运行脚本后sudo python name_script.py
,问题得以解决:似乎某些文件已损坏。解决方案是在这里提出的
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句