Allow specifying stability when wanting a compatible PECL version (#833)

pull/835/head 2.1.64
Michele Locati 2023-11-09 15:01:33 +01:00 committed by GitHub
parent a73618bc03
commit 02c0e027bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 6 deletions

View File

@ -114,6 +114,7 @@ jobs:
- 3.0.0 - 3.0.0
- ^2 - ^2
- ^2.8 - ^2.8
- ^2.8@stable
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -96,6 +96,15 @@ install-php-extensions xdebug-^2
install-php-extensions xdebug-^2.8 install-php-extensions xdebug-^2.8
``` ```
Please remark that with the syntax above you'll get the vary latest compatible version, which may be unstable. In order to install the most recent *stable* version, you can append `@stable`:
```sh
# Install the most recent STABLE xdebug 3.x version (for example 3.2.2)
install-php-extensions xdebug-^3@stable
```
(valid suffixes are: `@snapshot`, `@devel`, `@alpha`, `@beta`, and `@stable`)
Pre-release versions extensions available on `PECL` can be setup by suffixing the extension's name with its state i.e. `alpha`, `beta`, `rc`, `preview`, `devel` or `snapshot`. Pre-release versions extensions available on `PECL` can be setup by suffixing the extension's name with its state i.e. `alpha`, `beta`, `rc`, `preview`, `devel` or `snapshot`.
For example: For example:

View File

@ -371,19 +371,40 @@ resolveWantedPHPModuleVersion() {
printf '%s' "$resolveWantedPHPModuleVersion_raw" printf '%s' "$resolveWantedPHPModuleVersion_raw"
return return
fi fi
case "$resolveWantedPHPModuleVersion_afterCaret" in
?*@snapshot | ?*@devel | ?*@alpha | ?*@beta | ?*@stable)
resolveWantedPHPModuleVersion_wantedStability="${resolveWantedPHPModuleVersion_afterCaret##*@}"
resolveWantedPHPModuleVersion_wantedVersion="${resolveWantedPHPModuleVersion_afterCaret%@*}"
;;
*)
resolveWantedPHPModuleVersion_wantedStability=''
resolveWantedPHPModuleVersion_wantedVersion="$resolveWantedPHPModuleVersion_afterCaret"
;;
esac
resolveWantedPHPModuleVersion_xml="$(curl -sSLf "http://pecl.php.net/rest/r/$1/allreleases.xml")" resolveWantedPHPModuleVersion_xml="$(curl -sSLf "http://pecl.php.net/rest/r/$1/allreleases.xml")"
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_xml" | tr -s ' \t\r\n' ' ' | sed -r 's# *<#\n<#g' | grep '<v>' | sed 's#<v>##g' | sed 's# ##g')" # remove line endings, collapse spaces
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_xml" | tr -s ' \t\r\n' ' ')"
# one line per release (eg <r><v>1.2.3</v><s>stable</s></r>)
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_versions" | sed -r 's#<r#\n<r#g')"
if test -n "$resolveWantedPHPModuleVersion_wantedStability"; then
# keep the lines with the wanted stability
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_versions" | grep "<s>$resolveWantedPHPModuleVersion_wantedStability</s>")"
fi
# remove everything's up to '<v>' (included)
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_versions" | sed 's#^.*<v>##')"
# keep just the versions
resolveWantedPHPModuleVersion_versions="$(printf '%s' "$resolveWantedPHPModuleVersion_versions" | cut -d'<' -f1)"
resetIFS resetIFS
for resolveWantedPHPModuleVersion_version in $resolveWantedPHPModuleVersion_versions; do for resolveWantedPHPModuleVersion_version in $resolveWantedPHPModuleVersion_versions; do
resolveWantedPHPModuleVersion_suffix="${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_afterCaret}" resolveWantedPHPModuleVersion_suffix="${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_wantedVersion}"
if test "$resolveWantedPHPModuleVersion_version" != "${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_afterCaret.}"; then if test "$resolveWantedPHPModuleVersion_version" != "${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_wantedVersion.}"; then
# Example: looking for 1.0, found 1.0.1 # Example: looking for 1.0, found 1.0.1
printf '%s' "$resolveWantedPHPModuleVersion_version" printf '%s' "$resolveWantedPHPModuleVersion_version"
return return
fi fi
done done
for resolveWantedPHPModuleVersion_version in $resolveWantedPHPModuleVersion_versions; do for resolveWantedPHPModuleVersion_version in $resolveWantedPHPModuleVersion_versions; do
resolveWantedPHPModuleVersion_suffix="${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_afterCaret}" resolveWantedPHPModuleVersion_suffix="${resolveWantedPHPModuleVersion_version#$resolveWantedPHPModuleVersion_wantedVersion}"
if test "$resolveWantedPHPModuleVersion_version" = "$resolveWantedPHPModuleVersion_suffix"; then if test "$resolveWantedPHPModuleVersion_version" = "$resolveWantedPHPModuleVersion_suffix"; then
continue continue
fi fi

View File

@ -5,7 +5,8 @@ set -o errexit
set -o nounset set -o nounset
WANTED_VERSION="${1:-}" WANTED_VERSION="${1:-}"
WANTED_VERSION_AFTERCARET="${1#^}" WANTED_VERSION_BASE="${1#^}"
WANTED_VERSION_BASE="${WANTED_VERSION_BASE%@*}"
INSTALLME=xdebug INSTALLME=xdebug
if test -n "$WANTED_VERSION"; then if test -n "$WANTED_VERSION"; then
INSTALLME="$INSTALLME-$1" INSTALLME="$INSTALLME-$1"
@ -18,7 +19,7 @@ if test -z "$WANTED_VERSION"; then
printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION" printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION"
elif test "$WANTED_VERSION" = "$INSTALLED_VERSION"; then elif test "$WANTED_VERSION" = "$INSTALLED_VERSION"; then
printf 'Installing specific version %s worked\n' "$WANTED_VERSION" printf 'Installing specific version %s worked\n' "$WANTED_VERSION"
elif test "$WANTED_VERSION" != "$WANTED_VERSION_AFTERCARET" && test "${INSTALLED_VERSION#$WANTED_VERSION_AFTERCARET.}" != "$INSTALLED_VERSION"; then elif test "$WANTED_VERSION" != "$WANTED_VERSION_BASE" && test "${INSTALLED_VERSION#$WANTED_VERSION_BASE.}" != "$INSTALLED_VERSION"; then
printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION"
else else
printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2 printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2