-
Notifications
You must be signed in to change notification settings - Fork 145
/
verify
executable file
·149 lines (128 loc) · 4.58 KB
/
verify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/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