在dist-upgrade期间如何禁止删除某些包?

时间:2016-11-25 08:28:54

标签: debian apt

有没有办法禁止apt(apt-get)在dist-upgrade期间删除特定包,但允许升级/降级?

2 个答案:

答案 0 :(得分:0)

要防止升级特定包,您应将其置于保持状态:

您可以使用以下方式持有套餐:

sudo apt-mark hold package_name

sudo aptitude hold package_name

或者:

echo "package_name hold" | sudo dpkg --set-selections

要删除保留,您应该运行:

sudo apt-mark unhold package_name

sudo aptitude unhold package_name

echo "package_name install" | sudo dpkg --set-selections

将软件包列入黑名单:

您可以在/etc/apt/apt.conf.d/01autoremove下添加您的软件包,编辑您的文件,然后在Never-MarkAuto-Sections下添加所需的软件包

答案 1 :(得分:0)

我尝试使用Equiv解决方案:

创建一个如下所示的控制文件:

Section: misc
Priority: optional
Standards-Version: 3.9.2

Package: my-dummy-essential
Depends: emacs, kdenlive, firefox, kde-plasma-desktop, task-kde-desktop, task-french-kde-desktop, mypaint, keepassxc, tmux, zsh, openssh-client
Prerm: my-prerm
Description: just a package that refuse to be unistalled

Depends行应包含要保护的软件包的列表,

prerm行引用了一个脚本(这里称为my-prerm):

#!/bin/sh -e
    
if [ "$1" != remove ]; then
    exit 0
fi
    
echo "are you sure about removing your essential package? (y/N)"
read i
if [ "x$i" = "xy" ]; then
   exit 0
fi
    
false

这个想法是,此prerm脚本将失败(除非您接受删除程序包),这将阻止程序包及其依赖项的删除。