Apt

由於未滿足的依賴關係,無法在 Debian 9 上安裝 apt-transport-https:apt (>= 1.5~alpha4)

  • April 28, 2021

我有一個建構在 CI/CD 管道中的 Dockerfile。它從基於 Debian 9 延伸的 Drupal 映像開始,並安裝 Node 10。建構該映像已經工作了三年,但它昨天才停止工作。

為了重現該問題,我可以在沒有 Dockerfile 的任何說明的情況下執行容器:

docker run -it drupal:8.6.1-apache bash

然後在容器中執行這個應該安裝節點 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 建構期間自動發生這種情況的方法。

該映像配置為拒絕來自 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

*在第一個之後添加buster。這將允許apt-transport-https安裝沒有問題。

您可以使用

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

引用自:https://unix.stackexchange.com/questions/646402