一个好友的国外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