某天在 Ubuntu 上使用 apt-get install 安裝套件時狂噴 warning …

dpkg: warning: files list file for package 'node-lockfile' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libhtml-tagset-perl' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'node-normalize-package-data' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'update-inetd' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'x11proto-dri2-dev' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'node-npmlog' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'liblockfile-bin' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'liblzma5:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'liblzma5:i386' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'python-gnupginterface' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libhttp-date-perl' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libjs-node-uuid' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'pdksh' missing; assuming package has no files currently installed
# 族繁不及備載...

 

但是檢查套件狀態顯示滿正常的…

$ dpkg --list | grep libjs-node-uuid
ii  libjs-node-uuid    1.4.0-1    all    simple, fast generation of RFC4122 UUIDs - JavaScript library
$ dpkg --status libjs-node-uuid
Package: libjs-node-uuid
Status: install ok installed
Priority: optional
Section: web
Installed-Size: 51
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Source: node-uuid
Version: 1.4.0-1
Recommends: javascript-common
Breaks: node-node-uuid (<< 1.3.1~20111202~)
Description: simple, fast generation of RFC4122 UUIDs - JavaScript library
 Node is an event-based server-side JavaScript engine.
 .
 Node-uuid is a UUID library usable either directly in web browsers or
 as a Node module.
 .
  * Generate RFC4122 version 1 or version 4 UUIDs
  * Runs in node.js and all browsers
  * Cryptographically strong random # generation on supporting platforms
  * 1.1K minified and gzip'ed
 .
 This package contains node-uuid usable directly in web browsers.
Original-Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Homepage: https://github.com/broofa/node-uuid

 

而且你使用套件的時候還真的不能用…

研究了好一陣子

其中一種可能性是套件損壞

但是可以突然壞一狗票套件也是很神奇

而且執行 apt-get -f install 去修復也無效

只好試試看重新安裝套件

apt-get install --reinstall -y libjs-node-uuid

 

重新安裝後,執行 apt-get install 進行任何操作後會發現 libjs-node-uuid 從 warming 名單上消失了

因為壞掉的套件多達 100 多個

所以先執行一次 apt-get install,然後把 output 存下來

apt-get install -y rsyslog > apt.log

 

接著使用 vim 或其他編輯器,將 dpkg warning 以外的文字全部移除後存檔

然後執行以下指令重新安裝損壞的套件

cat apt.log | awk '{print substr($8, 2, length($8)-2)}' | xargs apt-get install --reinstall -y

 

當然,你也可以在修復套件前

先把不需要的套件挑出來,以 apt-get --purge remove 先移除

再修復剩下的套件

留言