From 5f301976dc06ffb0b31d72cb4abfe0bf3f8f4899 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 15 Jun 2017 12:18:42 +0100 Subject: [PATCH] scripts: sources-branch-updater-lib.sh: Avoid using 'dirname $0' Since this library can be sourced by external scripts, 'dirname $0' can't be used reliably to determine where the rest of the OSA helper scripts are located since $0 points to the external script. It's best to use the BASH_SOURCE array to determine the file in which the current function is defined. Change-Id: If48ee9cb472de811076d7d3adec8f3c9b476b833 --- scripts/sources-branch-updater-lib.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/sources-branch-updater-lib.sh b/scripts/sources-branch-updater-lib.sh index d04b69372a..18d8b03b58 100644 --- a/scripts/sources-branch-updater-lib.sh +++ b/scripts/sources-branch-updater-lib.sh @@ -207,9 +207,11 @@ update_pip_options() { # Updates ansible-role-requirements file SHAs # update_ansible_role_requirements() { - local role_name role_version osa_repo_tmp_path role_git_sources + local role_name role_version osa_repo_tmp_path role_git_sources current_source_dir local osa_branch=${1} local pre_release=${2} + current_source_dir="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" + # Update the ansible-role-requirements.yml file # We don't want to be doing this for the master branch if [ "${osa_branch}" != "master" ] || [ "${pre_release}" == "true" ]; then @@ -253,7 +255,7 @@ update_ansible_role_requirements() { fi # Now use the information we have to update the ansible-role-requirements file - "$(dirname "${0}")/ansible-role-requirements-editor.py" -f ansible-role-requirements.yml -n "${role_name}" -v "${role_version}" + "$current_source_dir/ansible-role-requirements-editor.py" -f ansible-role-requirements.yml -n "${role_name}" -v "${role_version}" unset role_version done