Skip to content

Lazy-install Swoole/OpenSwoole extensions #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ if [[ "${PHP}" == "" ]];then
fi

declare -a BEFORE_SCRIPT=()
readarray -t BEFORE_SCRIPT="$(echo "${JOB}" | jq -rc '(.before_script // [])[]' )"
BEFORE_SCRIPT_STRING="$(echo "${JOB}" | jq -rc '(.before_script // [])[]' | tr -d '\n')"
if [[ "${BEFORE_SCRIPT_STRING}" != "" ]]; then
readarray -t BEFORE_SCRIPT="${BEFORE_SCRIPT_STRING}"
fi

declare -a AFTER_SCRIPT=()
readarray -t AFTER_SCRIPT="$(echo "${JOB}" | jq -rc '(.after_script // [])[]' )"
AFTER_SCRIPT_STRING="$(echo "${JOB}" | jq -rc '(.after_script // [])[]' | tr -d '\n')"
if [[ "${AFTER_SCRIPT_STRING}" != "" ]]; then
readarray -t AFTER_SCRIPT="${AFTER_SCRIPT_STRING}"
fi


echo "Marking PHP ${PHP} as configured default"
Expand Down
15 changes: 0 additions & 15 deletions mods-install/install_swoole.sh

This file was deleted.

31 changes: 29 additions & 2 deletions scripts/extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

set -e

SWOOLE_PACKAGE_URL="https://github.com/weierophinney/laminas-ci-swoole-builder/releases/download/0.2.0/php%s-%s.tgz"

function install_extensions {
local PHP=$1
local -a EXTENSIONS=()
Expand All @@ -27,6 +29,25 @@ function install_extensions {
esac
}

function install_swoole_extension {
local PHP=$1
local extension=$2
local package_url
local package

# shellcheck disable=SC2059
package_url=$(printf "${SWOOLE_PACKAGE_URL}" "${PHP}" "${extension}")
package=$(basename "${package_url}")

echo "Fetching ${extension} extension package for PHP ${PHP}"
cd /tmp
wget "${package_url}"
cd /
tar xzf "/tmp/${package}"
rm -rf "/tmp/${package}"
phpenmod -v "${PHP}" -s ALL "${extension}"
}

function install_packaged_extensions {
local PHP=$1
# shellcheck disable=SC2206
Expand All @@ -37,8 +58,14 @@ function install_packaged_extensions {
local TO_INSTALL=""

for EXTENSION in "${EXTENSIONS[@]}"; do
# Converting extension name to package name, e.g. php8.0-redis
TO_INSTALL="${TO_INSTALL}php${PHP}-$EXTENSION "
if [[ "${EXTENSION}" =~ openswoole ]]; then
install_swoole_extension "${PHP}" "openswoole"
elif [[ "${EXTENSION}" =~ swoole ]]; then
install_swoole_extension "${PHP}" "swoole"
else
# Converting extension name to package name, e.g. php8.0-redis
TO_INSTALL="${TO_INSTALL}php${PHP}-$EXTENSION "
fi
done

if [ -z "$TO_INSTALL" ]; then
Expand Down