Skip to content

Commit 2c23b7c

Browse files
committed
refactoring and containers setup
1 parent a9f1a09 commit 2c23b7c

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

ci/setup-cfengine-build-host.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,16 @@ if [ -f /etc/cfengine-bootstrap-pr-host.flag ]; then
145145
exit
146146
fi
147147

148+
if [ -f /etc/cfengine-containers-host.flag ]; then
149+
"$thisdir"/setup-ci-host.sh
150+
exit
151+
fi
152+
148153
# platforms too old to support cf-remote, use scripts instead
149154
if [ -f /etc/os-release ]; then
150155
source /etc/os-release
151156
if [ "$ID" = "centos" ] && [ "$VERSION_ID" = "7" ]; then
152-
"$thisdir"/setup-build-host.sh
157+
"$thisdir"/setup-ci-host.sh
153158
exit
154159
fi
155160
fi
Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33
shopt -s expand_aliasas
4+
thisdir="$(dirname "$0")"
45

56
packages="" # a space separated list of packages to install
67
function add-pkg()
@@ -12,24 +13,53 @@ if [ -f /etc/os-release ]; then
1213
source /etc/os-release
1314
if grep -q rhel /etc/os-release; then
1415
yum update --assumeyes
15-
alias software='yum install --assumeyes'
16+
alias packages='yum install --assumeyes'
1617
elif grep -q debian /etc/os-release; then
17-
alias software='DEBIAN_FRONTEND=noninteractive apt install --yes'
18+
alias packages='DEBIAN_FRONTEND=noninteractive apt install --yes'
1819
elif grep -q suse /etc/os-release; then
19-
alias software='zypper install -y'
20+
alias packages='zypper install -y'
2021
else
2122
echo "Unknown platform ID $ID. Need this information in order to update/upgrade distribution packages."
2223
exit 1
2324
fi
2425
elif [ -f /etc/redhat-release ]; then
25-
alias software='yum install --assumeyes'
26+
alias packages='yum install --assumeyes'
2627
# shellcheck disable=SC1091
2728
source /etc/redhat-release
2829
else
2930
echo "No /etc/os-release or /etc/redhat-release so cant determine platform."
3031
exit 1
3132
fi
3233

34+
if [ -f /etc/cfengine-containers-host.flag ]; then
35+
if echo "$ID_LIKE" | grep debian && [ "$VERSION_ID" -ge "12" ]; then
36+
# in jenkins, CONTAINER labeled nodes are capable of running container builds like valgrind-check and static-check
37+
add-pkg unzip # linux-install-groovy.sh needs unzip to unpack the groovy distribution archive
38+
add-pkg buildah
39+
add-pkg jq
40+
add-pkg make
41+
add-pkg parallel
42+
add-pkg podman
43+
if ! command -v groovy; then
44+
bash "$thisdir"/linux-install-groovy.sh
45+
fi
46+
47+
# NOPASSWD is needed for various tools related to container jobs
48+
rm -rf /etc/sudoers.d/999-local
49+
cat >/etc/sudoers.d/999-local <<EOF
50+
%wheel ALL=NOPASSWD: /usr/bin/lvm-cache-stats
51+
%wheel ALL=NOPASSWD: /usr/bin/podman
52+
%sudo ALL=NOPASSWD: /usr/bin/lvm-cache-stats
53+
%sudo ALL=NOPASSWD: /usr/bin/podman
54+
%sudo ALL=NOPASSWD: /usr/sbin/lvs
55+
%sudo ALL=NOPASSWD: /usr/bin/journalctl
56+
jenkins ALL=NOPASSWD: /usr/bin/podman
57+
EOF
58+
chmod 400 /etc/sudoers.d/999-local
59+
chown root:root /etc/sudoers.d/999-local
60+
fi
61+
fi
62+
3363
if echo "$ID_LIKE" | grep rhel; then
3464
if [ "$VERSION_ID" != "6" ] && [ "$VERSION_ID" != "7" ]; then
3565
if ! grep best=False /etc/yum.conf; then
@@ -118,4 +148,7 @@ if echo "$ID_LIKE" | grep rhel; then
118148

119149
fi
120150

121-
software $packages
151+
# packages is a dynamic alias set near the top of this script
152+
# shellcheck disable=SC2086
153+
# ^^^ we want space separated package names as separate args, not one arg with the space separated list
154+
packages $packages

0 commit comments

Comments
 (0)