Skip to content

Commit 6fac759

Browse files
committed
Fix package verify script no longer working under CentOS 6.
/sbin/init has gone missing in newer version of the centos:6 image, so we need to manually install it first.
1 parent 229a626 commit 6fac759

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

build/package/verify/docker_run

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,37 @@ source_dir="$(dirname "$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}"
66
docker_image=${DIST/-/:}
77
container_name="api-umbrella-package-$DIST-verify"
88
container_name=${container_name//[^a-zA-Z0-9_.-]/}
9+
init_container_name="${container_name}-init"
910

1011
# Wipe any previous build attempts.
12+
existing=$(docker ps -a -q --filter="name=$init_container_name")
13+
if [ "$existing" != "" ]; then
14+
docker rm -f "$existing"
15+
fi
1116
existing=$(docker ps -a -q --filter="name=$container_name")
1217
if [ "$existing" != "" ]; then
1318
docker rm -f "$existing"
1419
fi
20+
existing=$(docker images -a -q --filter="reference=$init_container_name")
21+
if [ "$existing" != "" ]; then
22+
docker rmi -f "$existing"
23+
fi
1524

16-
# Run inside a privileged container for systemd things to work. First run
25+
install_init_cmd=""
26+
if [ "$DIST" == "centos-6" ]; then
27+
# CentOS 6 docker image no longer has /sbin/init pre-installed:
28+
# https://github.com/CentOS/sig-cloud-instance-images/issues/28#issuecomment-306801650
29+
install_init_cmd="yum -y install initscripts"
30+
fi
31+
32+
# Run inside a privileged container for systemd things to work. First install
33+
# /sbin/init (it's missing from some docker base images), and then run
1734
# /sbin/init so we can better emulate a real server for systemd testing.
35+
docker run \
36+
--name="$init_container_name" \
37+
"$docker_image" \
38+
bash -c "$install_init_cmd"
39+
docker commit "$init_container_name" "$init_container_name"
1840
docker run \
1941
--name="$container_name" \
2042
--volume="$source_dir:/api-umbrella" \
@@ -23,7 +45,7 @@ docker run \
2345
--tty \
2446
--privileged \
2547
--detach \
26-
"$docker_image" \
48+
"$init_container_name" \
2749
/sbin/init
2850

2951
# Next run our script to install the API Umbrella package and perform
@@ -32,6 +54,8 @@ docker exec --tty "$container_name" /bin/bash -c "/api-umbrella/build/package/ve
3254

3355
# Delete after successful run.
3456
docker stop "$container_name"
57+
docker rm -f "$init_container_name"
3558
docker rm -f "$container_name"
59+
docker rmi -f "$init_container_name"
3660

3761
echo "Completed package verification for $DIST"

0 commit comments

Comments
 (0)