今天想要用 apt-get, 結果冒出 Unable to locate package git-fame
cashchou@server: ~ $ sudo apt-get install git-fame
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package git-fame
為了消除 Unable to locate package, 據說要清理 source list, 很多人是因為網路的關係連不上 ubuntu, 但我確定都連得上, 所以不用改 source list. 而是可以試著 update. 結果在 apt-get update 的時候, 看到一堆類似的 warning. 像是:
W: Failed to fetch http://tw.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease Unable to find expected entry ‘ main/binary-foreign-architecture/Packages’ in Release file (Wrong sources.list entry or malformed file)
之類的東西. 話說 main 和 Packages 中間應該是出現 architecture 沒錯, 但應該是 amd64, i386 這種 architecture, 而不是直接來個 foreign architecture 吧!
cashchou@server: /etc/apt $ dpkg –print-architecture
amd64
cashchou@server: /etc/apt $ dpkg –print-foreign-architectures
foreign-architecture
這表示我們 server 的架構是 amd64, 如果曾不小心打成 and64, 或是 i586 打成 1586…這些都會被認為是不相容的外國建築 (foreign-architectures) . 但…這 server 上的外國建築竟然就叫做外國建築吶! 我試著把它刪除, 結果…得到一句繞口令…不能移除不是外國建築的外國建築.
cashchou@server: /etc/apt $ dpkg –remove-architecture foreign-architectures
dpkg: warning: cannot remove non-foreign architecture ‘foreign-architectures’
原來是我忘了 sudo, 加 sudo 硬是把它幹掉之後, apt-get update 就正常了.
sudo dpkg –remove-architecture foreign-architecture
但還是不能 upgrade.
cashchou@server: /etc/apt $ sudo apt-get upgrade
Reading package lists… Done
Building dependency tree
Reading state information… Done
You might want to run ‘apt-get -f install’ to correct these.
The following packages have unmet dependencies: …一大堆錯誤
據說, 此時可以試著 apt-get -f install, 但我試過這招沒用. 因為 unmet 太多了.
…一大堆錯誤
E: Unmet dependencies. Try using -f.
啊 force 也沒用啊!! 根據網路資訊 [1], 接下來的 SOP 就是先自動修復, 依序執行下面幾步. 當然 // 後面不是指令, 只是註解.
sudo apt-get update // update your package list sudo apt-get autoclean // clean up any partial packages sudo apt-get clean // clean up the apt cache sudo apt-get autoremove // will clean up any unneeded dependencies.
還不行的話, 只好逐個修復.
sudo dpkg --remove -force --force-remove-reinstreq package name
弟兄們裝了太多 package, 彼此互相影響, 我沒時間一個一個重裝, 只好留待比較急的人有緣人來處理了~~~
[REF]