Skip to content

Commit 6149ed2

Browse files
committed
Fixed cleanup of stale cfbuild packages on build hosts
zypper has no uninstall command, so erase-packages silently did nothing on SUSE. The || true guard hid the error. The cleanup also ran too late. It sat inside the cf-remote branch, which the CentOS 6 and SUSE 12 paths never reach because they install the agent directly. Leftover cfbuild-* packages own files under /var/cfengine. Installing cfengine-nova then aborts on file conflicts, because zypper install -y does not auto-answer the file conflict prompt. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent cb25aac commit 6149ed2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎ci/setup-cfengine-build-host.sh‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ if [ -f /etc/os-release ]; then
149149
elif grep -q suse /etc/os-release; then
150150
zypper -n update
151151
alias software='zypper install -y'
152-
alias erase-packages='zypper uninstall -y'
152+
alias erase-packages='zypper remove -y'
153153
else
154154
echo "Unknown platform ID $ID. Need this information in order to update/upgrade distribution packages."
155155
exit 1
156156
fi
157157
elif [ -f /etc/redhat-release ]; then
158158
yum update --assumeyes
159159
alias software='yum install --assumeyes'
160+
alias erase-packages='yum erase --assumeyes'
160161
else
161162
echo "No /etc/os-release or /etc/redhat-release so cant determine platform."
162163
exit 1
@@ -171,6 +172,11 @@ else
171172
exit 1
172173
fi
173174

175+
# Must run before any cfengine-nova install below. The cfbuild-* packages own
176+
# files under /var/cfengine, so leftovers make the agent install fail on file
177+
# conflicts.
178+
erase-packages cfbuild-* || true # in case a dirty build was left on a long-living build host
179+
174180
if grep -q 6.10 /etc/issue 2>/dev/null; then
175181
# special case of centos-6, cf-remote depends on urllib3 which depends on openssl 1.1.1+ that is not available
176182
# generally we rely on cf-remote to install cfengine-nova and download masterfiles so here we must provide for both of those
@@ -282,9 +288,6 @@ if ! /var/cfengine/bin/cf-agent -V 2>/dev/null; then
282288
mv "$HOME"/.cfengine/cf-remote/* "$HOME"/.config/cfengine/cf-remote/
283289
fi
284290

285-
286-
erase-packages cfbuild-* || true # in case a dirty build was left on a long-living build host
287-
288291
# We are passing a two-token string and need it to stay two tokens for proper argument parsing in $_VERSION
289292
# shellcheck disable=SC2086
290293
cf-remote --log-level info $_VERSION install --clients localhost || true

0 commit comments

Comments
 (0)