不知何故,我的apt
系统在我的 Ubuntu 20.04.4 系统上被淹没了,现在有超过 1,800 个软件包被标记为需要卸载。
这是来自Xubuntu
安装,这意味着我正在运行xfce
桌面。
我知道解决此类apt
问题的推荐方法是apt autoremove
重新安装软件包。但是,如果我这样做,我的系统将在 之后完全无法使用apt autoremove
,因为我系统的大部分软件包都已被卸载。
我正在寻找一种替代方法来修复我的apt
数据库,这样我就不必apt autoremove
为了更正apt
.
为了说明apt
我系统上的状态,这里是我运行的一些东西......
% sudo apt-get install -f
[returns a list of the names of the 1,800 packages]
% sudo dpkg configure -a
[no output]
% sudo aptitude search ?broken
[no output]
% sudo cat /var/log/apt/history.log
Start-Date: 2022-05-04 18:01:54
Requested-By: [MYUSERID] (1000)
Upgrade: networkd-dispatcher:amd64 (2.1-2~ubuntu20.04.2, 2.1-2~ubuntu20.04.3), libvirt-daemon-system-systemd:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), openssl:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), librbd1:amd64 (15.2.14-0ubuntu0.20.04.2, 15.2.16-0ubuntu0.20.04.1), google-chrome-stable:amd64 (101.0.4951.41-1, 101.0.4951.54-1), libvirt-clients:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), iio-sensor-proxy:amd64 (2.8-1ubuntu1, 2.8-1ubuntu2), libvirt-daemon-driver-storage-rbd:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libpq5:amd64 (12.9-0ubuntu0.20.04.1, 12.10-0ubuntu0.20.04.1), ubuntu-drivers-common:amd64 (1:0.9.0~0.20.04.6, 1:0.9.0~0.20.04.7), libvirt-daemon-driver-qemu:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libvirt-daemon-system:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), libssl-dev:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libssl-doc:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libmysqlclient21:amd64 (8.0.28-0ubuntu0.20.04.3, 8.0.29-0ubuntu0.20.04.2), libmysqlclient21:i386 (8.0.28-0ubuntu0.20.04.3, 8.0.29-0ubuntu0.20.04.2), libvirt0:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16), lm-sensors:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libsensors-config:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libssl1.1:amd64 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libssl1.1:i386 (1.1.1f-1ubuntu2.12, 1.1.1f-1ubuntu2.13), libsensors5:amd64 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), libsensors5:i386 (1:3.6.0-2ubuntu1, 1:3.6.0-2ubuntu1.1), librados2:amd64 (15.2.14-0ubuntu0.20.04.2, 15.2.16-0ubuntu0.20.04.1), libvirt-daemon:amd64 (6.0.0-0ubuntu8.15, 6.0.0-0ubuntu8.16)
End-Date: 2022-05-04 18:02:47
% sudo ls -l /etc/apt/sources.list
4 -rw-r--r-- 1 root root 3280 Jan 19 17:24 /etc/apt/sources.list
[note that the file hasn't changed in a few months]
% sudo ls -l /etc/apt/sources.list.d
total 16
4 -rw-r--r-- 1 root root 190 Jan 19 17:24 google-chrome.list
4 -rw-r--r-- 1 root root 190 Jan 19 17:24 google-chrome.list.save
4 -rw-r--r-- 1 root root 56 Apr 14 11:06 skype-stable.list
4 -rw-r--r-- 1 root root 56 Jan 19 17:24 skype-stable.list.save
[note that none of this has changed recently]
% sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:3 http://dl.winehq.org/wine-builds/ubuntu focal InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:6 http://archive.canonical.com/ubuntu focal InRelease
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [391 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B]
Get:11 http://us.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [9,568 B]
Get:12 http://us.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.8 kB]
Hit:13 https://repo.skype.com/deb stable InRelease
Get:14 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.6 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.3 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 1,155 kB in 2s (555 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
% sudo grep -r "^deb" /etc/apt/ --include=*.list
/etc/apt/sources.list.d/google-chrome.list:deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
/etc/apt/sources.list.d/skype-stable.list:deb [arch=amd64] https://repo.skype.com/deb stable main
/etc/apt/sources.list.d.save/alex-p-ubuntu-aegisub-focal.list:deb http://ppa.launchpad.net/alex-p/aegisub/ubuntu focal main
/etc/apt/sources.list.d.save/teamviewer.list:deb https://linux.teamviewer.com/deb stable main
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
/etc/apt/sources.list:deb http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:deb-src http://archive.canonical.com/ubuntu focal partner
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu focal-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list:deb http://dl.winehq.org/wine-builds/ubuntu/ focal main
过去我遇到过类似的问题,我在以下帖子的“答案”部分中描述了该问题:apt忘记了超过 1,000 个软件包,并且我无法重新安装……答案以“我想出了如何解决这个问题......”
但是,这似乎是解决此问题的一种 hack-y 方法,我不确定如果我现在运行它会有多可靠。
任何人都可以建议任何其他方法来解决这个问题,sudo apt autoremove
而无需我过去使用的那种 hack-y 方法?
非常感谢您提前。
PS:我每天对我的系统进行备份。是否有任何文件或目录可以从我的最新备份中恢复,其中包含apt
数据库的非损坏版本?
PPS:我尝试xubuntu-desktop
按照以下评论中的说明进行安装。可悲的是,它没有帮助......
% sudo apt install xubuntu-desktop
Reading package lists... Done
Building dependency tree
Reading state information... Done
xubuntu-desktop is already the newest version (2.233).
xubuntu-desktop set to manually installed.
The following packages were automatically installed and are no longer required:
[list of 1,800 package names, followed by ...]
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
并且所有这些软件包仍然标记为需要卸载。
我解决了这个问题。
重新安装
xubuntu-desktop
and后xubuntu-core
,我的问题仍然存在。因此,我认为问题不只是由于依赖关系树顶部缺少一个安装,而是整个apt
数据库可能以某种方式损坏了。所以,我放弃了捷径,我交叉手指,最后我硬着头皮做了一些我过去所做的事情,如我在此处的回答中所述:apt忘记了超过 1,000 个包,我'无法重新安装
这一次,我只安装了每个包,而不是每次安装前的初始删除,并且它有效。这是我采取的步骤...
步骤1:
运行后,该
apt-installs
文件包含此数据...第2步:
我编辑了这个
apt-installs
文件以删除顶部 4 行和底部 2 行,并重新格式化它,以便每行有一个包名称。第 3 步:
我将字符串添加
fixit
到每行的开头。第4步:
我创建了一个调用
fixit
来安装指定包的 shell 函数,并将该函数放在apt-installs
文件的顶部。现在,这就是前十几行的apt-installs
样子......第 5 步:
我跑了这个:
这运行了大约 30 分钟并重新安装了每个软件包。从函数中可以看出,在 each 之前
fixit
没有做任何事情。remove
install
第 6 步:
然后我运行了这两个命令...
这与数据库
aptitude
重新同步。apt
现在一切似乎都恢复正常了。
我猜如果我知道
apt
要从最近的备份中重新安装哪些相关文件/目录,我也可以通过这种方式解决问题。但是,我对 的底层内部结构了解得不够多apt
,而且我无法快速弄清楚需要恢复哪些项目。为了将来参考,我想知道有关如何恢复
apt
数据库的这些信息,因为如果再次发生此类问题,它将更容易解决。非常感谢user535733!