我在 AWS EC2 t3a.nano 实例上运行 ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-1087-aws x86_64)。当我通过 SSH 访问我的盒子时,我看到了这个:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-1087-aws x86_64)
* Documentation: [redacted]
* Management: [redacted]
* Support: [redacted]
Get cloud support with Ubuntu Advantage Cloud Guest:
[redacted]
132 packages can be updated.
3 updates are security updates.
为了使我的盒子上的软件保持最新状态,我运行了:
sudo apt-get update
Hit:1 [redacted] xenial InRelease
Hit:2 [redacted] xenial-updates InRelease
Hit:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
Reading package lists... Done
然后我输入:
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:
E: Unmet dependencies. Try using -f.
好的,所以我看到我有依赖问题,所以我尝试:
sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
bzip2 libbz2-1.0
Suggested packages:
bzip2-doc
The following packages will be upgraded:
bzip2 libbz2-1.0
2 upgraded, 0 newly installed, 0 to remove and 126 not upgraded.
1 not fully installed or removed.
Need to get 63.2 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 [redacted] xenial-updates/main amd64 bzip2 amd64 1.0.6-8ubuntu0.2 [32.5 kB]
Get:2 [redacted] xenial-updates/main amd64 libbz2-1.0 amd64 1.0.6-8ubuntu0.2 [30.7 kB]
Fetched 63.2 kB in 0s (3,126 kB/s)
Selecting previously unselected package bzip2.
E: Sub-process /usr/bin/dpkg exited unexpectedly
现在我看到 dpkg 意外退出,我尝试:
sudo dpkg --audit
The following packages are in a mess due to serious problems during
installation. They must be reinstalled for them (and any packages
that depend on them) to function properly:
bzip2 high-quality block-sorting file compressor - utilities
我尝试:
sudo apt-get install bzip2
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:
bzip2 : Depends: libbz2-1.0 (= 1.0.6-8ubuntu0.2) but 1.0.6-8ubuntu0.1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
所以现在我尝试:
sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
bzip2 libbz2-1.0
Suggested packages:
bzip2-doc
The following packages will be upgraded:
bzip2 libbz2-1.0
2 upgraded, 0 newly installed, 0 to remove and 126 not upgraded.
1 not fully installed or removed.
Need to get 0 B/63.2 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously unselected package bzip2.
E: Sub-process /usr/bin/dpkg exited unexpectedly
现在我要绕圈子了。有任何想法吗?
编辑以解决来自@fkraiem 的评论:当我转到 /etc/apt/sources.list 时,我看到:
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb-src http://us-east-2.ec2.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
[...]
您是否建议我将 us-east-2.ec2.archive.ubuntu.com 替换为 packages.ubuntu.com 并重试更新命令?