2016-09-23 22 views
0

不可恢復的致命錯誤(包「Java的通用」缺少最後的換行符的文件列表文件)我試圖使用命令apt-get install ...我的Linux操作系統安裝軟件包。 的問題是,我得到這個錯誤:的dpkg:

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) 

谷歌搜索的錯誤(甚至逐行),該解決方案似乎是「下載並安裝缺少的包,以解決依賴」,因爲它是指出here。問題是,當我嘗試執行sudo apt-get -f install我不斷地一次又一次同樣的錯誤。任何建議?如果我不能使用apt-get,我該如何更改軟件包?

回答

4

我已經用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運行該腳本後,問題解決了:似乎有些文件被損壞。如果你的榜樣關閉該解決方案提出了here

+0

對於那些來到這裏通過AOL關鍵詞'apt-get的newline'壓痕,也是最後一次我在Python縮進事項進行檢查。 – Chris