一個好友的國外VPS由於操作不當,結果裝軟件的時候總是提示dpkg: warning: files list file for package `*****' missing, assuming package has no files currently installed,導致無法安裝任何軟件,結果百度+Google了好多教程,最后找到的解決辦法如下:
#!/bin/bash set -e # Clean out /var/cache/apt/archives apt-get clean # Fill it with all the .debs we need apt-get --reinstall -dy install $(dpkg --get-selections | grep '[[:space:]]install' | cut -f1) DIR=$(mktemp -d -t info-XXXXXX) for deb in /var/cache/apt/archives/*.deb do # Move to working directory cd "$DIR" # Create DEBIAN directory mkdir -p DEBIAN # Extract control files dpkg-deb -e "$deb" # Extract file list, fixing up the leading ./ and turning / into /. dpkg-deb -c "$deb" | awk '{print $NF}' | cut -c2- | sed -e 's/^\/$/\/./' > DEBIAN/list # Figure out binary package name DEB=$(basename "$deb" | cut -d_ -f1) # Copy each control file into place cd DEBIAN for file in * do cp -a "$file" /var/lib/dpkg/info/"$DEB"."$file" done # Clean up cd .. rm -rf DEBIAN done rmdir "$DIR"
原理是重新下載所有安裝過的軟件包,然后從中提取文件列表信息復制到info文件夾里。
執行完畢后提示x11-common有空文件列表,(其它的是從別的ubuntu上拷貝了x11-common的文件),我的解決辦法是編輯/var/lib/dbkg/status文件,找到開頭為 Package: x11-common的那一段,然后刪除,再重新安裝,代碼如下
vi /var/lib/dbkg/status 刪除x11-common那一段 apt-get --reinstall install x11-common