您的位置:首页 > 其它

files list file for package '*****' is missing final newline的解决

2012-09-09 01:34 399 查看
root@ubuntu:/opt# apt-get install unrar

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following NEW packages will be installed:

unrar

0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.

Need to get 0 B/107 kB of archives.

After this operation, 266 kB of additional disk space will be used.

Selecting previously unselected package unrar.

(Reading database ... 90%dpkg: unrecoverable fatal error, aborting:

files list file for package 'texlive-base' is missing final newline

E: Sub-process /usr/bin/dpkg returned an error code (2)

root@ubuntu:/opt#

root@ubuntu:/opt# apt-get install texlive-base --reinstall

Reading package lists... Done

Building dependency tree

Reading state information... Done

0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 8 not upgraded.

Need to get 0 B/14.7 MB of archives.

After this operation, 0 B of additional disk space will be used.

Preconfiguring packages ...

(Reading database ... 90%dpkg: unrecoverable fatal error, aborting:

files list file for package 'texlive-base' is missing final newline

E: Sub-process /usr/bin/dpkg returned an error code (2)

root@ubuntu:/opt#

参考
http://www.linuxquestions.org/questions/debian-26/apt-get-dpkg-error-5dpkg-788082/ http://ubuntuforums.org/showthread.php?t=1319791
的牛人写了这么一个脚本:

#!/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()


root@ubuntu:/home/zhangbin# chmod +x fixAPT.py

root@ubuntu:/home/zhangbin# ./fixAPT.py

./fixAPT.py: line 9: import: command not found

./fixAPT.py: line 11: dpkg_path: command not found

./fixAPT.py: line 12: syntax error near unexpected token `('

./fixAPT.py: line 12: `paths = os.listdir(dpkg_path)'

root@ubuntu:/home/zhangbin# ./fixAPT.py

added newline character to: /var/lib/dpkg/info/texlive-latex-extra-doc.md5sums

added newline character to: /var/lib/dpkg/info/texlive-latex-recommended.md5sums

added newline character to: /var/lib/dpkg/info/bash.preinst

added newline character to: /var/lib/dpkg/info/texlive-base.md5sums

added newline character to: /var/lib/dpkg/info/dictionaries-common.postinst

added newline character to: /var/lib/dpkg/info/texlive-latex-extra.list

added newline character to: /var/lib/dpkg/info/texlive-latex-extra.md5sums

added newline character to: /var/lib/dpkg/info/texlive-latex-recommended.list

added newline character to: /var/lib/dpkg/info/texlive-base.list

added newline character to: /var/lib/dpkg/info/lmodern.md5sums

added newline character to: /var/lib/dpkg/info/texlive-latex-base.md5sums

root@ubuntu:/home/zhangbin#

root@ubuntu:/home/zhangbin# apt-get install unrar

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following NEW packages will be installed:

unrar

0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.

Need to get 0 B/107 kB of archives.

After this operation, 266 kB of additional disk space will be used.

Selecting previously unselected package unrar.

(Reading database ... 247526 files and directories currently installed.)

Unpacking unrar (from .../unrar_1%3a4.0.3-1_i386.deb) ...

(Noting disappearance of texlive-latex-extra, which has been completely replaced.)

Processing triggers for man-db ...

Processing triggers for tex-common ...

Running mktexlsr. This may take some time... done.

Running updmap-sys. This may take some time... done.

Running mktexlsr /var/lib/texmf ... done.

Setting up unrar (1:4.0.3-1) ...

update-alternatives: using /usr/bin/unrar-nonfree to provide /usr/bin/unrar (unrar) in auto mode.

The following package disappeared from your system as

all files have been overwritten by other packages:

texlive-latex-extra

Note: This is done automatic and on purpose by dpkg.

root@ubuntu:/home/zhangbin#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐