1. 查看包依赖
1.1 正向依赖
依赖哪些包
1
| apt-cache depends apparmor
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| apparmor
Depends: debconf # 必须
Depends: lsb-base # 必须
|Depends: debconf # 必须
Depends: <debconf-2.0> # 多选一
cdebconf
debconf
Depends: libc6 # 必须
Breaks: apparmor-profiles-extra # 不兼容
Breaks: fcitx-data # 不兼容
Breaks: snapd # 不兼容
Suggests: apparmor-profiles-extra # 建议安装
Suggests: apparmor-utils # 建议安装
Replaces: fcitx-data # 用于替代后者
|
1
| apt-cache depends --installed apparmor
|
1
2
| apt show apparmor
dpkg -s apparmor | grep -E '^(Package|Version|Depends|Pre-Depends|Recommends|Suggests|Conflicts|Breaks|Replaces):'
|
1.2 反向依赖
谁依赖这个包
1
| apt-cache rdepends golang-github-containers-common
|
1
| apt-cache rdepends --installed golang-github-containers-common
|
1
2
3
4
5
6
| golang-github-containers-common
Reverse Depends:
skopeo
podman
buildah
podman
|
1
| aptitude why golang-github-containers-common
|
1
2
3
| i devscripts Suggests autopkgtest
p autopkgtest Suggests podman
p podman Depends golang-github-containers-common
|
1
| aptitude why-not golang-github-containers-common
|
1.3 依赖树与冲突
模拟安装与文件反查
1
| apt-cache showpkg apparmor
|
1
| apt install --simulate apparmor
|
1
| dpkg -S /usr/bin/apparmor
|
1.4 第三方与非官方源包
Snap、手工安装等需单独排查
1
| apt-cache policy apparmor
|
1
| cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
|
1
| which apparmor && file "$(which apparmor)"
|
2. 查看包的变更历史
2.1 本机变更记录
最近什么时候装、升、删过
1
| less /var/log/apt/history.log
|
1
2
| zgrep -h apparmor /var/log/apt/history.log* /var/log/dpkg.log*
grep -E 'install|upgrade|remove' /var/log/apt/history.log | grep apparmor
|
Start-Date: 2026-07-10 14:32:01
Commandline: apt upgrade
Upgrade: apparmor:amd64 (3.0.4-2ubuntu2, 1.18.0-6ubuntu14.5)
End-Date: 2026-07-10 14:32:15
2.2 上游变更记录
这个包在仓库里改过什么
1
| apt changelog apparmor | less
|
1
| apt-cache policy apparmor
|
1
| apt-cache madison apparmor
|
Ubuntu 官方还可查 Launchpad 上对应源码包的 changelog 与 bugs,适合看跨多个版本的修复记录。
2.3 版本差异对比
升级前后文件变化
1
| dpkg-deb -c /var/cache/apt/archives/apparmor_*.deb | head
|
1
| dpkg -L apparmor > /tmp/apparmor-files.txt
|
3. 固定包的版本
3.1 锁定版本 hold
禁止指定包被升级
1
| apt-mark unhold apparmor
|
适合核心中间件(apparmor、mysql、内核)及已知有 breaking change 的版本。
3.2 安装时指定版本
安装或降级到指定版本
1
| apt-cache madison apparmor
|
1
| apt install --simulate apparmor=3.0.4-2ubuntu2
|
1
| apt install apparmor=3.0.4-2ubuntu2
|
3.3 升级前预览
先看会动哪些包再执行
1
| apt-get -s dist-upgrade
|
- 安装 apt-listchanges 显示变更说明
1
| apt install apt-listchanges
|