mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-01-18 22:31:45 +07:00
Add support for pre-installed PHP
This commit is contained in:
parent
b6d8115f12
commit
da729085ef
@ -410,6 +410,7 @@ Disable coverage for these reasons:
|
|||||||
- Accepts `lowest` to set up the lowest supported PHP version.
|
- Accepts `lowest` to set up the lowest supported PHP version.
|
||||||
- Accepts `highest` or `latest` to set up the latest stable PHP version.
|
- Accepts `highest` or `latest` to set up the latest stable PHP version.
|
||||||
- Accepts `nightly` to set up a nightly build from the master branch of PHP.
|
- Accepts `nightly` to set up a nightly build from the master branch of PHP.
|
||||||
|
- Accepts `pre-installed` to set up the highest pre-installed PHP version. You can combine this with `update: true` to update the pre-installed PHP version.
|
||||||
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
|
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
|
||||||
- See [PHP support](#tada-php-support) for the supported PHP versions.
|
- See [PHP support](#tada-php-support) for the supported PHP versions.
|
||||||
- If not specified, it looks for the following in order:
|
- If not specified, it looks for the following in order:
|
||||||
|
@ -213,6 +213,7 @@ get_scan_dir() {
|
|||||||
setup_php() {
|
setup_php() {
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
php_config="$(command -v php-config 2>/dev/null)"
|
php_config="$(command -v php-config 2>/dev/null)"
|
||||||
|
check_pre_installed
|
||||||
existing_version=$(get_brewed_php)
|
existing_version=$(get_brewed_php)
|
||||||
if [[ "$version" =~ ${old_versions:?} ]]; then
|
if [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
|
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
|
||||||
|
@ -246,6 +246,7 @@ setup_php() {
|
|||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
sudo mkdir -m 777 -p /var/run /run/php
|
sudo mkdir -m 777 -p /var/run /run/php
|
||||||
php_config="$(command -v php-config)"
|
php_config="$(command -v php-config)"
|
||||||
|
check_pre_installed
|
||||||
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
||||||
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
|
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
|
||||||
add_php >/dev/null 2>&1
|
add_php >/dev/null 2>&1
|
||||||
|
@ -184,6 +184,19 @@ self_hosted_setup() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to check pre-installed PHP
|
||||||
|
check_pre_installed() {
|
||||||
|
if [ "$version" = "pre" ]; then
|
||||||
|
if [ -n "$php_config" ]; then
|
||||||
|
version="$(php_semver | cut -c 1-3)"
|
||||||
|
update=false
|
||||||
|
else
|
||||||
|
fail_fast=true
|
||||||
|
add_log "$cross" "PHP" "No pre-installed PHP version found"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to configure PHP
|
# Function to configure PHP
|
||||||
configure_php() {
|
configure_php() {
|
||||||
add_php_config
|
add_php_config
|
||||||
|
@ -401,6 +401,15 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|||||||
}
|
}
|
||||||
$status = "Installed"
|
$status = "Installed"
|
||||||
$extra_version = ""
|
$extra_version = ""
|
||||||
|
if($version -eq 'pre') {
|
||||||
|
if($null -ne $installed) {
|
||||||
|
$version = $installed.MajorMinorVersion
|
||||||
|
$env:update = 'false'
|
||||||
|
} else {
|
||||||
|
Add-Log $cross "PHP" "No pre-installed PHP version found"
|
||||||
|
Write-Error "No pre-installed PHP version found" -ErrorAction Stop
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
||||||
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
||||||
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
||||||
|
Loading…
Reference in New Issue
Block a user