我想阻止来自 的所有包non-free
,除了我明确命名的包。目前,我有:
/etc/apt/sources.list
:
deb http://ftp.us.debian.org/debian stable main contrib non-free
/etc/apt/preferences.d/non-free_policy
:
Explanation: Disable packages from `non-free` tree by default
Package: *
Pin: release c=non-free
Pin-Priority: -1
(这个想法是,我为每个我想要的非免费包添加一个明确的节。)
但它不起作用:
root@silber:/etc/apt/preferences.d# apt-get -s install firmware-linux-nonfree
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Die folgenden NEUEN Pakete werden installiert:
firmware-linux-nonfree
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
Inst firmware-linux-nonfree (0.43 Debian:8.4/stable [all])
Conf firmware-linux-nonfree (0.43 Debian:8.4/stable [all])
我缺少什么?
答案1
您需要确保您没有其他更通用的引脚优先级,该优先级优先于您的non-free
排除规则。 (这包括APT::Default-Release
为给定版本分配高优先级的配置设置。)
例如,如果您的/etc/apt/preferences
文件(或 中的另一个文件/etc/apt/preferences.d
)包含类似以下内容的内容:
Package: *
Pin: release a=unstable
Pin-Priority: 200
那么unstable
无论组件如何,封装的引脚优先级都是 200。要使其与您的附加文件一起使用,您应该将其更改为
Package: *
Pin: release a=unstable, c=main
Pin-Priority: 200
contrib
(如果您关心的话,请添加一个额外的节)。 (在你的情况下,你stable
当然会这样做。)
您可以通过运行来检查引脚优先级的效果
apt-cache policy
如果您的non-free
-排除配置工作正常,您应该会在 上看到您正在跟踪的所有套件的条目non-free
,引脚优先级为 -1。一旦它起作用,您将发现您无法再安装raccoon
,或者事实上任何non-free
软件包(即使明确提到) - 您需要将non-free
所需的软件包添加到您的配置文件中,并具有适当的引脚优先级。
作为示例,这是我使用的设置:我有一个名为/etc/apt/preferences.d/non-free
包含的文件
Package: intel-microcode
Pin: release n=buster, c=non-free
Pin-Priority: 100
Explanation: Disable packages from non-free tree by default
Package: *
Pin: release c=non-free
Pin-Priority: -1
非免费软件包仍然出现在搜索中,但我无法安装它们:
$ sudo apt install lmbench
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package lmbench is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'lmbench' has no installation candidate
并apt policy
同意:
$ apt policy lmbench
lmbench:
Installed: (none)
Candidate: (none)
Version table:
3.0-a9+debian.1-2 -1
-1 http://ftp.fr.debian.org/debian buster/non-free amd64 Packages
-1 http://ftp.fr.debian.org/debian testing/non-free amd64 Packages
-1 http://ftp.fr.debian.org/debian unstable/non-free amd64 Packages
但intel-microcode
可以安装和升级。因此,在强制降级到旧稳定版本后,我得到
$ apt policy intel-microcode
intel-microcode:
Installed: 3.20190618.1~deb9u1
Candidate: 3.20190618.1
Version table:
3.20190618.1 100
-1 http://ftp.fr.debian.org/debian buster/non-free amd64 Packages
-1 http://ftp.fr.debian.org/debian testing/non-free amd64 Packages
-1 http://ftp.fr.debian.org/debian unstable/non-free amd64 Packages
*** 3.20190618.1~deb9u1 100
100 /usr/var/lib/dpkg/status
$ apt list --upgradable
intel-microcode/stable,testing,unstable 3.20190618.1 amd64 [upgradable from: 3.20190618.1~deb9u1]
输出apt policy
结果有点令人困惑——请参阅“候选”行以查看真正会发生什么。