![为什么“软件包可以更新”和“apt list --upgradeable”不匹配?](https://linux22.com/image/1153520/%E4%B8%BA%E4%BB%80%E4%B9%88%E2%80%9C%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%8F%AF%E4%BB%A5%E6%9B%B4%E6%96%B0%E2%80%9D%E5%92%8C%E2%80%9Capt%20list%20--upgradeable%E2%80%9D%E4%B8%8D%E5%8C%B9%E9%85%8D%EF%BC%9F.png)
当我登录到我的 Ubuntu VM 时,我收到以下消息,通知我有 8 个软件包可以升级:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-112-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
8 packages can be updated.
0 updates are security updates.
Last login: Mon Jan 29 14:55:34 2018 from 172.16.117.1
然而,当我发出时,apt list --upgradeable
我收到了 26 个包裹。
$ apt list --upgradeable
Listing... Done
cloud-initramfs-copymods/xenial-updates,xenial-updates 0.27ubuntu1.5 all [upgradable from: 0.27ubuntu1.4]
cloud-initramfs-dyn-netconf/xenial-updates,xenial-updates 0.27ubuntu1.5 all [upgradable from: 0.27ubuntu1.4]
cpp-5/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
distro-info-data/xenial-updates,xenial-updates 0.28ubuntu0.7 all [upgradable from: 0.28ubuntu0.3]
g++-5/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
gcc-5/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
gcc-5-base/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libasan2/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libatomic1/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libcc1-0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libcilkrts5/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libgcc-5-dev/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libgnutls-openssl27/xenial-updates 3.4.10-4ubuntu1.4 amd64 [upgradable from: 3.4.10-4ubuntu1.3]
libgnutls30/xenial-updates 3.4.10-4ubuntu1.4 amd64 [upgradable from: 3.4.10-4ubuntu1.3]
libgomp1/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libitm1/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
liblsan0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libmpx0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libquadmath0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libseccomp2/xenial-updates 2.3.1-2.1ubuntu2~16.04.1 amd64 [upgradable from: 2.2.3-3ubuntu3]
libstdc++-5-dev/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libstdc++6/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libtsan0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
libubsan0/xenial-updates 5.4.0-6ubuntu1~16.04.6 amd64 [upgradable from: 5.4.0-6ubuntu1~16.04.5]
python3-update-manager/xenial-updates,xenial-updates 1:16.04.10 all [upgradable from: 1:16.04.7]
update-manager-core/xenial-updates,xenial-updates 1:16.04.10 all [upgradable from: 1:16.04.7]
为什么不匹配?
答案1
它们在不同的时间运行。
项目会随时上传到存储库(而不是每天一次),因此如果您在一天中的不同时间比较--upgradable,那么随着时间的推移,您将获得越来越多的结果。
Apt 不会在启动时检查软件包 - 这会不必要地延迟启动。登录消息(每日消息 [motd] 的一部分)是在 apt-daily 的每日运行期间生成的...在之前的某个会话期间(例如昨天)。文本是为下次登录而生成和保存的。它的目的是提醒,缺乏准确性是一个众所周知的小问题。