由于未满足的依赖关系,无法在 Debian 9stretch 上安装 apt-transport-https:apt (>= 1.5~alpha4)

由于未满足的依赖关系,无法在 Debian 9stretch 上安装 apt-transport-https:apt (>= 1.5~alpha4)

我有一个构建在 CI/CD 管道中的 Dockerfile。它从基于 Debian 9 Stretch 的 Drupal 映像开始,并安装 Node 10。构建映像在过去三年中一直有效,但昨天才停止工作。

为了重现该问题,我可以在没有 Dockerfile 中的任何指令的情况下运行容器:

docker run -it drupal:8.6.1-apache bash

然后在容器中运行此脚本,该脚本应安装 Node 10:

curl -fsSL https://deb.nodesource.com/setup_10.x | bash -

尝试安装时脚本失败apt-transport-https。如果我尝试直接安装它,我可以看到收到的错误:

apt-get update && apt-get install -y apt-transport-https
...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 apt-transport-https : Depends: apt (>= 1.5~alpha4) but 1.4.8 is to be installed
E: Unable to correct problems, you have held broken packages.

如果我尝试运行此命令来安装该特定版本:

apt-get install -y apt=1.5~alpha4
...
E: Version '1.5~alpha4' for 'apt' was not found

如果我运行它来查看可用版本的列表apt

apt list -a apt
...
apt/stable-updates 1.8.2.3 amd64 [upgradable from: 1.4.8]
apt/stable,stable 1.8.2.2 amd64
apt/oldstable 1.4.11 amd64
apt/oldstable 1.4.10 amd64
apt/now 1.4.8 amd64 [installed,upgradable to: 1.8.2.3]

那么如果我:

apt-get install -y apt=1.8.2.3
...
The following packages have unmet dependencies:
 apt : Depends: libapt-pkg5.0 (>= 1.7.0~alpha3~) but 1.4.8 is to be installed
       Depends: libgnutls30 (>= 3.6.6) but 3.5.8-5+deb9u5 is to be installed
E: Unable to correct problems, you have held broken packages.

然后,如果我尝试安装所需的版本libapt-pkg5.0

The following packages have unmet dependencies:
 libapt-pkg5.0 : Depends: libc6 (>= 2.27) but 2.24-11+deb9u4 is to be installed
                 Depends: libzstd1 (>= 1.3.2) but 1.1.2-1+deb9u1 is to be installed
                 Breaks: apt (< 1.6~) but 1.4.8 is to be installed
                 Recommends: apt (>= 1.8.2.3) but 1.4.8 is to be installed

然后如果我运行:

apt-get install -y libzstd1=1.3.8+dfsg-3+deb10u2 # this seems to install fine
apt-get install -y libc6=2.28-10

安装libc6失败并显示:

Reading package lists... 0%
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-libc-dev
Use 'apt autoremove' to remove it.
Suggested packages:
  glibc-doc libc-l10n locales
Recommended packages:
  libidn2-0
The following packages will be upgraded:
  libc6
1 upgraded, 0 newly installed, 0 to remove and 57 not upgraded.
Need to get 2867 kB of archives.
After this operation, 1693 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libc6 amd64 2.28-10 [2867 kB]
Fetched 2867 kB in 1s (1858 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)

此时我已经花了几个小时来解决这个问题,我想知道是否值得继续朝这个方向前进,或者是否有其他方法来解决这个问题。

我能够aptitude在像这样的新容器中使用来满足所有依赖项:

apt-get update
apt-get install -y aptitude
aptitude install apt-transport-https

它问我:

The following NEW packages will be installed:
  apt-transport-https libseccomp2{a}
The following packages will be upgraded:
  apt{b} libapt-pkg5.0{b}
2 packages upgraded, 2 newly installed, 0 to remove and 59 not upgraded.
Need to get 2575 kB of archives. After unpacking 1189 kB will be used.
The following packages have unmet dependencies:
 apt : Depends: libgnutls30 (>= 3.6.6) but 3.5.8-5+deb9u3 is installed and it is kept back
       Breaks: aptitude (< 0.8.10) but 0.8.7-1 is installed
 libapt-pkg5.0 : Depends: libc6 (>= 2.27) but 2.24-11+deb9u3 is installed and it is kept back
                 Depends: libzstd1 (>= 1.3.2) but it is not going to be installed
                 Breaks: aptitude (< 0.8.9) but 0.8.7-1 is installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     apt [1.4.8 (now)]
2)     apt-transport-https [Not Installed]
3)     libapt-pkg5.0 [1.4.8 (now)]



Accept this solution? [Y/n/q/?]

该解决方案什么也不做,但如果我输入n它,就会问我:

The following actions will resolve these dependencies:

      Install the following packages:
1)      libboost-iostreams1.67.0 [1.67.0-13+deb10u1 (stable)]
2)      libboost-system1.67.0 [1.67.0-13+deb10u1 (stable)]
3)      libgpm2 [1.20.4-6.2+b1 (oldstable)]
4)      libncursesw6 [6.1+20181013-2+deb10u2 (stable)]
5)      libtinfo6 [6.1+20181013-2+deb10u2 (stable)]
6)      libunistring2 [0.9.10-1 (stable)]
7)      libzstd1 [1.3.8+dfsg-3+deb10u2 (stable)]

      Upgrade the following packages:
8)      aptitude [0.8.7-1 (now, oldstable) -> 0.8.11-7 (stable)]
9)      aptitude-common [0.8.7-1 (now, oldstable) -> 0.8.11-7 (stable)]
10)     libc-bin [2.24-11+deb9u3 (now) -> 2.28-10 (stable)]
11)     libc-dev-bin [2.24-11+deb9u3 (now) -> 2.28-10 (stable)]
12)     libc6 [2.24-11+deb9u3 (now) -> 2.28-10 (stable)]
13)     libc6-dev [2.24-11+deb9u3 (now) -> 2.28-10 (stable)]
14)     libcwidget3v5 [0.5.17-4+b1 (now, oldstable) -> 0.5.17-11 (stable)]
15)     libgnutls30 [3.5.8-5+deb9u3 (now) -> 3.6.7-4+deb10u4 (stable)]
16)     libhogweed4 [3.3-1+b2 (now, oldstable) -> 3.4.1-1 (stable)]
17)     libidn2-0 [0.16-1+deb9u1 (now, oldstable) -> 2.0.5-1+deb10u1 (stable)]
18)     libnettle6 [3.3-1+b2 (now, oldstable) -> 3.4.1-1 (stable)]
19)     libp11-kit0 [0.23.3-2 (now, oldstable) -> 0.23.15-2+deb10u1 (stable)]
20)     libtasn1-6 [4.10-1.1+deb9u1 (now, oldstable) -> 4.13-3 (stable)]
21)     libxapian30 [1.4.3-2+deb9u3 (now, oldstable) -> 1.4.11-1 (stable)]

Accept this solution? [Y/n/q/?]

接受此解决方案有效 -apt-transport-https已成功安装,然后我可以运行curl -fsSL https://deb.nodesource.com/setup_10.x | bash -脚本来安装 Node.js。然而,这是一个交互式解决方案,需要我输入n一次,然后y输入两次,而且我无法找到在 Docker 构建期间自动发生这种情况的方法。

答案1

该映像被配置为拒绝来自 Debian 10 ( buster) 的软件包,但不拒绝来自更新 ( buster-updates) 的软件包,因此它最终会尝试apt-transport-https从后者中拉取。要解决此问题,请进行编辑/etc/apt/preferences.d/argon2-buster以使其读取

Package: *
Pin: release n=buster*
Pin-Priority: -10

Package: libargon2*
Pin: release n=buster
Pin-Priority: 990

IE添加*在第一个之后buster。这将允许apt-transport-https安装而不会出现问题。

您可以使用以下命令自动执行此操作

sed -i '2,2s/buster/buster*/' /etc/apt/preferences.d/argon2-buster

答案2

就我而言,我正在使用基于的 docker 镜像php:7.2.15-apache-stretch。我发现该脚本正在尝试安装apt-transport-https version= 1.4.11

但是,当在出现此问题之前构建的容器内运行时apt apt-transport-https -v,我发现版本是1.4.10.于是我就修改了一下,就解决了。

刚刚在节点curl之前添加了安装。

FROM php:7.2.15-apache-stretch
...
RUN apt-get update
...
RUN apt-get install -y apt-transport-https=1.4.10
RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -

相关内容