Skip to content

Commit

Permalink
Improve PECL support
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Nov 27, 2020
1 parent 5a40a58 commit 8dbd6b7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2882,7 +2882,7 @@ async function addExtensionDarwin(extension_csv, version) {
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
case /.*-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(version_extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
return;
// match semver
Expand Down Expand Up @@ -2948,8 +2948,8 @@ async function addExtensionWindows(extension_csv, version) {
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version);
case /.*-(stable|beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version.replace('stable', ''));
break;
// match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension):
Expand Down Expand Up @@ -3029,7 +3029,7 @@ async function addExtensionLinux(extension_csv, version) {
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
case /.*-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(version_extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
return;
// match semver versions
Expand Down
12 changes: 8 additions & 4 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export async function addExtensionDarwin(
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
case /.*-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(
version_extension
):
add_script += await utils.joins(
'\nadd_unstable_extension',
ext_name,
Expand Down Expand Up @@ -135,11 +137,11 @@ export async function addExtensionWindows(
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
case /.*-(stable|beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
ext_version
ext_version.replace('stable', '')
);
break;
// match semver without state
Expand Down Expand Up @@ -246,7 +248,9 @@ export async function addExtensionLinux(
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
case /.*-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(
version_extension
):
add_script += await utils.joins(
'\nadd_unstable_extension',
ext_name,
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ enable_extension() {

# Function to configure PECL.
configure_pecl() {
if ! [ -e /tmp/pecl_config ] && command -v pecl >/dev/null; then
if ! [ -e /tmp/pecl_config ] && command -v pecl >/dev/null && command -v pear >/dev/null; then
for script in pear pecl; do
sudo "$script" config-set php_ini "${pecl_file:-$ini_file}"
sudo "$script" channel-update "$script".php.net
Expand All @@ -124,7 +124,7 @@ configure_pecl() {
# Function to get the PECL version of an extension.
get_pecl_version() {
extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
Expand All @@ -137,6 +137,7 @@ get_pecl_version() {
# Function to install PECL extensions and accept default options
pecl_install() {
local extension=$1
configure_pecl >/dev/null 2>&1
yes '' 2>/dev/null | sudo pecl install -f "$extension" >/dev/null 2>&1
}

Expand Down
1 change: 0 additions & 1 deletion src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ setup_php() {
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver"
}
Expand Down
5 changes: 1 addition & 4 deletions src/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ add_devtools() {
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
if command -v pecl >/dev/null; then
configure_pecl >/dev/null 2>&1
fi
configure_pecl >/dev/null 2>&1
add_log "${tick:?}" "$tool" "Added $tool $semver"
}

Expand All @@ -174,7 +172,6 @@ setup_nightly() {
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
setup_old_versions() {
run_script "php5-ubuntu" "$version"
configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
}

Expand Down

0 comments on commit 8dbd6b7

Please sign in to comment.