使用 apt 安装任意版本的软件包的推荐方法是什么?

使用 apt 安装任意版本的软件包的推荐方法是什么?

问题:

我需要一种方法来在我的 Debian 系统上安装某些软件包的特定固定版本。快照.debian.org似乎提供了一种方法来做到这一点,但是即使在我的 apt-sources 中添加快照后,我仍然无法找到apt-get install该快照存档中某些特定版本的软件包。

问题:

从 Debian 快照存档安装特定软件包版本的官方或“正确”方法是什么?

背景和我尝试过的方法:

让我们使用 Debian8 Jessie 和比当前版本低一个小版本的 3.16.x 内核二进制文件作为示例。截至撰写本文时,Jessie 发布的内核是 3.16.43-2+deb8u5。假设我想安装 3.16.43-2+deb8u4。

我首先在 Debian 快照档案中搜索我想要的版本(http://snapshot.debian.org/binary/linux-image-3.16.0-4-amd64/),然后点击我正在寻找的内核的确切版本,这将让我http://snapshot.debian.org/package/linux/3.16.43-2%2Bdeb8u4/#linux-image-3.16.0-4-amd64_3.16.43-2:2b:deb8u4

从那里,我可以看到该软件包“于 2017-09-20 22:12:21 在 debian-security 中看到”和“于 2017-10-08 16:31:52 在 debian 中看到”。我决定使用前者,并选择 debian-security 快照20170920T221221Z

按照首页上的说明快照.debian.org,我将以下内容添加到我的 /etc/apt/sources.list 中:

deb http://snapshot.debian.org/archive/debian-security/20170920T221221Z/ jessie/updates main
deb src http://snapshot.debian.org/archive/debian-security/20170920T221221Z/ jessie/updates main

然后我运行apt-get -o Acquire::Check-Valid-Until=false update并看到更新(似乎)已成功完成。

我认为这将允许我现在安装所需的内核版本,但 apt 仅知道两个安装候选版本,3.16.43-2+deb8u2 和 3.16.43-2+deb8u5。没有 +deb8u4 的迹象:

# apt-cache madison linux-image-3.16.0-4-amd64
linux-image-3.16.0-4-amd64 | 3.16.43-2+deb8u5 | http://security.debian.org/ jessie/updates/main amd64 Packages
linux-image-3.16.0-4-amd64 | 3.16.43-2+deb8u5 | http://snapshot.debian.org/archive/debian-security/20170920T221221Z/ jessie/updates/main amd64 Packages
linux-image-3.16.0-4-amd64 | 3.16.43-2+deb8u2 | http://cloudfront.debian.net/debian/ jessie/main amd64 Packages
linux-image-3.16.0-4-amd64 | 3.16.7-ckt25-2 | http://cloudfront.debian.net/debian/ jessie-updates/main amd64 Packages
     linux |  3.16.39-1 | http://cloudfront.debian.net/debian/ jessie-backports/main Sources

# apt-cache policy linux-image-3.16.0-4-amd64
linux-image-3.16.0-4-amd64:
  Installed: 3.16.43-2+deb8u5
  Candidate: 3.16.43-2+deb8u5
  Version table:
     3.16.43-2+deb8u5 0
        500 http://security.debian.org/ jessie/updates/main amd64 Packages
        500 http://snapshot.debian.org/archive/debian-security/20170920T221221Z/ jessie/updates/main amd64 Packages
 *** 3.16.43-2+deb8u2 0
        500 http://cloudfront.debian.net/debian/ jessie/main amd64 Packages
        100 /var/lib/dpkg/status
     3.16.7-ckt25-2 0
        500 http://cloudfront.debian.net/debian/ jessie-updates/main amd64 Packages

此外,如果我尝试指定并安装我想要的版本,它会返回“未找到”:

# apt-get install linux-image-3.16.0-4-amd64=3.16.43-2+deb8u4
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '3.16.43-2+deb8u4' for 'linux-image-3.16.0-4-amd64' was not found

我设法通过下载 .deb 二进制文件并dpkg -i安装它来解决这个问题,但我更喜欢使用 apt,而不是下载 .debs 并安装它们。有人能解释一下我需要做什么才能使用apt-get install特定的包吗,或者至少解释一下为什么这不像我期望的那样有效吗?

答案1

这不是精确的科学,但这可能是为什么它对这种特定情况不起作用的原因(当你没有跟踪变化太快的目标时,它通常会起作用)。

给定的存储库通常仅引用 Packages 文件中包的一个版本,例如,这个。这不是技术义务,例如deb https://dl.winehq.org/wine-builds/debian/ jessie main在其 Packages 文件中包括同一软件包的多个版本,所有版本都可以通过 apt-get 检索,使用方法=与你一样,但 Debian (TM) 不会在同一个 Packages 文件中保留对多个版本的引用。

如果您查看所查找包所在的实际目录,您会发现有两个可用的版本:

linux-镜像-3.16.0-4-amd64_3.16.43-2+deb8u4_amd64.deb
linux-镜像-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb

当 deb8u5 出现时,之前对 deb8u4 的引用就消失了。deb8u4 .deb 可能仍被其他存储库引用,或者只是没有经过某些“垃圾收集”。单击快照导航中的“上一个更改”只会显示 deb8u3,而没有 deb8u4 或 deb8u5。这意味着 deb8u4 和 deb8u5 之间的更改发生得太快,以至于 deb8u4 的 Packages 文件无法下载,或者在 deb8u5 替换它之前,snapshot.debian.org 无法保存此中间 Packages 文件。debian-security 中的此引用(以及相应的校验和以及签名的 Release 文件)已丢失。

只需再次尝试使用 debian(而不是 debian-security):

linux-镜像-3.16.0-4-amd64_3.16.43-2+deb8u4_amd64.deb

以及相应的软件包.xz文件。这个只有 deb8u2 的条目……并且只保留这个。在 8.10 发布之前,较新的版本应该来自 debian-security,所以即使它们出现在池中,那也只是因为 snap.debian.org 让所有都出现在同一个位置。

抱歉,对于这个特定的软件包版本,我找不到下载 deb8u4 的方法。即使可以从链接下载并dpkg -i安装,也无法验证下载的内容,因此应避免这样做。

注意:您的方法是正确的。通常可以通过为某些特定软件包固定特定快照来完成此操作,允许 apt-get 自动选择它们(无需=),并避免它们稍后升级。那里解释了这一点: https://wiki.debian.org/AptPreferences. 持有它们也可以(dpkg --set-selectionsapt-mark hold)避免升级。

相关内容