mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Refactor scripts
This commit is contained in:
parent
76cecacc5e
commit
43cfa2b1a8
@ -27,7 +27,7 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'xdebug, pcov, ast-beta',
|
'xdebug, pcov, ast-beta, xdebug-alpha',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
@ -35,7 +35,10 @@ describe('Extension tests', () => {
|
|||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('install_extension ast-beta');
|
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||||
|
expect(linux).toContain(
|
||||||
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
|
);
|
||||||
|
|
||||||
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
||||||
expect(linux).toContain('gearman.sh 7.0');
|
expect(linux).toContain('gearman.sh 7.0');
|
||||||
@ -67,7 +70,7 @@ describe('Extension tests', () => {
|
|||||||
);
|
);
|
||||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
expect(darwin).toContain('install_extension ast-beta');
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
||||||
|
31
dist/index.js
vendored
31
dist/index.js
vendored
@ -2642,12 +2642,20 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
|
const [extension_name, stability] = extension.split('-');
|
||||||
|
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.6xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -2748,12 +2756,20 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
|
const [extension_name, stability] = extension.split('-');
|
||||||
|
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
install_command =
|
install_command =
|
||||||
@ -2791,12 +2807,7 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||||
extension +
|
|
||||||
' "' +
|
|
||||||
install_command +
|
|
||||||
'" ' +
|
|
||||||
(yield utils.getExtensionPrefix(extension));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
|
@ -18,12 +18,20 @@ export async function addExtensionDarwin(
|
|||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
|
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.6xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -124,12 +132,20 @@ export async function addExtensionLinux(
|
|||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
|
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
install_command =
|
install_command =
|
||||||
@ -167,12 +183,7 @@ export async function addExtensionLinux(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||||
extension +
|
|
||||||
' "' +
|
|
||||||
install_command +
|
|
||||||
'" ' +
|
|
||||||
(await utils.getExtensionPrefix(extension));
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,13 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to remove extensions
|
||||||
|
remove_extension() {
|
||||||
|
extension=$1
|
||||||
|
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||||
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
@ -26,26 +33,49 @@ add_extension() {
|
|||||||
elif php -m | grep -i -q -w "$extension"; then
|
elif php -m | grep -i -q -w "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
elif ! php -m | grep -i -q -w "$extension"; then
|
||||||
(eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
|
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to force install extensions using PECL
|
# Fuction to get the PECL version
|
||||||
install_extension() {
|
get_pecl_version() {
|
||||||
extension=$1
|
extension=$1
|
||||||
extension_name="$(echo "$extension" | cut -d'-' -f 1)"
|
stability=$2
|
||||||
sudo sed -i "/$extension_name/d" "$ini_file"
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension_name"* >/dev/null 2>&1
|
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||||
sudo rm -rf "$ext_dir"/"$extension_name".so >/dev/null 2>&1
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
sudo pecl install -f "$extension" >/dev/null 2>&1
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove extensions
|
# Function to pre-release extensions using PECL
|
||||||
remove_extension() {
|
add_unstable_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
sudo sed -i '' "/$1/d" "$ini_file"
|
stability=$2
|
||||||
sudo rm -rf "$ext_dir"/"$1".so >/dev/null 2>&1
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');")
|
||||||
|
if [ "$extension_version" = "$pecl_version" ]; then
|
||||||
|
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
remove_extension "$extension"
|
||||||
|
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
||||||
|
fi
|
||||||
|
elif php -m | grep -i -q -w "$extension"; then
|
||||||
|
extension_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$extension_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
remove_extension "$extension"
|
||||||
|
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool
|
# Function to setup a remote tool
|
||||||
@ -75,22 +105,29 @@ add_tool() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to add a tool using composer
|
||||||
add_composer_tool() {
|
add_composer_tool() {
|
||||||
tool=$1
|
tool=$1
|
||||||
release=$2
|
release=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 && \
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" && \
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to configure PECL
|
||||||
|
configure_pecl() {
|
||||||
|
for tool in pear pecl; do
|
||||||
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to log PECL, it is installed along with PHP
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
||||||
sudo pear config-set auto_discover 1 >/dev/null 2>&1
|
|
||||||
sudo pear channel-update pear.php.net >/dev/null 2>&1
|
|
||||||
sudo pecl channel-update pecl.php.net >/dev/null 2>&1
|
|
||||||
add_log "$tick" "PECL" "Added"
|
add_log "$tick" "PECL" "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,3 +154,4 @@ sudo chmod 777 "$ini_file"
|
|||||||
mkdir -p "$(pecl config-get ext_dir)"
|
mkdir -p "$(pecl config-get ext_dir)"
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
add_log "$tick" "PHP" "Installed PHP $semver"
|
add_log "$tick" "PHP" "Installed PHP $semver"
|
||||||
|
configure_pecl
|
||||||
|
@ -27,14 +27,27 @@ update_ppa() {
|
|||||||
configure_pecl() {
|
configure_pecl() {
|
||||||
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
||||||
for tool in pear pecl; do
|
for tool in pear pecl; do
|
||||||
sudo $tool config-set php_ini "$ini_file" >/dev/null 2>&1
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
sudo $tool config-set auto_discover 1 >/dev/null 2>&1
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
sudo $tool channel-update $tool.php.net >/dev/null 2>&1
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
pecl_config="true"
|
pecl_config="true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fuction to get the PECL version
|
||||||
|
get_pecl_version() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
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*)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
@ -53,25 +66,57 @@ add_extension() {
|
|||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to force install extensions using PECL
|
# Function to delete extensions
|
||||||
install_extension() {
|
delete_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
extension_name="$(echo "$extension" | cut -d'-' -f 1)"
|
sudo sed -i "/$extension/d" "$ini_file"
|
||||||
sudo sed -i "/$extension_name/d" "$ini_file"
|
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension"* >/dev/null 2>&1
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension_name"* >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension_name".so >/dev/null 2>&1
|
|
||||||
sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove extensions
|
# Function to disable and delete extensions
|
||||||
remove_extension() {
|
remove_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||||
sudo phpdismod -v "$version" "$extension"
|
sudo phpdismod -v "$version" "$extension"
|
||||||
fi
|
fi
|
||||||
sudo sed -i "/$extension/d" "$ini_file"
|
delete_extension "$extension"
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension"* >/dev/null 2>&1
|
}
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
(sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to pre-release extensions using PECL
|
||||||
|
add_unstable_extension() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');")
|
||||||
|
if [ "$extension_version" = "$pecl_version" ]; then
|
||||||
|
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
delete_extension "$extension"
|
||||||
|
add_pecl_extension "$extension" "$pecl_version"
|
||||||
|
fi
|
||||||
|
elif php -m | grep -i -q -w "$extension"; then
|
||||||
|
extension_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$extension_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
delete_extension "$extension"
|
||||||
|
add_pecl_extension "$extension" "$pecl_version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
add_pecl_extension "$extension" "$pecl_version"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update extension
|
# Function to update extension
|
||||||
@ -99,27 +144,27 @@ add_tool() {
|
|||||||
status_code=$(sudo curl -s -w "%{http_code}" -o /usr/local/bin/"$tool" -L "$url")
|
status_code=$(sudo curl -s -w "%{http_code}" -o /usr/local/bin/"$tool" -L "$url")
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x /usr/local/bin/"$tool"
|
sudo chmod a+x /usr/local/bin/"$tool"
|
||||||
add_log "$tick" "$tool" "Added"
|
|
||||||
else
|
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
fi
|
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
fi
|
elif [ "$tool" = "phive" ]; then
|
||||||
if [ "$tool" = "phive" ]; then
|
|
||||||
add_extension curl >/dev/null 2>&1
|
add_extension curl >/dev/null 2>&1
|
||||||
add_extension mbstring >/dev/null 2>&1
|
add_extension mbstring >/dev/null 2>&1
|
||||||
add_extension xml >/dev/null 2>&1
|
add_extension xml >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
add_log "$tick" "$tool" "Added"
|
||||||
|
else
|
||||||
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to setup a tool using composer
|
||||||
add_composer_tool() {
|
add_composer_tool() {
|
||||||
tool=$1
|
tool=$1
|
||||||
release=$2
|
release=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 && \
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" && \
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
@ -150,7 +195,9 @@ setup_master() {
|
|||||||
# Function to setup PECL
|
# Function to setup PECL
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
add_devtools
|
add_devtools
|
||||||
|
if [ ! -e /usr/bin/pecl ]; then
|
||||||
$apt_install php-pear >/dev/null 2>&1
|
$apt_install php-pear >/dev/null 2>&1
|
||||||
|
fi
|
||||||
configure_pecl
|
configure_pecl
|
||||||
add_log "$tick" "PECL" "Added"
|
add_log "$tick" "PECL" "Added"
|
||||||
}
|
}
|
||||||
@ -172,7 +219,6 @@ pecl_config="false"
|
|||||||
version=$1
|
version=$1
|
||||||
apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y"
|
apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y"
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
@ -182,9 +228,7 @@ sudo mkdir -p /run/php
|
|||||||
if [ "$existing_version" != "$version" ]; then
|
if [ "$existing_version" != "$version" ]; then
|
||||||
if [ ! -e "/usr/bin/php$version" ]; then
|
if [ ! -e "/usr/bin/php$version" ]; then
|
||||||
update_ppa
|
update_ppa
|
||||||
if [ "$version" = "7.4" ]; then
|
if [ "$version" = "8.0" ]; then
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml php"$version"-phpdbg >/dev/null 2>&1
|
|
||||||
elif [ "$version" = "8.0" ]; then
|
|
||||||
setup_master
|
setup_master
|
||||||
else
|
else
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||||
@ -196,9 +240,10 @@ if [ "$existing_version" != "$version" ]; then
|
|||||||
|
|
||||||
switch_version
|
switch_version
|
||||||
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
if [ "$version" = "8.0" ]; then
|
if [ "$version" = "8.0" ]; then
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
else
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$status" != "switched" ]; then
|
if [ "$status" != "switched" ]; then
|
||||||
@ -207,6 +252,7 @@ if [ "$existing_version" != "$version" ]; then
|
|||||||
status="Switched to PHP $semver"
|
status="Switched to PHP $semver"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
status="PHP $semver Found"
|
status="PHP $semver Found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ Function Add-Extension {
|
|||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||||
if ($null -ne $extension_info -and $mininum_stability -eq 'stable') {
|
if ($null -ne $extension_info) {
|
||||||
switch ($extension_info.State) {
|
switch ($extension_info.State) {
|
||||||
'Builtin' {
|
'Builtin' {
|
||||||
Add-Log $tick $extension "Enabled"
|
Add-Log $tick $extension "Enabled"
|
||||||
@ -51,13 +51,9 @@ Function Add-Extension {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
|
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
|
||||||
if($mininum_stability -ne 'stable') {
|
|
||||||
Add-Log $tick "$extension-$mininum_stability" "Installed and enabled"
|
|
||||||
} else {
|
|
||||||
Add-Log $tick $extension "Installed and enabled"
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
catch {
|
||||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user