docker-ce-packaging/verify

150 строки
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
###
# Script Name: verify
#
# Description: This runs a smoke test to verify that the packages can be installed corrected
###
# build/${DIST_ID}/${DIST_VERSION}/${ARCH} - location of all packages
# Manually Testing: docker run --rm -it -v $(pwd):/v -w /v "centos:7" ./verify
set -e
source install-containerd-helpers
function verify() {
if dpkg --version >/dev/null 2>/dev/null; then
verify_deb
elif rpm --version >/dev/null 2>/dev/null; then
verify_rpm
else
echo "[ERROR] Unable to determine base os:"
cat /etc/os-release
exit 1
fi
}
function verify_binaries() {
docker --version
docker buildx version
docker compose version
dockerd --version
docker-proxy --version
containerd --version
ctr --version
containerd-shim -v
containerd-shim-runc-v1 -v
containerd-shim-runc-v2 -v
runc --version
}
function verify_deb() {
# First install prerequisites for our script and dpkg and apt to run correctly.
# This list SHOULD NOT include dependencies of docker itself, otherwise we would
# not be able to verify that our packages specify all the required dependencies.
apt-get update
apt-get -y install --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
lsb-release \
software-properties-common
DIST_ID=$(source /etc/os-release; echo "$ID")
DIST_VERSION=$(lsb_release -sc)
if [ "${DIST_VERSION}" = "sid" ]; then
echo 'Debian sid ("unstable") cannot be used for packaging: replace with the actual codename'
exit 1
fi
install_debian_containerd
packages=$(find "deb/debbuild/${DIST_ID}-${DIST_VERSION}/" -type f -name "*.deb")
# All local packages need to be prefixed with `./` or else apt-get doesn't understand where to pull from
packages=$(echo "${packages}" | awk '$0="./"$0' | xargs)
(
set -x
# Install the locally built packages using 'dpkg' because installing with
# 'apt-get' would attempt to install dependency packages (such as the CLI)
# from download.docker.com instead of the locally built CLI package. Given
# that 'dpkg -i' does not install any dependency (but will fail if depen-
# dencies are missing), we use the '--ignore-depends' option to ignore
# packages we know to be missing at this stage, and '--force-depends' to
# only warn about any other missing dependency.
#
# shellcheck disable=SC2086
dpkg \
--ignore-depends=containerd.io,iptables,libdevmapper,libdevmapper1.02.1 \
--force-depends \
-i ${packages}
# After installing the local packages, we run 'apt-get install' with the
# '--fix-broken' option to trigger installation of the dependencies, which
# should succeed successfully. This step is to verify that not only the
# packages can be installed, but also that all dependencies (including
# containerd.io) can be resolved correctly for the distro that we built for,
# before going through the whole pipeline and publishing the packages.
#
# The '--no-upgrade' option is set to prevent apt from attempting to install
# packages from download(-stage).docker.com that we already installed using
# the local packages above. Without this, installing (e.g.) ./docker-ce-cli
# would result in apt installing "docker-ce" from the package repository and
# produce a "the following packages will be DOWNGRADED" error.
#
# shellcheck disable=SC2086
apt-get -y install --no-install-recommends --no-upgrade --fix-broken ${packages}
)
verify_binaries
}
function verify_rpm() {
DIST_ID=$(. /etc/os-release; echo "${ID}")
DIST_VERSION=$(. /etc/os-release; echo "${VERSION_ID}" | cut -d'.' -f1)
pkg_manager="yum"
pkg_config_manager="yum-config-manager"
if dnf --version; then
pkg_manager="dnf"
pkg_config_manager="dnf config-manager"
dnf clean all
${pkg_manager} install -y 'dnf-command(config-manager)'
fi
case ${DIST_ID}:${DIST_VERSION} in
ol:7*)
# Needed for container-selinux
${pkg_config_manager} --enable ol7_addons
;;
fedora*)
dnf install -y findutils
;;
esac
install_rpm_containerd
# find all rpm packages, exclude src package
echo "[DEBUG] Installing engine rpms"
packages=$(find "rpm/rpmbuild/${DIST_ID}-${DIST_VERSION}/RPMS/" -type f -name "*.rpm" | sed '/src/d')
# install all non-source packages
(
set -x
product_version=$(source /etc/os-release; echo "${REDHAT_SUPPORT_PRODUCT_VERSION:-}")
if [ "$product_version" = 'rawhide' ]; then
# force $releasever to account for Fedora pre-release images, as they
# may still be using "rawhide", which is not present on our package
# repositories on download.docker.com.
export DNF_VAR_releasever="$DIST_VERSION"
fi
${pkg_manager} install -y ${packages}
)
verify_binaries
}
verify