天天看點

ubuntu apt-get 遇到的問題

裝軟體的時候總是提示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檔案夾裡。(是以請在網速較好的時候使用)

下一篇: mysql