do-release-upgrade 20.04->22.04 挂起,最后一个 main.log 行是“正在运行 doUpdate() (showErrors=True)”

do-release-upgrade 20.04->22.04 挂起,最后一个 main.log 行是“正在运行 doUpdate() (showErrors=True)”

从一台运行着 Ubuntu 18.04 桌面版的 PC 开始,我复制了整个驱动器作为备份,然后尝试将其升级到 22.04。运行 do-release-upgrade 将其升级到 20.04,它似乎运行得很好。几次重启后,我尝试将其从 20.04 升级到 22.04。它总是挂在同一个位置,就在之后:

Get:184 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe DEP-11 64x64 Icons [13.4 kB]
Get:185 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe amd64 c-n-f Metadata [480 B]
Get:186 http://ports.ubuntu.com/ubuntu-ports jammy-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 504 MB in 6s (0 B/s)

我把它这样放了至少几个小时。它卡住了。按 Control-C 退出,回溯如下:

Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 27, in <module>
    col.create(db)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 95, in create
    self._fill_commands(con)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 140, in _fill_commands
    if sub.wait() != 0:
  File "/usr/lib/python3.8/subprocess.py", line 1083, in wait
    return self._wait(timeout=timeout)
  File "/usr/lib/python3.8/subprocess.py", line 1806, in _wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.8/subprocess.py", line 1764, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)

在工作中,我们有一个虚拟机也遇到了同样的问题,从 20.04 升级到 22.04。最后他们只是制作了一个新的 22.04 虚拟机。我在这台电脑上做了一些工作,所以可能是某个特定的软件包出了问题,而且两个系统都安装了这个软件包。

当它处于该状态时:

# tail -n 10 /var/log/dist-upgrade/main.log
2023-04-02 12:29:04,801 DEBUG url_downloadable: http://ports.ubuntu.com/ubuntu-ports//dists/jammy/Release
2023-04-02 12:29:04,801 DEBUG s='http' n='ports.ubuntu.com' p='/ubuntu-ports//dists/jammy/Release' q='' f=''
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,980 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse'
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,980 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse'
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,981 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse'
2023-04-02 12:29:04,981 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,986 DEBUG running doUpdate() (showErrors=True)

我尝试了其他帖子中建议的许多不同方法。例如,我将所有 .list 文件从 /etc/apt/ 和 /etc/apt/sources.list.d/ 中移出,这些文件中除了“focal”之外还列出了其他内容(有些是“bionic”)。例如,我可以在重启后运行这些命令,但仍然遇到同样的问题:

apt-get clean
apt --fix-broken install
apt-get update
apt-get upgrade
apt-get clean
do-release-upgrade

dpkg --print-architecture 和 dpkg --print-foreign-architectures 请编辑您的问题。

scott@scott-XPS-8900:~$ dpkg --print-architecture
amd64
scott@scott-XPS-8900:~$ dpkg  --print-foreign-architectures
i386
arm64

上述工作内容涉及为 arm64 进行编译。我不确定为什么 i386 在那里(编辑:“dpkg --list | grep i36”显示“syslinux-legacy”)。

更新:不再有任何外部架构。我清除了这些软件包,并删除了 i386 和 arm64 架构,如中所述如何从 Ubuntu 64 位中删除所有 i386 包?。 没提升。

我发现 python/python3 的某些部分坏了。 sudo apt update

我之前尝试过:

sudo apt-get install --reinstall python3-apt

目前“apt update”挂了。之前它没有这样做:

scott@scott-XPS-8900:~$ sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://ca.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://ca.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://ca.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Hit:6 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
Hit:7 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Hit:8 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease

(然后它就呆在那里)几分钟后,按 Control-C:

Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 27, in <module>
    col.create(db)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 95, in create
    self._fill_commands(con)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 140, in _fill_commands
    if sub.wait() != 0:
  File "/usr/lib/python3.8/subprocess.py", line 1083, in wait
    return self._wait(timeout=timeout)
  File "/usr/lib/python3.8/subprocess.py", line 1806, in _wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.8/subprocess.py", line 1764, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)

为什么 ports.ubuntu.com repo 仍然活跃?

看来它们是我之前启用外部架构(i386、arm64)时遗留下来的。我将它们注释掉/etc/apt/sources.list并再次运行apt update。它仍然挂起。

然后我尝试:

sudo pkill cnf-update-db
sudo rm -rf /var/lib/apt/lists/*
sudo apt update``

它再次挂起,并且 control-C 产生与上面相同的堆栈跟踪。

在对 control-C 回溯中的 Python 代码进行深入研究并进行了大量搜索之后,我发现:CommandNotFound.db.creator 在 ubuntu 上导入 DbCreator

那开始apt-get update了:

sudo apt-get remove --purge python3-apt
sudo apt autoremove
apt-get install python3-apt
# Probably most of the next few commands weren't needed
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get check
sudo apt --fix-broken install
sudo apt-get update

我将重新启动并重试do-release-upgrade,然后报告结果。(更新:它起作用了——请参阅我发布的解决方案)

答案1

在我尝试了大量方法(问题中列出)之后,do-release-upgrade终于可以正常运行。我的电脑现在运行的是 Ubuntu 22.04。

我怀疑清除并安装python-apt(我从CommandNotFound.db.creator 在 ubuntu 上导入 DbCreator)是最重要的一步,但它可能只是最后的重要步骤:

sudo apt-get remove --purge python3-apt
sudo apt autoremove
apt-get install python3-apt

我原来的问题解决了,但do-release-upgrade报告了一些错误。我建议遇到同样问题的人先清除python3-apt/安装,然后尝试do-release-upgrade,如果不起作用,再做我试过的其他事情。

Errors were encountered while processing:
 openmpi-bin
 mpi-default-bin
 libcoarrays-openmpi-dev:amd64
 libopenmpi-dev:amd64
 libboost-mpi-python1.74.0
 libboost-mpi-python1.74-dev
 libboost-mpi-python-dev
 libboost-all-dev
 mpi-default-dev
 libboost-mpi1.74-dev
 libboost-mpi-dev

Upgrade complete

The upgrade has completed but there were errors during the upgrade
process.

我这样解决了这些问题(主要基于软件包安装问题 - linux-image-server):

dpkg --remove --force-remove-reinstreq  openmpi-bin
dpkg --remove --force-remove-reinstreq  mpi-default-bin
dpkg --remove --force-remove-reinstreq  libcoarrays-openmpi-dev:amd64
dpkg --remove --force-remove-reinstreq  libopenmpi-dev:amd64
dpkg --remove --force-remove-reinstreq  libboost-mpi-python1.74.0
dpkg --remove --force-remove-reinstreq  libboost-mpi-python1.74-dev
dpkg --remove --force-remove-reinstreq  libboost-mpi-python-dev
dpkg --remove --force-remove-reinstreq  libboost-all-dev
dpkg --remove --force-remove-reinstreq  mpi-default-dev
dpkg --remove --force-remove-reinstreq  libboost-mpi1.74-dev
dpkg --remove --force-remove-reinstreq  libboost-mpi-dev

# ... but one package was more stubborn, indicating:
# update-alternatives: error: /var/lib/dpkg/alternatives/mpi corrupt: slave link same as main link /usr/bin/mpicc
# Fixed with:
sudo update-alternatives --remove-all mpi
sudo rm /var/lib/dpkg/alternatives/mpi
sudo dpkg --remove --force-remove-reinstreq openmpi-bin

# then checking for errors:
apt autoremove
apt upgrade

现在一切都好了。

相关内容