aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/patches_utils.sh
diff options
context:
space:
mode:
authorJanos Gyerik <janos.gyerik@sonarsource.com>2017-11-21 16:50:40 +0100
committerGitHub <noreply@github.com>2017-11-21 16:50:40 +0100
commitbe37450079cf25c85456abae6dd1b5c99edb02f8 (patch)
tree9937c0bae6f66857bbd74dd4f310a2f4054213d2 /scripts/patches_utils.sh
parentda41cff1d4695e2644221ca60210209a143a17a7 (diff)
downloadsonarqube-be37450079cf25c85456abae6dd1b5c99edb02f8.tar.gz
sonarqube-be37450079cf25c85456abae6dd1b5c99edb02f8.zip
Add USER_PATCHES_HOME support and minor quality improvements (#2815)
Diffstat (limited to 'scripts/patches_utils.sh')
-rwxr-xr-xscripts/patches_utils.sh49
1 files changed, 30 insertions, 19 deletions
diff --git a/scripts/patches_utils.sh b/scripts/patches_utils.sh
index 1792a4ce5a6..4a2f1c4b8df 100755
--- a/scripts/patches_utils.sh
+++ b/scripts/patches_utils.sh
@@ -1,29 +1,40 @@
-#!/bin/bash
-###############################
-# exposes library functions to modify properties in a property
-###############################
+#!/usr/bin/env bash
set -euo pipefail
PATCHES_HOME=scripts/patches
+USER_PATCHES_HOME=
-# $1: name(s) of patches to call, separated by a colon
-# all other arguments are passed as is to the patches
-function call_patches() {
- local PATCHES=$1
- local ARGS=${@:2}
- local savedIFS=$IFS
+if [ "${SONARQUBE_USER_PATCHES_HOME+x}" ]; then
+ USER_PATCHES_HOME=$SONARQUBE_USER_PATCHES_HOME
+fi
+
+# $1: name(s) of patches to call, separated by comma(s)
+# $2: path to SonarQube installation
+call_patches() {
+ local patches=$1
+ local sq_home=$2
+ local patch script
+ local IFS=,
- IFS=','
- for PATCH in $PATCHES; do
- #echo "calling $PATCHES_HOME/$PATCH.sh $ARGS"
- echo ""
- echo "******** $PATCH *******"
- $PATCHES_HOME/$PATCH.sh $ARGS
+ for patch in $patches; do
+ echo
+ echo "******** $patch *******"
+
+ if [ "$USER_PATCHES_HOME" -a -x "$USER_PATCHES_HOME/$patch.sh" ]; then
+ script=$USER_PATCHES_HOME/$patch.sh
+ elif [ -x "$PATCHES_HOME/$patch.sh" ]; then
+ script=$PATCHES_HOME/$patch.sh
+ elif [ "$USER_PATCHES_HOME" ]; then
+ echo "Patch $patch is not an executable script in $PATCHES_HOME or $USER_PATCHES_HOME"
+ return 1
+ else
+ echo "Patch $patch is not an executable script in $PATCHES_HOME"
+ return 1
+ fi
+ "$script" "$sq_home"
done
- IFS=$savedIFS
- echo ""
+ echo
}
-