mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-01-23 00:58:57 +07:00
Fix paths for bin tools and scoped tools [skip ci]
This commit is contained in:
@@ -176,10 +176,14 @@ add_tool() {
|
||||
if ! [ -d "$tool_path_dir" ]; then
|
||||
sudo mkdir -p "$tool_path_dir"
|
||||
fi
|
||||
if ! [ -d "$tool_cache_path_dir" ]; then
|
||||
sudo mkdir -p "$tool_cache_path_dir"
|
||||
fi
|
||||
add_path "$tool_path_dir"
|
||||
add_path "$tool_cache_path_dir"
|
||||
IFS="," read -r -a url <<<"$url"
|
||||
cache_key=$(get_sha256 "${url[0]}" | head -c 16)
|
||||
cache_path="/tmp/${tool}-${cache_key}"
|
||||
cache_path="$tool_cache_path_dir/${tool}-${cache_key}"
|
||||
status_code="200"
|
||||
if [ -f "$cache_path" ]; then
|
||||
sudo cp -a "$cache_path" "$tool_path"
|
||||
@@ -199,6 +203,7 @@ add_tool() {
|
||||
fi
|
||||
if [ "$status_code" = "200" ]; then
|
||||
add_tools_helper "$tool"
|
||||
[ -L "$tool_cache_path_dir/$tool" ] || sudo ln -s "$tool_path" "$tool_cache_path_dir/$tool" 2>/dev/null || true
|
||||
tool_version=$(get_tool_version "$tool" "$ver_param")
|
||||
add_log "${tick:?}" "$tool" "Added $tool $tool_version"
|
||||
else
|
||||
|
||||
@@ -58,6 +58,7 @@ read_env() {
|
||||
-n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github
|
||||
runner="${runner:-${RUNNER:-$_runner}}"
|
||||
tool_path_dir="${setup_php_tools_dir:-${SETUP_PHP_TOOLS_DIR:-/usr/local/bin}}"
|
||||
tool_cache_path_dir="${setup_php_tool_cache_dir:-${SETUP_PHP_TOOL_CACHE_DIR:-$RUNNER_TOOL_CACHE/setup-php/tools}}"
|
||||
|
||||
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
||||
fail_fast=true
|
||||
@@ -79,6 +80,7 @@ read_env() {
|
||||
export update
|
||||
export ts
|
||||
export tool_path_dir
|
||||
export tool_cache_path_dir
|
||||
}
|
||||
|
||||
# Function to create a lock.
|
||||
@@ -169,14 +171,13 @@ get_shell_profile() {
|
||||
# Function to add a path to the PATH variable.
|
||||
add_path() {
|
||||
path_to_add=$1
|
||||
[[ ":$PATH:" == *":$path_to_add:"* ]] && return
|
||||
if [[ -n "$GITHUB_PATH" ]]; then
|
||||
echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
|
||||
printf '%s\n%s' "$path_to_add" "$(grep -v "^${path_to_add}$" "$GITHUB_PATH" 2>/dev/null)" > "$GITHUB_PATH"
|
||||
else
|
||||
profile=$(get_shell_profile)
|
||||
([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
|
||||
fi
|
||||
export PATH="${PATH:+${PATH}:}$path_to_add"
|
||||
[[ ":$PATH:" == *":$path_to_add:"* ]] || export PATH="${PATH:+${PATH}:}$path_to_add"
|
||||
}
|
||||
|
||||
# Function to add environment variables using a PATH.
|
||||
|
||||
Reference in New Issue
Block a user