mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-02-13 14:38:47 +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
|
if ! [ -d "$tool_path_dir" ]; then
|
||||||
sudo mkdir -p "$tool_path_dir"
|
sudo mkdir -p "$tool_path_dir"
|
||||||
fi
|
fi
|
||||||
add_path "$tool_path_dir"
|
if ! [ -d "$tool_cache_path_dir" ]; then
|
||||||
|
sudo mkdir -p "$tool_cache_path_dir"
|
||||||
|
fi
|
||||||
|
add_path "$tool_path_dir" verify
|
||||||
|
add_path "$tool_cache_path_dir"
|
||||||
IFS="," read -r -a url <<<"$url"
|
IFS="," read -r -a url <<<"$url"
|
||||||
cache_key=$(get_sha256 "${url[0]}" | head -c 16)
|
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"
|
status_code="200"
|
||||||
if [ -f "$cache_path" ]; then
|
if [ -f "$cache_path" ]; then
|
||||||
sudo cp -a "$cache_path" "$tool_path"
|
sudo cp -a "$cache_path" "$tool_path"
|
||||||
@@ -199,6 +203,7 @@ add_tool() {
|
|||||||
fi
|
fi
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
add_tools_helper "$tool"
|
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")
|
tool_version=$(get_tool_version "$tool" "$ver_param")
|
||||||
add_log "${tick:?}" "$tool" "Added $tool $tool_version"
|
add_log "${tick:?}" "$tool" "Added $tool $tool_version"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ read_env() {
|
|||||||
-n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github
|
-n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github
|
||||||
runner="${runner:-${RUNNER:-$_runner}}"
|
runner="${runner:-${RUNNER:-$_runner}}"
|
||||||
tool_path_dir="${setup_php_tools_dir:-${SETUP_PHP_TOOLS_DIR:-/usr/local/bin}}"
|
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:-/opt/hostedtoolcache}/setup-php/tools}}"
|
||||||
|
|
||||||
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
||||||
fail_fast=true
|
fail_fast=true
|
||||||
@@ -79,6 +80,7 @@ read_env() {
|
|||||||
export update
|
export update
|
||||||
export ts
|
export ts
|
||||||
export tool_path_dir
|
export tool_path_dir
|
||||||
|
export tool_cache_path_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to create a lock.
|
# Function to create a lock.
|
||||||
@@ -169,14 +171,15 @@ get_shell_profile() {
|
|||||||
# Function to add a path to the PATH variable.
|
# Function to add a path to the PATH variable.
|
||||||
add_path() {
|
add_path() {
|
||||||
path_to_add=$1
|
path_to_add=$1
|
||||||
[[ ":$PATH:" == *":$path_to_add:"* ]] && return
|
action=$2
|
||||||
|
[[ "$action" == "verify" && ":$PATH:" == *":$path_to_add:"* ]] && return
|
||||||
if [[ -n "$GITHUB_PATH" ]]; then
|
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
|
else
|
||||||
profile=$(get_shell_profile)
|
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
|
([ -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
|
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.
|
# Function to add environment variables using a PATH.
|
||||||
|
|||||||
@@ -81,9 +81,10 @@ Function Get-PathFromRegistry {
|
|||||||
# Function to add a location to PATH.
|
# Function to add a location to PATH.
|
||||||
Function Add-Path {
|
Function Add-Path {
|
||||||
param(
|
param(
|
||||||
[string]$PathItem
|
[string]$PathItem,
|
||||||
|
[switch]$Force
|
||||||
)
|
)
|
||||||
if("$env:PATH;".contains("$PathItem;")) {
|
if(-not($Force) -and "$env:PATH;".contains("$PathItem;")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ($env:GITHUB_PATH) {
|
if ($env:GITHUB_PATH) {
|
||||||
@@ -375,6 +376,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
|
|||||||
if(-not(Test-Path -LiteralPath $current_profile)) {
|
if(-not(Test-Path -LiteralPath $current_profile)) {
|
||||||
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
||||||
}
|
}
|
||||||
|
Add-Path -PathItem $bin_dir -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
||||||
|
|||||||
Reference in New Issue
Block a user