在 Ubuntu 22.04.1 LTS 上运行apt-get dist-upgrade
会导致各种软件包被保留:
root@localhost:/var/log/apt# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-signed libnss-mymachines libnss-systemd libpam-systemd libpython3-dev libpython3-stdlib libpython3.10 libpython3.10-dev libpython3.10-minimal libpython3.10-stdlib libsystemd0 libudev1
python3 python3-dev python3-distutils python3-gdbm python3-lib2to3 python3-minimal python3-tk python3.10 python3.10-dev python3.10-minimal systemd systemd-container systemd-sysv systemd-timesyncd udev
The following packages will be upgraded:
bind9-dnsutils bind9-host bind9-libs libpcre2-8-0 python3-oauthlib
5 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
5 standard security updates
Need to get 1,719 kB of archives.
After this operation, 3,072 B of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
有效更新此类软件包的唯一方法是在命令行上主动指定它们:
root@localhost:/var/log/apt# apt-get dist-upgrade grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-signed libnss-mymachines libnss-systemd libpam-systemd libpython3-dev libpython3-stdlib libpython3.10 libpython3.10-dev libpython3.10-minimal libpython3.10-stdlib libsystemd0 libudev1 python3 python3-dev python3-distutils python3-gdbm python3-lib2to3 python3-minimal python3-tk python3.10 python3.10-dev python3.10-minimal systemd systemd-container systemd-sysv systemd-timesyncd udev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
systemd-hwe-hwdb
The following packages will be upgraded:
bind9-dnsutils bind9-host bind9-libs grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-signed libnss-mymachines libnss-systemd libpam-systemd libpcre2-8-0 libpython3-dev libpython3-stdlib libpython3.10 libpython3.10-dev
libpython3.10-minimal libpython3.10-stdlib libsystemd0 libudev1 python3 python3-dev python3-distutils python3-gdbm python3-lib2to3 python3-minimal python3-oauthlib python3-tk python3.10 python3.10-dev python3.10-minimal systemd
systemd-container systemd-sysv systemd-timesyncd udev
34 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
5 standard security updates
Need to get 23.5 MB of archives.
After this operation, 545 kB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
据我了解,apt dist-upgrade
应该自动更新所有软件包。为什么它拒绝这样做?
答案1
经过一些调试,我发现这是由于分阶段更新没有选择我的机器来应用更新。通过-oAPT::Get::Always-Include-Phased-Updates=1
强制禁用它apt-get dist-upgrade
来更新任何东西。
否则,人们可以使用它aptitude full-upgrade
来获取所有更新,而不管其分阶段更新状态如何。
答案2
关于手动的
upgrade 和 dist-upgrade 之间的区别
apt(-get) 升级
用于从 /etc/apt/sources.list(5) 中枚举的源安装系统中当前安装的所有软件包的最新版本。检索和升级当前安装且有新版本的软件包;在任何情况下都不会删除当前安装的软件包,也不会检索和安装尚未安装的软件包。如果当前安装的软件包的新版本无法在不更改其他软件包的安装状态的情况下升级,则将保留其当前版本。必须先执行更新,以便 apt-get 知道有新版本的软件包可用。
apt(-get) dist-upgrade
除了执行升级功能之外,此选项还可以智能地处理软件包新版本的变化依赖关系;apt-get 具有“智能”冲突解决系统,如果有必要,它会尝试以牺牲不太重要的软件包为代价来升级最重要的软件包。
有一个类似的命令apt-getdist-grade,是易于全面升级。
结论
- 简单地说,升级仅尝试无冲突的软件包,这些软件包通常不会以任何方式破坏系统。
- 而 dist-upgrade,正如其名称所示,对系统进行升级。此操作可以破坏你的系统。