From d0b5111da52ec652b6dbb910b42a11178c1d7143 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 20 Jun 2025 15:16:24 +0200 Subject: [PATCH 1/2] clean-buildmachine: fixed indentation in case statement Signed-off-by: Lars Erik Wik --- build-scripts/clean-buildmachine | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build-scripts/clean-buildmachine b/build-scripts/clean-buildmachine index 31d0c51d2..d1403a29d 100755 --- a/build-scripts/clean-buildmachine +++ b/build-scripts/clean-buildmachine @@ -6,10 +6,10 @@ uninstall_cfbuild case $OS in -aix) -sudo rm -rf "$PREFIX"/* -;; -*) -sudo rm -rf "$PREFIX" -;; + aix) + sudo rm -rf "$PREFIX"/* + ;; + *) + sudo rm -rf "$PREFIX" + ;; esac From ced08524d615216ddbbd23bf2aff0ef2fc0f0ac6 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 20 Jun 2025 15:46:12 +0200 Subject: [PATCH 2/2] clean-buildmachine: documented script I also: - fixed shellcheck issues - added an if statement to prevent accedental deletion root on AIX in case of prefix being empty or undefined - added a debug log message Ticket: ENT-12600 Signed-off-by: Lars Erik Wik --- build-scripts/clean-buildmachine | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build-scripts/clean-buildmachine b/build-scripts/clean-buildmachine index d1403a29d..e5104e719 100755 --- a/build-scripts/clean-buildmachine +++ b/build-scripts/clean-buildmachine @@ -1,10 +1,22 @@ #!/bin/sh -. `dirname "$0"`/functions +# This script cleans a build machine by uninstalling cfbuild and removing the +# contents of the PREFIX directory. +# +# Don't run this script on your dev machine! You may accidentally delete +# something very important. + +. "$(dirname "$0")"/functions . detect-environment uninstall_cfbuild +if [ -z "$PREFIX" ] || [ "$PREFIX" = "/" ]; then + echo "$(basename "$0"): Error: \$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion." + exit 1 +fi + +echo "$(basename "$0"): Debug: Cleaning build host by deleting $PREFIX" case $OS in aix) sudo rm -rf "$PREFIX"/*