[Ubuntu] 意外移除了 APT 套件管理程式的復原方法

本篇文章更新時間:2022/06/01
如有資訊過時或語誤之處,歡迎使用 Contact 功能通知。
一介資男的 LINE 社群開站囉!歡迎入群聊聊~
如果本站內容對你有幫助,歡迎使用 BFX Pay 加密貨幣新台幣 贊助支持。


前幾天把一台 Ubuntu 16.04 的主機升級到 18.04,然後這樣升級並沒有比直接安裝好,反而還導致一堆舊套件被卡在原本版本上沒有更新。

就在這個反覆移除->更新的過程中,意外的關聯到 APT 這個套件管理程式的工具,移除後整個有點傻眼,就沒辦法繼續「管理」了XD

好在這種事肯定不是我第一個發生,方向也大概確認:就是手動把他裝回來吧!

[email protected]:~/apt# wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.12ubuntu0.2_amd64.deb
Saving to: ‘apt_1.6.12ubuntu0.2_amd64.deb’

apt_1.6.12ubuntu0.2_amd64.deb             100%[=====================================================================================>]   1.15M   809KB/s    in 1.5s

[email protected]:~/apt# wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.12ubuntu0.2_amd64.deb

Saving to: ‘libapt-pkg5.0_1.6.12ubuntu0.2_amd64.deb’

libapt-pkg5.0_1.6.12ubuntu0.2_amd64.deb   100%[=====================================================================================>] 787.23K   566KB/s    in 1.4s

[email protected]:~/apt# wget http://security.ubuntu.com/ubuntu/pool/main/u/ubuntu-keyring/ubuntu-keyring_2018.02.28_all.deb

Saving to: ‘ubuntu-keyring_2018.02.28_all.deb’

ubuntu-keyring_2018.02.28_all.deb         100%[=====================================================================================>]  20.21K  75.9KB/s    in 0.3s

[email protected]:~/apt# dpkg -i ubuntu-keyring_2018.02.28_all.deb

[email protected]:~/apt# dpkg -i libapt-pkg5.0_1.6.12ubuntu0.2_amd64.deb

[email protected]:~/apt# dpkg -i apt_1.6.12ubuntu0.2_amd64.deb
dpkg: regarding apt_1.6.12ubuntu0.2_amd64.deb containing apt:
 apt breaks apt-transport-https (<< 1.5~alpha4~)
  apt-transport-https (version 1.2.35) is present and installed.

dpkg: error processing archive apt_1.6.12ubuntu0.2_amd64.deb (--install):
 installing apt would break apt-transport-https, and
 deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
 apt_1.6.12ubuntu0.2_amd64.deb

[email protected]:~/apt# dpkg -r apt-transport-https
dpkg: dependency problems prevent removal of apt-transport-https:
 ubuntu-advantage-tools depends on apt-transport-https (>= 1.2.32).

dpkg: error processing package apt-transport-https (--remove):
 dependency problems - not removing
Errors were encountered while processing:
 apt-transport-https

[email protected]:~/apt# dpkg -r ubuntu-advantage-tools
(Reading database ... 39144 files and directories currently installed.)
Removing ubuntu-advantage-tools (27.8~16.04.1) ...
Processing triggers for man-db (2.8.3-2) ...

[email protected]:~/apt# dpkg -i apt_1.6.12ubuntu0.2_amd64.deb
dpkg: regarding apt_1.6.12ubuntu0.2_amd64.deb containing apt:
 apt breaks apt-transport-https (<< 1.5~alpha4~)
  apt-transport-https (version 1.2.35) is present and installed.

dpkg: error processing archive apt_1.6.12ubuntu0.2_amd64.deb (--install):
 installing apt would break apt-transport-https, and
 deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
 apt_1.6.12ubuntu0.2_amd64.deb

[email protected]:~/apt# dpkg -r apt-transport-https
(Reading database ... 39063 files and directories currently installed.)
Removing apt-transport-https (1.2.35) ...

[email protected]:~/apt# dpkg -i apt_1.6.12ubuntu0.2_amd64.deb
dpkg: regarding apt_1.6.12ubuntu0.2_amd64.deb containing apt:
 apt breaks apt-utils (<< 1.3~exp2~)
  apt-utils (version 1.2.35) is present and installed.

dpkg: error processing archive apt_1.6.12ubuntu0.2_amd64.deb (--install):
 installing apt would break apt-utils, and
 deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
 apt_1.6.12ubuntu0.2_amd64.deb

[email protected]:~/apt# dpkg -r apt-utils

[email protected]:~/apt# dpkg -i apt_1.6.12ubuntu0.2_amd64.deb

[email protected]:~/apt# apt -v

apt 1.6.12ubuntu0.2 (amd64)

上面是我操作的過程,先是抓 apt_1.6.12ubuntu0.2_amd64.deb, libapt-pkg5.0_1.6.12ubuntu0.2_amd64.deb, ubuntu-keyring_2018.02.28_all.deb 這三個檔案下來,然後開始進行安裝。

過程中看到「apt breaks apt-transport-https 」錯誤就移除 apt-transport-https,移除過程中又出現「dpkg: dependency problems prevent removal of apt-transport-https: ubuntu-advantage-tools depends on apt-transport-https」錯誤也是繼續移除 ubuntu-advantage-toolsapt-utils,最後輾轉才把 apt_1.6.12ubuntu0.2_amd64.deb 給裝好。

裝好後確認 apt -v 看看版本與執行狀態,有出現 apt 1.6.12ubuntu0.2 就正確拉~


Share:

作者: Chun

資訊愛好人士。主張「人人都該為了偷懶而進步」。期許自己成為斜槓到變進度條 100% 的年輕人。[///////////____36%_________]

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *


文章
Filter
Apply Filters
Mastodon