在 archlinux 下可以直接通过 pacman -Syu --ingore 来跳过指定包进行升级,然而 ubuntu 下的 apt 居然不提供类似的排除选项,这很让我感到吃惊,不过网上 apt 的内容倒是蛮多,经过简单的搜索,很容易找到解决方法。
sudo apt-mark hold emacs-snapshot
emacs-snapshot set on hold.
sudo apt upgrade -y
sudo apt-mark unhold emacs-snapshot
Canceled hold on emacs-snapshot.
如果没有 apt-mark 命令,则还可以使用 dpkg --set-selections 来保留软件包,关于它的 manual 如下:
--set-selections
Set package selections using file read from stdin. This file should be in the format “package state”,
where state is one of install, hold, deinstall or purge. Blank lines and comment lines beginning with
‘#’ are also permitted.
The available file needs to be up-to-date for this command to be useful, otherwise unknown packages
will be ignored with a warning. See the --update-avail and --merge-avail commands for more information.
所以步骤可以修改为
echo "emacs-snapshot hold" |sudo dpkg --set-selections
sudo apt upgrade -y
echo "emacs-snapshot install" |sudo dpkg --set-selections
