linux系统阻止更新某些包(debian,redhat系)

引言

termux中的mesa新版本引入了SVE特性,但是设备不支持SVE导致llvmpipe无法正常运行,但是我有习惯让软件包保持最新,为了保持mesa相关的软件包不被更新,可以通过一些命令使其保持固有版本。
这里提出了几点需要组织更新的理由:

  • 某个驱动版本和硬件兼容性更好;
  • 某些软件的新版本存在 Bug;
  • 自己编译安装了某个软件,怕被 apt 覆盖。

apt-mark方案

Debian 或 Ubuntu 系统的用户

阻止更新:

sudo apt-mark hold <包名>

取消阻止

sudo apt-mark unhold <包名>

示例

u0_a258@localhost  ~  apt-mark hold firefox
firefox set on hold.
u0_a258@localhost  ~  apt-mark unhold firefox
Canceled hold on firefox.

查看被阻止更新的包

u0_a258@localhost  ~  apt-mark showhold
mesa
mesa-dev
mesa-vulkan-icd-freedreno
mesa-vulkan-icd-swrast

Redhat发行版

CentOS / RHEL / AlmaLinux

全局排除

编辑 yum/dnf 配置文件:

sudo nano /etc/yum.conf

添加或修改如下内容:

exclude=kernel* firefox

说明:可以使用通配符 *,多个包用空格分隔。

保存后,yum update 或 dnf upgrade 将不会升级这些包。

针对某个 repo 排除

编辑特定的 repo 文件,例如:

sudo nano /etc/yum.repos.d/epel.repo

在 [epel] 段内添加:

exclude=somepackage*

结语

建议定期检查锁定状态,避免忘记解锁影响长期更新。更新未必是坏事。

评论 0

还没有评论,来说点什么吧。

提交后需要审核才会公开。