docker-ce-packaging/install-containerd-helpers

84 строки
3.0 KiB
Bash

#!/usr/bin/env bash
###
# Script Name: install-containerd-helpers
#
# Description: A library that containers helpers to install containerd on different
# distributions based on a package manager
###
set -x extglob
# Steps taken from: https://docs.docker.com/install/linux/docker-ce/centos/
function install_rpm_containerd() {
if [ "${PACKAGE_REPO}" = "stage" ]; then
REPO_URL="https://download-stage.docker.com/linux/${DIST_ID}/docker-ce-staging.repo"
else
REPO_URL="https://download.docker.com/linux/${DIST_ID}/docker-ce.repo"
fi
# Install containerd dependency for non-zypper dependecies
echo "[DEBUG] Installing engine dependencies from ${REPO_URL}"
# Note: we enable test channel to be able to test non-stable containerd packages as well.
# Once a containerd package becomes stable it will also be available in the test channel,
# so this logic works for both cases.
# (See also same logic in install_debian_containerd)
if command -v dnf5; then
dnf --version
# FIXME(thaJeztah); strip empty lines as workaround for https://github.com/rpm-software-management/dnf5/issues/1603
TMP_REPO_FILE="$(mktemp --dry-run)"
curl -fsSL "${REPO_URL}" | tr -s '\n' > "${TMP_REPO_FILE}"
dnf config-manager addrepo --save-filename=docker-ce.repo --overwrite --from-repofile="${TMP_REPO_FILE}"
rm -f "${TMP_REPO_FILE}"
# dnf config-manager addrepo --save-filename=docker-ce.repo --from-repofile="${REPO_URL}"
dnf config-manager setopt 'docker-ce-*.enabled=0'
dnf config-manager setopt 'docker-ce-test.enabled=1'
dnf makecache
elif command -v dnf; then
dnf --version
dnf config-manager --add-repo "${REPO_URL}"
dnf config-manager --set-disabled 'docker-ce-*'
dnf config-manager --set-enabled 'docker-ce-test'
dnf makecache
else
yum-config-manager --add-repo "${REPO_URL}"
yum-config-manager --disable 'docker-ce-*'
yum-config-manager --enable 'docker-ce-test'
yum makecache
fi
}
# Steps taken from: https://docs.docker.com/install/linux/docker-ce/ubuntu/
function install_debian_containerd() {
if [ "${PACKAGE_REPO}" = "stage" ]; then
REPO_URL="https://download-stage.docker.com/linux/${DIST_ID}"
else
REPO_URL="https://download.docker.com/linux/${DIST_ID}"
fi
echo "[DEBUG] Installing engine dependencies from ${REPO_URL}"
#TODO include this step in the get.docker.com installation script
# Make sure ca-certificates are up-to-date
update-ca-certificates -f
curl -fsSL "${REPO_URL}/gpg" | apt-key add -
if [ "${DIST_VERSION}" = "sid" ]; then
echo 'Debian sid ("unstable") cannot be used for packaging: replace with the actual codename'
exit 1
fi
ARCH=$(dpkg --print-architecture)
# Note: we enable test channel to be able to test non-stable containerd packages as well.
# Once a containerd package becomes stable it will also be available in the test channel,
# so this logic works for both cases.
# (See also same logic in install_rpm_containerd)
echo "deb [arch=${ARCH}] ${REPO_URL} ${DIST_VERSION} test" > /etc/apt/sources.list.d/docker.list
apt-get update
}