Allow extensions to be compiled from GitHub sources

This commit is contained in:
Andreas Braun
2021-01-21 11:37:11 +01:00
committed by Shivam Mathur
parent 912f27c42c
commit f42065d568
6 changed files with 128 additions and 12 deletions

View File

@ -17,6 +17,22 @@ export async function addExtensionDarwin(
const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name);
// Install extensions from a GitHub tarball. This needs to be checked first
// as the version may also match the semver check below.
const urlMatches = extension.match(/.*-(.*)\/(.*)@(.*)/);
if (urlMatches != null) {
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
urlMatches[1],
urlMatches[2],
urlMatches[3],
ext_prefix
);
return;
}
switch (true) {
// match :extension
case /^:/.test(ext_name):
@ -142,6 +158,15 @@ export async function addExtensionWindows(
ext_version.replace('stable', '')
);
break;
// match extensions from GitHub. Do this before checking for semver as
// the version may match that as well
case /.*-(.*)\/(.*)@(.*)/.test(extension):
add_script += await utils.getUnsupportedLog(
extension,
version,
'win32'
);
break;
// match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension):
add_script += await utils.joins(
@ -214,6 +239,22 @@ export async function addExtensionLinux(
const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name);
// Install extensions from a GitHub tarball. This needs to be checked first
// as the version may also match the semver check below.
const urlMatches = extension.match(/.*-(.*)\/(.*)@(.*)/);
if (urlMatches != null) {
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
urlMatches[1],
urlMatches[2],
urlMatches[3],
ext_prefix
);
return;
}
switch (true) {
// Match :extension
case /^:/.test(ext_name):

View File

@ -39,6 +39,24 @@ add_pecl_extension() {
fi
}
# Function to install extension from a GitHub repository
add_extension_from_github() {
extension=$1
org=$2
repo=$3
release=$4
prefix=$5
(
add_devtools phpize
delete_extension "$extension"
git clone --recurse-submodules -b "$release" https://github.com/"$org"/"$repo" /tmp/"$repo-$release" || exit 1
cd /tmp/"$repo-$release" || exit 1
phpize && ./configure && make -j"$(nproc)" && sudo make install
enable_extension "$extension" "$prefix"
) >/dev/null 2>&1
add_extension_log "$extension-$org/$repo@$release" "Installed and enabled"
}
# Function to fetch a brew tap
fetch_brew_tap() {
tap=$1

View File

@ -148,23 +148,22 @@ add_pecl_extension() {
fi
}
# Function to install extension from source
add_extension_from_source() {
# Function to install extension from a GitHub repository
add_extension_from_github() {
extension=$1
repo=$2
release=$3
args=$4
org=$2
repo=$3
release=$4
prefix=$5
(
add_devtools phpize
delete_extension "$extension"
get -q -n "/tmp/$extension.tar.gz" "https://github.com/$repo/archive/$release.tar.gz"
tar xf /tmp/"$extension".tar.gz -C /tmp
cd /tmp/"$extension-$release" || exit 1
phpize && ./configure "$args" && make -j"$(nproc)" && sudo make install
git clone --recurse-submodules -b "$release" https://github.com/"$org"/"$repo" /tmp/"$repo-$release" || exit 1
cd /tmp/"$repo-$release" || exit 1
phpize && ./configure && make -j"$(nproc)" && sudo make install
enable_extension "$extension" "$prefix"
) >/dev/null 2>&1
add_extension_log "$extension-$release" "Installed and enabled"
add_extension_log "$extension-$org/$repo@$release" "Installed and enabled"
}
# Function to setup phpize and php-config.