Fix support for pre-release extensions

This commit is contained in:
Shivam Mathur 2020-07-14 14:12:50 +05:30
parent 19497a0597
commit 2f1900f7bc
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 22 additions and 6 deletions

View File

@ -37,10 +37,10 @@ check_extension() {
# Fuction to get the PECL version
get_pecl_version() {
extension=$1
stability=$2
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*$stability\d*)")
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
fi
@ -52,6 +52,9 @@ add_pecl_extension() {
extension=$1
pecl_version=$2
prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
fi

View File

@ -49,10 +49,10 @@ configure_pecl() {
# Fuction to get the PECL version
get_pecl_version() {
extension=$1
stability=$2
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*$stability\d*)")
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
fi
@ -111,6 +111,9 @@ add_pecl_extension() {
extension=$1
pecl_version=$2
prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
fi

View File

@ -65,7 +65,12 @@ Function Add-Extension {
[ValidateNotNull()]
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
[string]
$mininum_stability = 'stable'
$stability = 'stable',
[Parameter(Position = 2, Mandatory = $false)]
[ValidateNotNull()]
[ValidatePattern('^\d+(\.\d+){0,2}$')]
[string]
$extension_version = ''
)
try {
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
@ -84,7 +89,12 @@ Function Add-Extension {
}
}
else {
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
if($extension_version -ne '') {
Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $stability -MaximumStability $stability -Path $php_dir
} else {
Install-PhpExtension -Extension $extension -MinimumStability $stability -MaximumStability $stability -Path $php_dir
}
Add-Log $tick $extension "Installed and enabled"
}
}