从 Ubuntu 16.04 LTS 升级到 18.04 LTS 后无法升级软件包(未满足依赖项)

从 Ubuntu 16.04 LTS 升级到 18.04 LTS 后无法升级软件包(未满足依赖项)

我在 Linux 机器上运行游戏服务器,刚刚从 Ubuntu 16.04 LTS 升级到 18.04 LTS。通过 SSH(命令行)进行连接。

服务器重启正常。

我看到我有 310 个更新可以应用。

我用了:

sudo apt-get update
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. 
grub-pc: Depends: grub-common (= 2.02-2ubuntu8.23) 
grub-pc-bin : Depends: grub-common (= 2.02-2ubuntu8.23) 
grub2-common : Depends: grub-common (= 2.02-2ubuntu8.23) 
python3-apt : Depends: libapt-inst2.0 (>= 1.6.5~) but 1.2.35 is installed
Depends: libapt-pkg5.0 (>= 1.6.5~) but 1.2.35 is installed 
systemd : Depends: libsystemd0 (= 229-4ubuntu21.31) but 237-3ubuntu10.53 is installed 
udev : Depends: libudev1 (= 229-4ubuntu21.31) but 237-3ubuntu10.53 is installed 
E: Unmet dependencies. Try using -f.

接下来我尝试:

sudo apt -f install

其结果是:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer
required:
cgmanager fonts-ubuntu-font-family-console libcgmanager0
libcryptsetup4
libgomp1 libmpc3 libquadmath0 libsub-name-perl
linux-image-3.13.0-164-generic linux-image-extra-3.13.0-164-generic
python3.5 python3.5-minimal
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apt apt-transport-https apt-utils grub-common libapt-inst2.0
libapt-pkg5.0
libgnutls-openssl27 libgnutls30 libidn2-0 libpam-systemd libtasn1-6
libunistring2 networkd-dispatcher systemd udev
Suggested packages:
apt-doc aptitude | synaptic | wajig dpkg-dev multiboot-doc grub-emu
xorriso
desktop-base gnutls-bin systemd-container
The following packages will be REMOVED
systemd-shim
The following NEW packages will be installed
libidn2-0 libunistring2 networkd-dispatcher
The following packages will be upgraded:
apt apt-transport-https apt-utils grub-common libapt-inst2.0
libapt-pkg5.0
libgnutls-openssl27 libgnutls30 libpam-systemd libtasn1-6 systemd
udev
12 to upgrade, 3 to newly install, 1 to remove and 366 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/9,316 kB of archives.
After this operation, 2,167 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 104742 files and directories currently installed.)
Removing systemd-shim (9-1bzr4ubuntu1) ...
Removing 'diversion of /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service to /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.systemd
by systemd-shim'
dpkg-divert: error: rename involves overwriting
'/usr/share/dbus-1/system-services/org.freedesktop.systemd1.service'
with  different file
'/usr/share/dbus-1/system-services/org.freedesktop.systemd1.service.systemd',
not allowed
dpkg: error processing package systemd-shim (--remove):
installed systemd-shim package post-removal script subprocess
returned error exit status 2 Errors were encountered while processing:
systemd-shim
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试过各种其他命令:

sudo apt clean
sudo apt autoclean

sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get install -f

我仍然遇到相同的错误。

我对 Linux 一无所知(我从想要退休的前任所有者那里“继承”了这台服务器)。据我所知,我现在既不能升级这些软件包,也不能从 18.04 LTS 升级到 20.04 LTS(也尝试了后者)。不过,升级到 20.04 LTS 是我的目标。

有人知道我该怎么做吗?请详细描述,以便我可以按照您的步骤操作。

谢谢!

编辑:根据 guiverc 的建议,我运行了 sudo apt update:

Hit:1 http://de.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://de.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://de.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:5 https://esm.ubuntu.com/infra/ubuntu bionic-infra-security InRelease [7,458 B]
Get:6 https://esm.ubuntu.com/infra/ubuntu bionic-infra-updates InRelease [7,457 B]
Fetched 267 kB in 0s (406 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
378 packages can be upgraded. Run 'apt list --upgradable' to see them.

答案1

好的,一位朋友帮助我处理了依赖关系。我会尝试写下我们在这里所做的事情。

首先,我们尝试手动升级所有依赖项,但是在解决所有依赖项错误后,删除 systemd-shim 后软件包的升级仍然失败。

我们通过删除与 systemd-shim 卸载相关的文件解决了这个问题:

sudo cp /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service /tmp/org.freedesktop.systemd1.service

sudo rm /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service

检查文件是否已被删除

sudo ls -l /usr/share/dbus-1/system-services/org.freedesktop.systemd1.service

它应该说“没有这样的文件或目录”。

然后我们升级依赖项:

sudo apt-get --only-upgrade install systemd udev libpam-systemd libapt-inst2.0 libapt-pkg5.0 grub-common

安装过程没有任何错误,但我的朋友说,只有在下次重启后我们才能确定一切是否正常。由于我现在已经打开了播放器(我以为今天不会完成这个,所以重新打开了我们的游戏进程),所以我会在其他时间重启。希望到时候它会重新打开……

相关内容