diff --git a/.github/workflows/experimental-workflow.yml b/.github/workflows/experimental-workflow.yml index 61479ac5..0ce895a3 100644 --- a/.github/workflows/experimental-workflow.yml +++ b/.github/workflows/experimental-workflow.yml @@ -29,7 +29,7 @@ jobs: php-versions: ['8.0'] env: extensions: xml, opcache, xdebug, pcov - key: cache-v1 + key: cache-v2 steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9ff255da..d5af78a8 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -27,7 +27,7 @@ jobs: php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] env: extensions: xml, opcache, xdebug, pcov - key: cache-v1 + key: cache-v2 steps: - name: Checkout uses: actions/checkout@v2 diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 262ce269..e8c5cb29 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -35,15 +35,15 @@ describe('Extension tests', () => { it('checking addExtensionOnLinux', async () => { let linux: string = await extensions.addExtension( - 'xdebug, pcov, ast-beta, xdebug-alpha, grpc-1.2.3', + 'xdebug, pcov, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', '7.4', 'linux' ); expect(linux).toContain('update_extension xdebug 2.9.1'); - expect(linux).toContain( - 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov' - ); + expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov'); expect(linux).toContain('add_unstable_extension ast beta extension'); + expect(linux).toContain('add_pdo_extension mysql'); + expect(linux).toContain('add_pdo_extension odbc'); expect(linux).toContain('add_pecl_extension grpc 1.2.3 extension'); expect(linux).toContain( 'add_unstable_extension xdebug alpha zend_extension' diff --git a/dist/index.js b/dist/index.js index 8d46cf46..2b3b82ad 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2917,12 +2917,18 @@ function addExtensionLinux(extension_csv, version, pipe) { '\n' + (yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); return; + // match pdo extensions + case /.*pdo[_-].*/.test(version_extension): + script += + '\nadd_pdo_extension ' + + extension.replace('pdo_', '').replace('pdo-', ''); + return; default: install_command = - 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' + + 'sudo $debconf_fix apt-get install -y php' + version + '-' + - extension.replace('pdo_', '').replace('pdo-', '') + + extension + pipe; break; } diff --git a/package-lock.json b/package-lock.json index 855e7e59..a164d42c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -32,18 +32,18 @@ } }, "@babel/core": { - "version": "7.8.6", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.6.tgz", - "integrity": "sha512-Sheg7yEJD51YHAvLEV/7Uvw95AeWqYPL3Vk3zGujJKIhJ+8oLw2ALaf3hbucILhKsgSoADOvtKRJuNVdcJkOrg==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.7.tgz", + "integrity": "sha512-rBlqF3Yko9cynC5CCFy6+K/w2N+Sq/ff2BPy+Krp7rHlABIr5epbA7OxVeKoMHB39LZOp1UY5SuLjy6uWi35yA==", "dev": true, "requires": { "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.8.6", + "@babel/generator": "^7.8.7", "@babel/helpers": "^7.8.4", - "@babel/parser": "^7.8.6", + "@babel/parser": "^7.8.7", "@babel/template": "^7.8.6", "@babel/traverse": "^7.8.6", - "@babel/types": "^7.8.6", + "@babel/types": "^7.8.7", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.1", @@ -69,12 +69,12 @@ } }, "@babel/generator": { - "version": "7.8.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.6.tgz", - "integrity": "sha512-4bpOR5ZBz+wWcMeVtcf7FbjcFzCp+817z2/gHNncIRcM9MmKzUhtWCYAq27RAfUrAFwb+OCG1s9WEaVxfi6cjg==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.7.tgz", + "integrity": "sha512-DQwjiKJqH4C3qGiyQCAExJHoZssn49JTMJgZ8SANGgVFdkupcUhLOdkAeoC6kmHZCPfoDG5M0b6cFlSN5wW7Ew==", "dev": true, "requires": { - "@babel/types": "^7.8.6", + "@babel/types": "^7.8.7", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -198,9 +198,9 @@ } }, "@babel/parser": { - "version": "7.8.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.6.tgz", - "integrity": "sha512-trGNYSfwq5s0SgM1BMEB8hX3NDmO7EP2wsDGDexiaKMB92BaRpS+qZfpkMqUBhcsOTBwNy9B/jieo4ad/t/z2g==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.7.tgz", + "integrity": "sha512-9JWls8WilDXFGxs0phaXAZgpxTZhSk/yOYH2hTHC0X1yC7Z78IJfvR1vJ+rmJKq3I35td2XzXzN6ZLYlna+r/A==", "dev": true }, "@babel/plugin-syntax-bigint": { @@ -222,12 +222,12 @@ } }, "@babel/runtime": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.4.tgz", - "integrity": "sha512-neAp3zt80trRVBI1x0azq6c57aNBqYZH8KhMm3TaB7wEI5Q4A2SHfBHE8w9gOhI/lrqxtEbXZgQIrHP+wvSGwQ==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.7.tgz", + "integrity": "sha512-+AATMUFppJDw6aiR5NVPHqIQBlV/Pj8wY/EZH+lmvRdUo9xBaz/rF3alAwFJQavvKfeOlPE7oaaDHVbcySbCsg==", "dev": true, "requires": { - "regenerator-runtime": "^0.13.2" + "regenerator-runtime": "^0.13.4" } }, "@babel/template": { @@ -267,9 +267,9 @@ } }, "@babel/types": { - "version": "7.8.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.6.tgz", - "integrity": "sha512-wqz7pgWMIrht3gquyEFPVXeXCti72Rm8ep9b5tQKz9Yg9LzJA3HxosF1SB3Kc81KD1A3XBkkVYtJvCKS2Z/QrA==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.7.tgz", + "integrity": "sha512-k2TreEHxFA4CjGkL+GYjRyx35W0Mr7DP5+9q6WMkyKXB+904bYmG40syjMFV0oLlhhFCwWl0vA0DyzTDkwAiJw==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -662,9 +662,9 @@ } }, "@types/jest": { - "version": "25.1.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.3.tgz", - "integrity": "sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg==", + "version": "25.1.4", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.4.tgz", + "integrity": "sha512-QDDY2uNAhCV7TMCITrxz+MRk1EizcsevzfeS6LykIlq2V1E5oO4wXG8V2ZEd9w7Snxeeagk46YbMgZ8ESHx3sw==", "dev": true, "requires": { "jest-diff": "^25.1.0", @@ -678,9 +678,9 @@ "dev": true }, "@types/node": { - "version": "13.7.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.7.tgz", - "integrity": "sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg==", + "version": "13.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz", + "integrity": "sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==", "dev": true }, "@types/parse-json": { @@ -711,12 +711,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.21.0.tgz", - "integrity": "sha512-b5jjjDMxzcjh/Sbjuo7WyhrQmVJg0WipTHQgXh5Xwx10uYm6nPWqN1WGOsaNq4HR3Zh4wUx4IRQdDkCHwyewyw==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.22.0.tgz", + "integrity": "sha512-BvxRLaTDVQ3N+Qq8BivLiE9akQLAOUfxNHIEhedOcg8B2+jY8Rc4/D+iVprvuMX1AdezFYautuGDwr9QxqSxBQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.21.0", + "@typescript-eslint/experimental-utils": "2.22.0", "eslint-utils": "^1.4.3", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -724,32 +724,32 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.21.0.tgz", - "integrity": "sha512-olKw9JP/XUkav4lq0I7S1mhGgONJF9rHNhKFn9wJlpfRVjNo3PPjSvybxEldvCXnvD+WAshSzqH5cEjPp9CsBA==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz", + "integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.21.0", + "@typescript-eslint/typescript-estree": "2.22.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.21.0.tgz", - "integrity": "sha512-VrmbdrrrvvI6cPPOG7uOgGUFXNYTiSbnRq8ZMyuGa4+qmXJXVLEEz78hKuqupvkpwJQNk1Ucz1TenrRP90gmBg==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.22.0.tgz", + "integrity": "sha512-FaZKC1X+nvD7qMPqKFUYHz3H0TAioSVFGvG29f796Nc5tBluoqfHgLbSFKsh7mKjRoeTm8J9WX2Wo9EyZWjG7w==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.21.0", - "@typescript-eslint/typescript-estree": "2.21.0", + "@typescript-eslint/experimental-utils": "2.22.0", + "@typescript-eslint/typescript-estree": "2.22.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.21.0.tgz", - "integrity": "sha512-NC/nogZNb9IK2MEFQqyDBAciOT8Lp8O3KgAfvHx2Skx6WBo+KmDqlU3R9KxHONaijfTIKtojRe3SZQyMjr3wBw==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz", + "integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==", "dev": true, "requires": { "debug": "^4.1.1", @@ -1113,9 +1113,9 @@ } }, "browser-process-hrtime": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", - "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", "dev": true }, "browser-resolve": { @@ -1883,9 +1883,9 @@ } }, "eslint-plugin-jest": { - "version": "23.8.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.1.tgz", - "integrity": "sha512-OycLNqPo/2EfO6kTqnmsu1khz1gTIOxGl3ThIVwL5/oycDF4pm5uNDyvFelNLdpr4COUuM8PVi3963NEG1Efpw==", + "version": "23.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz", + "integrity": "sha512-xwbnvOsotSV27MtAe7s8uGWOori0nUsrXh2f1EnpmXua8sDfY6VZhHAhHg2sqK7HBNycRQExF074XSZ7DvfoFg==", "dev": true, "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" @@ -1926,13 +1926,13 @@ "dev": true }, "espree": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", - "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.0.tgz", + "integrity": "sha512-Xs8airJ7RQolnDIbLtRutmfvSsAe0xqMMAantCN/GMoqf81TFbeI1T7Jpd56qYu1uuh32dOG5W/X9uO+ghPXzA==", "dev": true, "requires": { "acorn": "^7.1.0", - "acorn-jsx": "^5.1.0", + "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.1.0" } }, @@ -2739,9 +2739,9 @@ "dev": true }, "inquirer": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.5.tgz", - "integrity": "sha512-6Z5cP+LAO0rzNE7xWjWtT84jxKa5ScLEGLgegPXeO3dGeU8lNe5Ii7SlXH6KVtLGlDuaEhsvsFjrjWjw8j5lFg==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.6.tgz", + "integrity": "sha512-7SVO4h+QIdMq6XcqIqrNte3gS5MzCCKZdsq9DO4PJziBFNYzP3PGFbDjgadDb//MCahzgjCxvQ/O2wa7kx9o4w==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", @@ -4430,9 +4430,9 @@ } }, "regenerator-runtime": { - "version": "0.13.3", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", - "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz", + "integrity": "sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==", "dev": true }, "regex-not": { @@ -5713,12 +5713,12 @@ } }, "w3c-hr-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", - "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", + "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", "dev": true, "requires": { - "browser-process-hrtime": "^0.1.2" + "browser-process-hrtime": "^1.0.0" } }, "w3c-xmlserializer": { @@ -5874,12 +5874,12 @@ "dev": true }, "yaml": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", - "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.0.tgz", + "integrity": "sha512-6qI/tTx7OVtA4qNqD0OyutbM6Z9EKu4rxWm/2Y3FDEBQ4/2X2XAnyuRXMzAE2+1BPyqzksJZtrIwblOHg0IEzA==", "dev": true, "requires": { - "@babel/runtime": "^7.6.3" + "@babel/runtime": "^7.8.7" } }, "yargs": { diff --git a/package.json b/package.json index 75143cff..fe804acd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "2.1.0", + "version": "2.1.1", "private": false, "description": "Setup PHP for use with GitHub Actions", "main": "dist/index.js", @@ -30,15 +30,15 @@ "fs": "0.0.1-security" }, "devDependencies": { - "@types/jest": "^25.1.3", - "@types/node": "^13.7.7", - "@typescript-eslint/eslint-plugin": "^2.21.0", - "@typescript-eslint/parser": "^2.21.0", + "@types/jest": "^25.1.4", + "@types/node": "^13.9.0", + "@typescript-eslint/eslint-plugin": "^2.22.0", + "@typescript-eslint/parser": "^2.22.0", "@zeit/ncc": "^0.21.1", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.0", "eslint-plugin-import": "^2.20.1", - "eslint-plugin-jest": "^23.8.1", + "eslint-plugin-jest": "^23.8.2", "eslint-plugin-prettier": "^3.1.2", "husky": "^4.2.3", "jest": "^25.1.0", diff --git a/src/extensions.ts b/src/extensions.ts index a0d35cfb..cd4c4d29 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -241,12 +241,18 @@ export async function addExtensionLinux( '\n' + (await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); return; + // match pdo extensions + case /.*pdo[_-].*/.test(version_extension): + script += + '\nadd_pdo_extension ' + + extension.replace('pdo_', '').replace('pdo-', ''); + return; default: install_command = - 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' + + 'sudo $debconf_fix apt-get install -y php' + version + '-' + - extension.replace('pdo_', '').replace('pdo-', '') + + extension + pipe; break; } diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 7028217a..0ee7d0ee 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -74,11 +74,10 @@ add_extension() { elif check_extension "$extension"; then add_log "$tick" "$extension" "Enabled" elif ! check_extension "$extension"; then - ( - eval "$install_command" >/dev/null 2>&1 && - check_extension "$extension" && - add_log "$tick" "$extension" "Installed and enabled" - ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + eval "$install_command" >/dev/null 2>&1 && + if [[ "$version" =~ $old_versions ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi + (check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") || + add_log "$cross" "$extension" "Could not install $extension on PHP $semver" fi } @@ -172,6 +171,7 @@ setup_php() { tick="✓" cross="✗" version=$1 +nodot_version=${1/./} old_versions="5.[3-5]" tool_path_dir="/usr/local/bin" existing_version=$(php-config --version | cut -c 1-3) @@ -180,8 +180,7 @@ existing_version=$(php-config --version | cut -c 1-3) # Setup PHP step_log "Setup PHP" if [[ "$version" =~ $old_versions ]]; then - script="https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh" - curl -sSL "$script" | bash -s "$version" >/dev/null 2>&1 && + curl -sSL https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 && status="Installed" elif [ "$existing_version" != "$version" ]; then setup_php "install" @@ -195,10 +194,9 @@ fi ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") sudo chmod 777 "$ini_file" "$tool_path_dir" echo "date.timezone=UTC" >>"$ini_file" -echo "detect_unicode=Off" >>"$ini_file" -ext_dir=$(php -i | grep -Ei "extension_dir => /usr" | sed -e "s|.*=> s*||") +ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") sudo mkdir -p "$ext_dir" semver=$(php -v | head -n 1 | cut -f 2 -d ' ') -configure_pecl +if [[ ! "$version" =~ $old_versions ]]; then configure_pecl; fi add_log "$tick" "PHP" "$status PHP $semver" diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 35077fa0..d70a28d2 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -56,8 +56,7 @@ get_pecl_version() { # Function to test if extension is loaded check_extension() { - extension=$1 - php -m | grep -i -q -w "$extension" + php -m | grep -i -q -w "$1" } # Function to delete extensions @@ -77,6 +76,32 @@ remove_extension() { delete_extension "$extension" } +# Function to enable existing extension +enable_extension() { + if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then + echo "$2=$1.so" >>"$ini_file" + fi +} + +# Funcion to add PDO extension +add_pdo_extension() { + pdo_ext="pdo_$1" + if check_extension "$pdo_ext"; then + add_log "$tick" "$pdo_ext" "Enabled" + else + read -r ext ext_name <<< "$1 $1" + sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1 && enable_extension "pdo" "extension" >/dev/null 2>&1 + if [ "$ext" = "mysql" ]; then + enable_extension "mysqlnd" "extension" + ext_name="mysqli" + fi + add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1 + enable_extension "$pdo_ext" "extension" + (check_extension "$pdo_ext" && add_log "$tick" "$pdo_ext" "Enabled") || + add_log "$cross" "$pdo_ext" "Could not install $pdo_ext on PHP $semver" + fi +} + # Function to setup extensions add_extension() { extension=$1 @@ -85,11 +110,10 @@ add_extension() { if [[ "$version" =~ $old_versions ]]; then install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}" fi - if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then - echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" - elif check_extension "$extension"; then + enable_extension "$extension" "$prefix" + if check_extension "$extension"; then add_log "$tick" "$extension" "Enabled" - elif ! check_extension "$extension"; then + else eval "$install_command" >/dev/null 2>&1 || (update_ppa && eval "$install_command" >/dev/null 2>&1) || sudo pecl install -f "$extension" >/dev/null 2>&1