From cdda8c2bddf80053c3d829ef98b3e415911a6d00 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 28 Sep 2021 13:11:38 +0200 Subject: [PATCH] Fix installing ionCube in multiarch, fix installing SourceGuardian for 32-bit PHP (#444) --- install-php-extensions | 107 +++++++++++++++++++++++------------ scripts/tests/ioncube_loader | 24 ++++++++ 2 files changed, 95 insertions(+), 36 deletions(-) create mode 100755 scripts/tests/ioncube_loader diff --git a/install-php-extensions b/install-php-extensions index d38fe37..4b977d2 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -74,12 +74,14 @@ setDistro() { # - PHP_MAJMINPAT_VERSION: Major-Minor-Patch version, format MMmmpp (example 80001 for PHP 8.0.1) variables containing integers value # - PHP_MAJDOTMINDOTPAT_VERSION: Major-Minor-Patch version, format M.m.p (example 8.0.1 for PHP 8.0.1) # - PHP_THREADSAFE: 1 if PHP is thread-safe (TS), 0 if not thread-safe (NTS) +# - PHP_BITS: 32 if PHP is compiled for 32-bit, 64 if 64-bit setPHPVersionVariables() { PHP_MAJDOTMINDOTPAT_VERSION="$(php-config --version)" PHP_MAJMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*100+$2}') PHP_MAJDOTMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | cut -d. -f1-2) PHP_MAJMINPAT_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*10000+$2*100+$3}') PHP_THREADSAFE=$(php -r 'echo ZEND_THREAD_SAFE ? 1 : 0;') + PHP_BITS=$(php -r 'echo PHP_INT_SIZE * 8;') } # Fix apt-get being very slow on Debian Jessie @@ -1317,17 +1319,20 @@ compareVersions() { # Set: # ORACLE_INSTANTCLIENT_LIBPATH installOracleInstantClient() { - if test $(php -r 'echo PHP_INT_SIZE;') -eq 4; then - installOracleInstantClient_client=client - installOracleInstantClient_version='19.9' - installOracleInstantClient_ic=https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-basic-linux-$installOracleInstantClient_version.0.0.0dbru.zip - installOracleInstantClient_sdk=https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-sdk-linux-$installOracleInstantClient_version.0.0.0dbru.zip - else - installOracleInstantClient_client=client64 - installOracleInstantClient_version='21.1' - installOracleInstantClient_ic=https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basic-linux.x64-$installOracleInstantClient_version.0.0.0.zip - installOracleInstantClient_sdk=https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sdk-linux.x64-$installOracleInstantClient_version.0.0.0.zip - fi + case $PHP_BITS in + 32) + installOracleInstantClient_client=client + installOracleInstantClient_version='19.9' + installOracleInstantClient_ic=https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-basic-linux-$installOracleInstantClient_version.0.0.0dbru.zip + installOracleInstantClient_sdk=https://download.oracle.com/otn_software/linux/instantclient/199000/instantclient-sdk-linux-$installOracleInstantClient_version.0.0.0dbru.zip + ;; + *) + installOracleInstantClient_client=client64 + installOracleInstantClient_version='21.1' + installOracleInstantClient_ic=https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basic-linux.x64-$installOracleInstantClient_version.0.0.0.zip + installOracleInstantClient_sdk=https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sdk-linux.x64-$installOracleInstantClient_version.0.0.0.zip + ;; + esac ORACLE_INSTANTCLIENT_LIBPATH=/usr/lib/oracle/$installOracleInstantClient_version/$installOracleInstantClient_client/lib if ! test -e "$ORACLE_INSTANTCLIENT_LIBPATH"; then printf 'Downloading Oracle Instant Client v%s... ' "$installOracleInstantClient_version" @@ -1354,11 +1359,14 @@ installOracleInstantClient() { cat "$ORACLE_INSTANTCLIENT_LIBPATH" | awk -v suffix=":$ORACLE_INSTANTCLIENT_LIBPATH" '{print NR==1 ? $0suffix : $0}' >"$ORACLE_INSTANTCLIENT_LIBPATH" fi else - if test $(php -r 'echo PHP_INT_SIZE;') -eq 4; then - echo "/lib:/usr/local/lib:/usr/lib:$ORACLE_INSTANTCLIENT_LIBPATH" >"$installOracleInstantClient_ldconf" - else - echo "/lib64:/lib:/usr/local/lib:/usr/lib:$ORACLE_INSTANTCLIENT_LIBPATH" >"$installOracleInstantClient_ldconf" - fi + case $PHP_BITS in + 32) + echo "/lib:/usr/local/lib:/usr/lib:$ORACLE_INSTANTCLIENT_LIBPATH" >"$installOracleInstantClient_ldconf" + ;; + *) + echo "/lib64:/lib:/usr/local/lib:/usr/lib:$ORACLE_INSTANTCLIENT_LIBPATH" >"$installOracleInstantClient_ldconf" + ;; + esac fi ;; debian) @@ -1457,17 +1465,54 @@ actuallyInstallComposer() { rm -- "$actuallyInstallComposer_installer" } -# Install SourceGuardian Loader -installSourceGuardian() { - case $(uname -m) in - i386 | i686 | x86) - installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-i386.tar.gz - ;; - aarch64 | arm64 | armv8) - installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-aarch64.tar.gz +# Install ionCube Loader +installIonCubeLoader() { + # See https://www.ioncube.com/loaders.php + case $PHP_BITS in + 32) + case $(uname -m) in + aarch* | arm*) + installIonCubeLoader_url="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_armv7l.tar.gz" + ;; + *) + installIonCubeLoader_url="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz" + ;; + esac ;; *) - installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gz + case $(uname -m) in + aarch64 | arm64 | armv8) + installIonCubeLoader_url="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_aarch64.tar.gz" + ;; + *) + installIonCubeLoader_url="https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz" + ;; + esac + ;; + esac + printf 'Downloading ionCube Loader... ' + installIonCubeLoader_dir="$(getPackageSource $installIonCubeLoader_url)" + echo 'done.' + installIonCubeLoader_so=$(php -r "printf('ioncube_loader_lin_%s.%s%s.so', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, ZEND_THREAD_SAFE ? '_ts' : '');") + cp "$installIonCubeLoader_dir/$installIonCubeLoader_so" "$(getPHPExtensionsDir)/ioncube_loader.so" +} + +# Install SourceGuardian Loader +installSourceGuardian() { + # See https://www.sourceguardian.com/loaders.html + case $PHP_BITS in + 32) + installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-i386.tar.gz + ;; + *) + case $(uname -m) in + aarch64 | arm64 | armv8) + installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-aarch64.tar.gz + ;; + *) + installSourceGuardian_url=https://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gz + ;; + esac ;; esac printf 'Downloading SourceGuardian... ' @@ -1970,17 +2015,7 @@ installRemoteModule() { fi ;; ioncube_loader) - installRemoteModule_src='https://downloads.ioncube.com/loader_downloads/' - if test $(php -r 'echo PHP_INT_SIZE;') -eq 4; then - installRemoteModule_src="${installRemoteModule_src}ioncube_loaders_lin_x86.tar.gz" - else - installRemoteModule_src="${installRemoteModule_src}ioncube_loaders_lin_x86-64.tar.gz" - fi - printf 'Downloading ionCube Loader... ' - installRemoteModule_src="$(getPackageSource $installRemoteModule_src)" - echo 'done.' - installRemoteModule_so=$(php -r "printf('ioncube_loader_lin_%s.%s%s.so', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, ZEND_THREAD_SAFE ? '_ts' : '');") - cp "$installRemoteModule_src/$installRemoteModule_so" "$(getPHPExtensionsDir)/$installRemoteModule_module.so" + installIonCubeLoader installRemoteModule_manuallyInstalled=1 ;; jsmin) diff --git a/scripts/tests/ioncube_loader b/scripts/tests/ioncube_loader new file mode 100755 index 0000000..a98c75e --- /dev/null +++ b/scripts/tests/ioncube_loader @@ -0,0 +1,24 @@ +#!/usr/bin/env php + 'PHP module', true => 'Zend extension'] as $type => $typeName) { + $extensions = get_loaded_extensions($type); + $found = ''; + foreach ($extensions as $extension) { + if (preg_match('/^(the )?ioncube (php )?loader/i', $extension)) { + $found = $extension; + + break; + } + } + if ($found !== '') { + fwrite(STDOUT, "The {$found} {$typeName} is loaded.\n"); + } else { + fwrite(STDERR, "The ionCube Loader {$typeName} is not loaded.\nLoaded extensions are: \n- " . implode("\n- ", $extensions)); + $rc = 1; + } +} +exit($rc);