mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Refactor to dry unix scripts
This commit is contained in:
parent
7de94e6400
commit
d812e938ac
@ -21,7 +21,7 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
it('checking addCoverage with PCOV on darwin', async () => {
|
it('checking addCoverage with PCOV on darwin', async () => {
|
||||||
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
||||||
expect(darwin).toContain('add_extension pcov');
|
expect(darwin).toContain('add_brew_extension pcov');
|
||||||
expect(darwin).toContain('remove_extension xdebug');
|
expect(darwin).toContain('remove_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ describe('Config tests', () => {
|
|||||||
'7.4',
|
'7.4',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(darwin).toContain('add_extension xdebug');
|
expect(darwin).toContain('add_brew_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking disableCoverage windows', async () => {
|
it('checking disableCoverage windows', async () => {
|
||||||
|
@ -59,20 +59,15 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
|
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
expect(linux).toContain('add_extension sqlite3');
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
|
||||||
);
|
|
||||||
expect(linux).toContain('remove_extension intl');
|
expect(linux).toContain('remove_extension intl');
|
||||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-ast');
|
|
||||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
|
|
||||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(linux).toContain('add_pdo_extension mysql');
|
expect(linux).toContain('add_pdo_extension mysql');
|
||||||
expect(linux).toContain('add_pdo_extension odbc');
|
expect(linux).toContain('add_pdo_extension odbc');
|
||||||
@ -81,11 +76,6 @@ describe('Extension tests', () => {
|
|||||||
'add_unstable_extension xdebug alpha zend_extension'
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
);
|
);
|
||||||
|
|
||||||
linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
|
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
|
|
||||||
);
|
|
||||||
|
|
||||||
linux = await extensions.addExtension('pcov', '5.6', 'linux');
|
linux = await extensions.addExtension('pcov', '5.6', 'linux');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
|
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
|
||||||
@ -134,14 +124,14 @@ describe('Extension tests', () => {
|
|||||||
'7.2',
|
'7.2',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(darwin).toContain('add_brew_extension xdebug');
|
expect(darwin).toContain('add_brew_extension xdebug zend_extension');
|
||||||
expect(darwin).toContain('add_brew_extension pcov');
|
expect(darwin).toContain('add_brew_extension pcov extension');
|
||||||
expect(darwin).toContain('add_brew_extension grpc');
|
expect(darwin).toContain('add_brew_extension grpc extension');
|
||||||
expect(darwin).toContain('add_brew_extension igbinary');
|
expect(darwin).toContain('add_brew_extension igbinary extension');
|
||||||
expect(darwin).toContain('add_brew_extension imagick');
|
expect(darwin).toContain('add_brew_extension imagick extension');
|
||||||
expect(darwin).toContain('add_brew_extension protobuf');
|
expect(darwin).toContain('add_brew_extension protobuf extension');
|
||||||
expect(darwin).toContain('add_brew_extension swoole');
|
expect(darwin).toContain('add_brew_extension swoole extension');
|
||||||
expect(darwin).toContain('pecl_install sqlite3');
|
expect(darwin).toContain('add_extension sqlite3');
|
||||||
expect(darwin).toContain('remove_extension intl');
|
expect(darwin).toContain('remove_extension intl');
|
||||||
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
|
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
|
||||||
@ -177,14 +167,13 @@ describe('Extension tests', () => {
|
|||||||
expect(darwin).toContain('add_brew_extension xdebug');
|
expect(darwin).toContain('add_brew_extension xdebug');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
|
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('pecl_install redis-2.2.8');
|
expect(darwin).toContain('add_extension redis-2.2.8');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
|
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('pecl_install redis');
|
expect(darwin).toContain('add_extension redis');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
|
darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
|
||||||
expect(darwin).toContain('brew install pkg-config imagemagick');
|
expect(darwin).toContain('add_extension imagick');
|
||||||
expect(darwin).toContain('pecl_install imagick');
|
|
||||||
|
|
||||||
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
|
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
|
||||||
expect(darwin).toContain('add_blackfire blackfire');
|
expect(darwin).toContain('add_blackfire blackfire');
|
||||||
|
47
dist/index.js
vendored
47
dist/index.js
vendored
@ -2570,6 +2570,7 @@ async function getScript(filename, version, os_version) {
|
|||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'https://setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
// taking inputs
|
// taking inputs
|
||||||
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
const extension_csv = await utils.getInput('extensions', false);
|
const extension_csv = await utils.getInput('extensions', false);
|
||||||
const ini_values_csv = await utils.getInput('ini-values', false);
|
const ini_values_csv = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver = await utils.getInput('coverage', false);
|
const coverage_driver = await utils.getInput('coverage', false);
|
||||||
@ -2603,8 +2604,7 @@ async function run() {
|
|||||||
const tool = await utils.scriptTool(os_version);
|
const tool = await utils.scriptTool(os_version);
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
const script = os_version + (await utils.scriptExtension(os_version));
|
||||||
const location = await getScript(script, version, os_version);
|
const location = await getScript(script, version, os_version);
|
||||||
const fail_fast = await utils.readEnv('fail-fast');
|
await exec_1.exec(await utils.joins(tool, location, version, __dirname));
|
||||||
await exec_1.exec(await utils.joins(tool, location, version, __dirname, fail_fast));
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@ -2865,9 +2865,8 @@ const utils = __importStar(__webpack_require__(163));
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param pipe
|
|
||||||
*/
|
*/
|
||||||
async function addExtensionDarwin(extension_csv, version, pipe) {
|
async function addExtensionDarwin(extension_csv, version) {
|
||||||
const extensions = await utils.extensionArray(extension_csv);
|
const extensions = await utils.extensionArray(extension_csv);
|
||||||
let add_script = '\n';
|
let add_script = '\n';
|
||||||
let remove_script = '';
|
let remove_script = '';
|
||||||
@ -2875,8 +2874,6 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
const [ext_name, ext_version] = extension.split('-');
|
const [ext_name, ext_version] = extension.split('-');
|
||||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||||
const command_prefix = 'pecl_install ';
|
|
||||||
let command = '';
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match :extension
|
// match :extension
|
||||||
case /^:/.test(ext_name):
|
case /^:/.test(ext_name):
|
||||||
@ -2911,26 +2908,20 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
|
case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension):
|
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension):
|
||||||
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
|
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
|
||||||
command = 'add_brew_extension ' + ext_name;
|
add_script += await utils.joins('\nadd_brew_extension', ext_name, ext_prefix);
|
||||||
break;
|
return;
|
||||||
// match 5.6redis
|
// match 5.6redis
|
||||||
case /5\.6redis/.test(version_extension):
|
case /5\.6redis/.test(version_extension):
|
||||||
command = command_prefix + 'redis-2.2.8';
|
extension = 'redis-2.2.8';
|
||||||
break;
|
|
||||||
// match 5.4imagick and 5.5imagick
|
|
||||||
case /^5\.[4-5]imagick$/.test(version_extension):
|
|
||||||
command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe);
|
|
||||||
break;
|
break;
|
||||||
// match sqlite
|
// match sqlite
|
||||||
case /^sqlite$/.test(extension):
|
case /^sqlite$/.test(extension):
|
||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + extension;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
command = command_prefix + extension;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix);
|
add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
|
||||||
});
|
});
|
||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
@ -3013,9 +3004,8 @@ exports.addExtensionWindows = addExtensionWindows;
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param pipe
|
|
||||||
*/
|
*/
|
||||||
async function addExtensionLinux(extension_csv, version, pipe) {
|
async function addExtensionLinux(extension_csv, version) {
|
||||||
const extensions = await utils.extensionArray(extension_csv);
|
const extensions = await utils.extensionArray(extension_csv);
|
||||||
let add_script = '\n';
|
let add_script = '\n';
|
||||||
let remove_script = '';
|
let remove_script = '';
|
||||||
@ -3023,8 +3013,6 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
const [ext_name, ext_version] = extension.split('-');
|
const [ext_name, ext_version] = extension.split('-');
|
||||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||||
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
|
||||||
let command = '';
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// Match :extension
|
// Match :extension
|
||||||
case /^:/.test(ext_name):
|
case /^:/.test(ext_name):
|
||||||
@ -3066,27 +3054,20 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
// match 8.0xdebug3...8.9xdebug3
|
// match 8.0xdebug3...8.9xdebug3
|
||||||
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||||
extension = 'xdebug';
|
extension = 'xdebug';
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
// match pdo extensions
|
// match pdo extensions
|
||||||
case /.*pdo[_-].*/.test(version_extension):
|
case /.*pdo[_-].*/.test(version_extension):
|
||||||
extension = extension.replace(/pdo[_-]|3/, '');
|
extension = extension.replace(/pdo[_-]|3/, '');
|
||||||
add_script += '\nadd_pdo_extension ' + extension;
|
add_script += '\nadd_pdo_extension ' + extension;
|
||||||
return;
|
return;
|
||||||
// match uopz
|
|
||||||
case /^(uopz)$/.test(extension):
|
|
||||||
command = command_prefix + '-' + extension + pipe;
|
|
||||||
break;
|
|
||||||
// match sqlite
|
// match sqlite
|
||||||
case /^sqlite$/.test(extension):
|
case /^sqlite$/.test(extension):
|
||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix);
|
add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
|
||||||
});
|
});
|
||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
@ -3100,24 +3081,24 @@ exports.addExtensionLinux = addExtensionLinux;
|
|||||||
* @param no_step
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
async function addExtension(extension_csv, version, os_version, no_step = false) {
|
async function addExtension(extension_csv, version, os_version, no_step = false) {
|
||||||
const pipe = await utils.suppressOutput(os_version);
|
const log = await utils.stepLog('Setup Extensions', os_version);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe;
|
script += log + (await utils.suppressOutput(os_version));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += await utils.stepLog('Setup Extensions', os_version);
|
script += log;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
return script + (await addExtensionDarwin(extension_csv, version));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addExtensionLinux(extension_csv, version, pipe));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,10 @@ import * as utils from './utils';
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param pipe
|
|
||||||
*/
|
*/
|
||||||
export async function addExtensionDarwin(
|
export async function addExtensionDarwin(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
pipe: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let add_script = '\n';
|
let add_script = '\n';
|
||||||
@ -19,8 +17,6 @@ export async function addExtensionDarwin(
|
|||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
const [ext_name, ext_version]: string[] = extension.split('-');
|
const [ext_name, ext_version]: string[] = extension.split('-');
|
||||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||||
const command_prefix = 'pecl_install ';
|
|
||||||
let command = '';
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match :extension
|
// match :extension
|
||||||
case /^:/.test(ext_name):
|
case /^:/.test(ext_name):
|
||||||
@ -74,34 +70,24 @@ export async function addExtensionDarwin(
|
|||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
|
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
|
||||||
command = 'add_brew_extension ' + ext_name;
|
add_script += await utils.joins(
|
||||||
break;
|
'\nadd_brew_extension',
|
||||||
|
ext_name,
|
||||||
|
ext_prefix
|
||||||
|
);
|
||||||
|
return;
|
||||||
// match 5.6redis
|
// match 5.6redis
|
||||||
case /5\.6redis/.test(version_extension):
|
case /5\.6redis/.test(version_extension):
|
||||||
command = command_prefix + 'redis-2.2.8';
|
extension = 'redis-2.2.8';
|
||||||
break;
|
|
||||||
// match 5.4imagick and 5.5imagick
|
|
||||||
case /^5\.[4-5]imagick$/.test(version_extension):
|
|
||||||
command = await utils.joins(
|
|
||||||
'brew install pkg-config imagemagick' + pipe,
|
|
||||||
'&& ' + command_prefix + 'imagick' + pipe
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
// match sqlite
|
// match sqlite
|
||||||
case /^sqlite$/.test(extension):
|
case /^sqlite$/.test(extension):
|
||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + extension;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
command = command_prefix + extension;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_script += await utils.joins(
|
add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
|
||||||
'\nadd_extension',
|
|
||||||
extension,
|
|
||||||
'"' + command + '"',
|
|
||||||
ext_prefix
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
@ -210,12 +196,10 @@ export async function addExtensionWindows(
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param pipe
|
|
||||||
*/
|
*/
|
||||||
export async function addExtensionLinux(
|
export async function addExtensionLinux(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
pipe: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let add_script = '\n';
|
let add_script = '\n';
|
||||||
@ -224,8 +208,6 @@ export async function addExtensionLinux(
|
|||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
const [ext_name, ext_version]: string[] = extension.split('-');
|
const [ext_name, ext_version]: string[] = extension.split('-');
|
||||||
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
const ext_prefix = await utils.getExtensionPrefix(ext_name);
|
||||||
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
|
||||||
let command = '';
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// Match :extension
|
// Match :extension
|
||||||
case /^:/.test(ext_name):
|
case /^:/.test(ext_name):
|
||||||
@ -288,32 +270,20 @@ export async function addExtensionLinux(
|
|||||||
// match 8.0xdebug3...8.9xdebug3
|
// match 8.0xdebug3...8.9xdebug3
|
||||||
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||||
extension = 'xdebug';
|
extension = 'xdebug';
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
// match pdo extensions
|
// match pdo extensions
|
||||||
case /.*pdo[_-].*/.test(version_extension):
|
case /.*pdo[_-].*/.test(version_extension):
|
||||||
extension = extension.replace(/pdo[_-]|3/, '');
|
extension = extension.replace(/pdo[_-]|3/, '');
|
||||||
add_script += '\nadd_pdo_extension ' + extension;
|
add_script += '\nadd_pdo_extension ' + extension;
|
||||||
return;
|
return;
|
||||||
// match uopz
|
|
||||||
case /^(uopz)$/.test(extension):
|
|
||||||
command = command_prefix + '-' + extension + pipe;
|
|
||||||
break;
|
|
||||||
// match sqlite
|
// match sqlite
|
||||||
case /^sqlite$/.test(extension):
|
case /^sqlite$/.test(extension):
|
||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
command = command_prefix + version + '-' + extension + pipe;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_script += await utils.joins(
|
add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
|
||||||
'\nadd_extension',
|
|
||||||
extension,
|
|
||||||
'"' + command + '"',
|
|
||||||
ext_prefix
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
@ -332,15 +302,15 @@ export async function addExtension(
|
|||||||
os_version: string,
|
os_version: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const pipe: string = await utils.suppressOutput(os_version);
|
const log: string = await utils.stepLog('Setup Extensions', os_version);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe;
|
script += log + (await utils.suppressOutput(os_version));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += await utils.stepLog('Setup Extensions', os_version);
|
script += log;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,9 +318,9 @@ export async function addExtension(
|
|||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
return script + (await addExtensionDarwin(extension_csv, version));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addExtensionLinux(extension_csv, version, pipe));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
@ -21,6 +21,7 @@ export async function getScript(
|
|||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'https://setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
// taking inputs
|
// taking inputs
|
||||||
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
const extension_csv: string = await utils.getInput('extensions', false);
|
const extension_csv: string = await utils.getInput('extensions', false);
|
||||||
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver: string = await utils.getInput('coverage', false);
|
const coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
@ -60,10 +61,7 @@ export async function run(): Promise<void> {
|
|||||||
const tool = await utils.scriptTool(os_version);
|
const tool = await utils.scriptTool(os_version);
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
const script = os_version + (await utils.scriptExtension(os_version));
|
||||||
const location = await getScript(script, version, os_version);
|
const location = await getScript(script, version, os_version);
|
||||||
const fail_fast = await utils.readEnv('fail-fast');
|
await exec(await utils.joins(tool, location, version, __dirname));
|
||||||
await exec(
|
|
||||||
await utils.joins(tool, location, version, __dirname, fail_fast)
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,9 @@
|
|||||||
# Function to log start of a operation.
|
|
||||||
step_log() {
|
|
||||||
message=$1
|
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to log result of a operation.
|
|
||||||
add_log() {
|
|
||||||
mark=$1
|
|
||||||
subject=$2
|
|
||||||
message=$3
|
|
||||||
if [ "$mark" = "$tick" ]; then
|
|
||||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
else
|
|
||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
[ "$fail_fast" = "true" ] && exit 1;
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to log result of installing extension.
|
|
||||||
add_extension_log() {
|
|
||||||
extension=$1
|
|
||||||
status=$2
|
|
||||||
extension_name=$(echo "$extension" | cut -d '-' -f 1)
|
|
||||||
(
|
|
||||||
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
|
|
||||||
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP $semver"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to read env inputs.
|
|
||||||
read_env() {
|
|
||||||
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
|
||||||
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
|
|
||||||
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
|
|
||||||
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup environment for self-hosted runners.
|
# Function to setup environment for self-hosted runners.
|
||||||
self_hosted_setup() {
|
self_hosted_helper() {
|
||||||
if [[ $(command -v brew) == "" ]]; then
|
if ! command -v brew >/dev/null; then
|
||||||
step_log "Setup Brew"
|
step_log "Setup Brew"
|
||||||
curl "${curl_opts[@]}" https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1
|
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1
|
||||||
add_log "$tick" "Brew" "Installed Homebrew"
|
add_log "${tick:?}" "Brew" "Installed Homebrew"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,59 +11,27 @@ self_hosted_setup() {
|
|||||||
remove_extension() {
|
remove_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
sudo sed -i '' "/$extension/d" "$ini_file"
|
sudo sed -i '' "/$extension/d" "${ini_file:?}"
|
||||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
|
||||||
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
|
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
|
||||||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
|
|
||||||
else
|
else
|
||||||
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
|
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to test if extension is loaded.
|
|
||||||
check_extension() {
|
|
||||||
extension=$1
|
|
||||||
if [ "$extension" != "mysql" ]; then
|
|
||||||
php -m | grep -i -q -w "$extension"
|
|
||||||
else
|
|
||||||
php -m | grep -i -q "$extension"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get the PECL version.
|
|
||||||
get_pecl_version() {
|
|
||||||
extension=$1
|
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
|
||||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
|
|
||||||
if [ ! "$pecl_version" ]; then
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
|
||||||
fi
|
|
||||||
echo "$pecl_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install PECL extensions and accept default options
|
|
||||||
pecl_install() {
|
|
||||||
local extension=$1
|
|
||||||
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install a specific version of PECL extension.
|
# Function to install a specific version of PECL extension.
|
||||||
add_pecl_extension() {
|
add_pecl_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
pecl_version=$2
|
pecl_version=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
|
enable_extension "$extension" "$prefix"
|
||||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||||
fi
|
fi
|
||||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
||||||
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
|
||||||
fi
|
|
||||||
ext_version=$(php -r "echo phpversion('$extension');")
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
if [ "$ext_version" = "$pecl_version" ]; then
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
else
|
else
|
||||||
remove_extension "$extension" >/dev/null 2>&1
|
remove_extension "$extension" >/dev/null 2>&1
|
||||||
pecl_install "$extension-$pecl_version"
|
pecl_install "$extension-$pecl_version"
|
||||||
@ -111,169 +42,65 @@ add_pecl_extension() {
|
|||||||
# Function to install a php extension from shivammathur/extensions tap.
|
# Function to install a php extension from shivammathur/extensions tap.
|
||||||
add_brew_extension() {
|
add_brew_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if ! brew tap | grep shivammathur/extensions; then
|
prefix=$2
|
||||||
brew tap --shallow shivammathur/extensions
|
enable_extension "$extension" "$prefix"
|
||||||
|
if check_extension "$extension"; then
|
||||||
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
if ! brew tap | grep -q shivammathur/extensions; then
|
||||||
|
brew tap --shallow shivammathur/extensions >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
brew install "$extension@$version"
|
brew install "$extension@$version" >/dev/null 2>&1
|
||||||
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
|
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
|
||||||
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
prefix=$2
|
||||||
prefix=$3
|
enable_extension "$extension" "$prefix"
|
||||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if check_extension "$extension"; then
|
||||||
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
elif check_extension "$extension"; then
|
else
|
||||||
add_log "$tick" "$extension" "Enabled"
|
[[ "$version" =~ 5.[4-5] ]] && [ "$extension" = "imagick" ] && brew install pkg-config imagemagick >/dev/null 2>&1
|
||||||
elif ! check_extension "$extension"; then
|
pecl_install "$extension" >/dev/null 2>&1 &&
|
||||||
eval "$install_command" >/dev/null 2>&1 &&
|
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
||||||
if [[ "$version" =~ $old_versions ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup pre-release extensions using PECL.
|
|
||||||
add_unstable_extension() {
|
|
||||||
extension=$1
|
|
||||||
stability=$2
|
|
||||||
prefix=$3
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure composer
|
|
||||||
configure_composer() {
|
|
||||||
tool_path=$1
|
|
||||||
sudo ln -sf "$tool_path" "$tool_path.phar"
|
|
||||||
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
add_log "$cross" "composer" "Could not download composer"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
composer -q global config process-timeout 0
|
|
||||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
|
||||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
|
||||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to extract tool version.
|
|
||||||
get_tool_version() {
|
|
||||||
tool=$1
|
|
||||||
param=$2
|
|
||||||
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
if [ "$param" != "snapshot" ]; then
|
|
||||||
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
|
|
||||||
else
|
|
||||||
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
|
|
||||||
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
|
|
||||||
echo "$trunk+$commit"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
|
||||||
add_tool() {
|
|
||||||
url=$1
|
|
||||||
tool=$2
|
|
||||||
ver_param=$3
|
|
||||||
tool_path="$tool_path_dir/$tool"
|
|
||||||
if [ ! -e "$tool_path" ]; then
|
|
||||||
rm -rf "$tool_path"
|
|
||||||
fi
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
IFS="," read -r -a urls <<< "$url"
|
|
||||||
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
|
||||||
else
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
||||||
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
|
||||||
url=$(echo $url | sed -e "s|releases/latest/download|releases/download/$(curl "${curl_opts[@]}" "$(echo "$url" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "$url" | sed -e "s/.*\///")" | cut -d '/' -f 1)|")
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$status_code" = "200" ]; then
|
|
||||||
sudo chmod a+x "$tool_path"
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
configure_composer "$tool_path"
|
|
||||||
elif [ "$tool" = "phan" ]; then
|
|
||||||
add_extension fileinfo "pecl_install fileinfo" extension >/dev/null 2>&1
|
|
||||||
add_extension ast "pecl_install ast" extension >/dev/null 2>&1
|
|
||||||
elif [ "$tool" = "phive" ]; then
|
|
||||||
add_extension curl "pecl_install curl" extension >/dev/null 2>&1
|
|
||||||
add_extension mbstring "pecl_install mbstring" extension >/dev/null 2>&1
|
|
||||||
add_extension xml "pecl_install xml" extension >/dev/null 2>&1
|
|
||||||
elif [ "$tool" = "cs2pr" ]; then
|
|
||||||
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
|
||||||
tr -d '\r' <"$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
|
||||||
sudo chmod a+x "$tool_path"
|
|
||||||
elif [ "$tool" = "wp-cli" ]; then
|
|
||||||
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
|
||||||
fi
|
|
||||||
tool_version=$(get_tool_version "$tool" "$ver_param")
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
else
|
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to add a tool using composer.
|
|
||||||
add_composertool() {
|
|
||||||
tool=$1
|
|
||||||
release=$2
|
|
||||||
prefix=$3
|
|
||||||
(
|
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
|
||||||
json=$(grep "$prefix$tool" /Users/"$USER"/.composer/composer.json) &&
|
|
||||||
tool_version=$(get_tool_version 'echo' "$json") &&
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
if [ -e "$composer_bin/composer" ]; then
|
|
||||||
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to handle request to add phpize and php-config.
|
# Function to handle request to add phpize and php-config.
|
||||||
add_devtools() {
|
add_devtools() {
|
||||||
tool=$1
|
tool=$1
|
||||||
add_log "$tick" "$tool" "Added $tool $semver"
|
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure PECL
|
|
||||||
configure_pecl() {
|
|
||||||
for tool in pear pecl; do
|
|
||||||
sudo "$tool" config-set php_ini "$ini_file"
|
|
||||||
sudo "$tool" channel-update "$tool".php.net
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle request to add PECL.
|
# Function to handle request to add PECL.
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
pecl_version=$(get_tool_version "pecl" "version")
|
pecl_version=$(get_tool_version "pecl" "version")
|
||||||
add_log "$tick" "PECL" "Found PECL $pecl_version"
|
add_log "${tick:?}" "PECL" "Found PECL $pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update dependencies.
|
# Function to update dependencies.
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
if [[ "$version" =~ $nightly_versions ]] && [ "$runner" != "self-hosted" ]; then
|
if [[ "$version" =~ ${nightly_versions:?} ]] && [ "${runner:?}" != "self-hosted" ]; then
|
||||||
|
tap_dir="$(brew --prefix)/Homebrew/Library/Taps"
|
||||||
while read -r formula; do
|
while read -r formula; do
|
||||||
curl -o "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
|
curl -o "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]:?}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
|
||||||
to_wait+=( $! )
|
to_wait+=($!)
|
||||||
done < "$(brew --prefix)/Homebrew/Library/Taps/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
||||||
wait "${to_wait[@]}"
|
wait "${to_wait[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PHP 5.6 and newer.
|
# Function to setup PHP 5.6 and newer using Homebrew.
|
||||||
setup_php() {
|
add_php() {
|
||||||
action=$1
|
action=$1
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
if ! brew tap | grep -q shivammathur/php; then
|
||||||
brew tap --shallow shivammathur/homebrew-php
|
brew tap --shallow shivammathur/php
|
||||||
|
fi
|
||||||
update_dependencies
|
update_dependencies
|
||||||
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
|
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
|
||||||
brew unlink php@"$version"
|
brew unlink php@"$version"
|
||||||
@ -283,51 +110,42 @@ setup_php() {
|
|||||||
brew link --force --overwrite php@"$version"
|
brew link --force --overwrite php@"$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to Setup PHP
|
||||||
|
setup_php() {
|
||||||
|
step_log "Setup PHP"
|
||||||
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
|
if [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
|
curl "${curl_opts[@]:?}" "${github:?}/php5-darwin/releases/latest/download/install.sh" | bash -s "${version/./}" >/dev/null 2>&1
|
||||||
|
status="Installed"
|
||||||
|
elif [ "$existing_version" != "$version" ]; then
|
||||||
|
add_php "install" >/dev/null 2>&1
|
||||||
|
status="Installed"
|
||||||
|
elif [ "$existing_version" = "$version" ] && [ "${update:?}" = "true" ]; then
|
||||||
|
add_php "upgrade" >/dev/null 2>&1
|
||||||
|
status="Updated to"
|
||||||
|
else
|
||||||
|
status="Found"
|
||||||
|
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 -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
|
||||||
|
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
|
||||||
|
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
tick="✓"
|
|
||||||
cross="✗"
|
|
||||||
version=$1
|
version=$1
|
||||||
dist=$2
|
dist=$2
|
||||||
fail_fast=$3
|
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||||
nodot_version=${1/./}
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||||
nightly_versions="8.[0-1]"
|
|
||||||
old_versions="5.[3-5]"
|
|
||||||
composer_bin="/Users/$USER/.composer/vendor/bin"
|
|
||||||
tool_path_dir="/usr/local/bin"
|
|
||||||
curl_opts=(-sL)
|
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
|
||||||
|
|
||||||
|
# shellcheck source=.
|
||||||
|
. "${dist}"/../src/scripts/common.sh
|
||||||
read_env
|
read_env
|
||||||
if [ "$runner" = "self-hosted" ]; then
|
self_hosted_setup
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
setup_php
|
||||||
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
self_hosted_setup >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setup PHP
|
|
||||||
step_log "Setup PHP"
|
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
|
||||||
curl "${curl_opts[@]}" 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" >/dev/null 2>&1
|
|
||||||
status="Installed"
|
|
||||||
elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then
|
|
||||||
setup_php "upgrade" >/dev/null 2>&1
|
|
||||||
status="Updated to"
|
|
||||||
else
|
|
||||||
status="Found"
|
|
||||||
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 -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
|
|
||||||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|
||||||
sudo mkdir -m 777 -p "$ext_dir" "/Users/$USER/.composer"
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
||||||
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
|
|
||||||
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
|
||||||
|
@ -83,16 +83,9 @@ patch_pdo_oci_config() {
|
|||||||
add_dependencies() {
|
add_dependencies() {
|
||||||
if [ "$os" = 'Linux' ]; then
|
if [ "$os" = 'Linux' ]; then
|
||||||
if [ "${runner:?}" = "self-hosted" ]; then
|
if [ "${runner:?}" = "self-hosted" ]; then
|
||||||
if ! [[ ${version:?} =~ $nightly_versions ]]; then
|
|
||||||
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++ php"$version"-dev
|
|
||||||
else
|
|
||||||
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++
|
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++
|
||||||
fi
|
fi
|
||||||
else
|
! [[ ${version:?} =~ $nightly_versions ]] && add_devtools phpize
|
||||||
! [[ ${version:?} =~ $nightly_versions ]] && update_lists && ${apt_install:?} --no-upgrade --no-install-recommends php"$version"-dev
|
|
||||||
fi
|
|
||||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version"
|
|
||||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,39 +1,10 @@
|
|||||||
# Function to log start of a operation.
|
# Function to setup environment for self-hosted runners.
|
||||||
step_log() {
|
self_hosted_helper() {
|
||||||
message=$1
|
if ! command -v apt-fast >/dev/null; then
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||||
}
|
|
||||||
|
|
||||||
# Function to log result of a operation.
|
|
||||||
add_log() {
|
|
||||||
mark=$1
|
|
||||||
subject=$2
|
|
||||||
message=$3
|
|
||||||
if [ "$mark" = "$tick" ]; then
|
|
||||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
else
|
|
||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
[ "$fail_fast" = "true" ] && exit 1;
|
|
||||||
fi
|
fi
|
||||||
}
|
install_packages curl make software-properties-common unzip
|
||||||
|
add_ppa
|
||||||
# Function to log result of installing extension.
|
|
||||||
add_extension_log() {
|
|
||||||
extension=$1
|
|
||||||
status=$2
|
|
||||||
extension_name=$(echo "$extension" | cut -d '-' -f 1)
|
|
||||||
(
|
|
||||||
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
|
|
||||||
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP $semver"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to read env inputs.
|
|
||||||
read_env() {
|
|
||||||
. /etc/lsb-release
|
|
||||||
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
|
||||||
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
|
|
||||||
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
|
|
||||||
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to backup and cleanup package lists.
|
# Function to backup and cleanup package lists.
|
||||||
@ -64,70 +35,24 @@ update_lists() {
|
|||||||
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
|
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
|
||||||
cleanup_lists
|
cleanup_lists
|
||||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||||
echo '' | sudo tee "/tmp/setup_php" >/dev/null 2>&1
|
echo '' | sudo tee /tmp/setup_php >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup environment for self-hosted runners.
|
# Function to install a package
|
||||||
self_hosted_setup() {
|
install_packages() {
|
||||||
if ! command -v apt-fast >/dev/null; then
|
packages=("$@")
|
||||||
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
$apt_install "${packages[@]}" >/dev/null 2>&1 || update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1
|
||||||
fi
|
|
||||||
update_lists && $apt_install curl make software-properties-common unzip
|
|
||||||
add_ppa
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure PECL.
|
|
||||||
configure_pecl() {
|
|
||||||
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
|
||||||
|
|
||||||
for tool in pear pecl; do
|
|
||||||
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini
|
|
||||||
sudo "$tool" channel-update "$tool".php.net
|
|
||||||
done
|
|
||||||
pecl_config="true"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get the PECL version of an extension.
|
|
||||||
get_pecl_version() {
|
|
||||||
extension=$1
|
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
|
||||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\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 install PECL extensions and accept default options
|
|
||||||
pecl_install() {
|
|
||||||
local extension=$1
|
|
||||||
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to check if an extension is loaded.
|
|
||||||
check_extension() {
|
|
||||||
extension=$1
|
|
||||||
if [ "$extension" != "mysql" ]; then
|
|
||||||
php -m | grep -i -q -w "$extension"
|
|
||||||
else
|
|
||||||
php -m | grep -i -q "$extension"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to delete extensions.
|
# Function to delete extensions.
|
||||||
delete_extension() {
|
delete_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
sudo sed -i "/$extension/d" "$ini_file"
|
sudo sed -i "/$extension/d" "${ini_file:?}"
|
||||||
sudo sed -i "/$extension/d" "$pecl_file"
|
sudo sed -i "/$extension/d" "${pecl_file:?}"
|
||||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
if [ "${runner:?}" = "self-hosted" ]; then
|
||||||
if [ "$runner" = "self-hosted" ]; then
|
$apt_remove "php-$extension" "php$version-$extension" >/dev/null 2>&1 || true
|
||||||
$apt_remove "php-$extension" >/dev/null 2>&1 || true
|
|
||||||
$apt_remove "php$version-$extension" >/dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,21 +60,14 @@ delete_extension() {
|
|||||||
remove_extension() {
|
remove_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
if [[ ! "$version" =~ $old_versions ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
if [[ ! "$version" =~ ${old_versions:?} ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||||
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
|
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
|
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
|
||||||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
|
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
|
||||||
else
|
else
|
||||||
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
|
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable existing extensions.
|
|
||||||
enable_extension() {
|
|
||||||
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
|
|
||||||
echo "$2=$1.so" >>"$pecl_file"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,19 +75,19 @@ enable_extension() {
|
|||||||
add_pdo_extension() {
|
add_pdo_extension() {
|
||||||
pdo_ext="pdo_$1"
|
pdo_ext="pdo_$1"
|
||||||
if check_extension "$pdo_ext"; then
|
if check_extension "$pdo_ext"; then
|
||||||
add_log "$tick" "$pdo_ext" "Enabled"
|
add_log "${tick:?}" "$pdo_ext" "Enabled"
|
||||||
else
|
else
|
||||||
read -r ext ext_name <<< "$1 $1"
|
ext=$1; ext_name=$1;
|
||||||
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1
|
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1
|
||||||
if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" >> "$ini_file"; fi
|
if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" >>"$ini_file"; fi
|
||||||
if [ "$ext" = "mysql" ]; then
|
if [ "$ext" = "mysql" ]; then
|
||||||
enable_extension "mysqlnd" "extension"
|
enable_extension "mysqlnd" "extension"
|
||||||
ext_name="mysqli"
|
ext_name="mysqli"
|
||||||
elif [ "$ext" = "sqlite" ]; then
|
elif [ "$ext" = "sqlite" ]; then
|
||||||
read -r ext ext_name <<< "sqlite3 sqlite3"
|
ext="sqlite3"; ext_name="sqlite3";
|
||||||
fi
|
fi
|
||||||
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1
|
add_extension "$ext_name" "extension" >/dev/null 2>&1
|
||||||
add_extension "$pdo_ext" "pecl_install $pdo_ext" "extension" >/dev/null 2>&1
|
add_extension "$pdo_ext" "extension" >/dev/null 2>&1
|
||||||
add_extension_log "$pdo_ext" "Enabled"
|
add_extension_log "$pdo_ext" "Enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -177,20 +95,17 @@ add_pdo_extension() {
|
|||||||
# Function to add extensions.
|
# Function to add extensions.
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
prefix=$2
|
||||||
prefix=$3
|
|
||||||
enable_extension "$extension" "$prefix"
|
enable_extension "$extension" "$prefix"
|
||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
else
|
else
|
||||||
if [[ "$version" =~ 5.[4-5] ]]; then
|
if [[ "$version" =~ 5.[4-5] ]]; then
|
||||||
install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
install_packages "php5-$extension=$release_version"
|
||||||
fi
|
elif [[ "$version" =~ ${nightly_versions:?} ]]; then
|
||||||
if [[ "$version" =~ $nightly_versions ]]; then
|
|
||||||
pecl_install "$extension"
|
pecl_install "$extension"
|
||||||
else
|
else
|
||||||
eval "$install_command" >/dev/null 2>&1 ||
|
install_packages "php$version-$extension" || pecl_install "$extension"
|
||||||
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension"
|
|
||||||
fi
|
fi
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
fi
|
||||||
@ -205,12 +120,10 @@ add_pecl_extension() {
|
|||||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||||
fi
|
fi
|
||||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
enable_extension "$extension" "$prefix"
|
||||||
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
|
|
||||||
fi
|
|
||||||
ext_version=$(php -r "echo phpversion('$extension');")
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
if [ "$ext_version" = "$pecl_version" ]; then
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
else
|
else
|
||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
pecl_install "$extension-$pecl_version"
|
pecl_install "$extension-$pecl_version"
|
||||||
@ -218,15 +131,6 @@ add_pecl_extension() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to pre-release extensions using PECL.
|
|
||||||
add_unstable_extension() {
|
|
||||||
extension=$1
|
|
||||||
stability=$2
|
|
||||||
prefix=$3
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install extension from source
|
# Function to install extension from source
|
||||||
add_extension_from_source() {
|
add_extension_from_source() {
|
||||||
extension=$1
|
extension=$1
|
||||||
@ -237,128 +141,37 @@ add_extension_from_source() {
|
|||||||
(
|
(
|
||||||
add_devtools phpize
|
add_devtools phpize
|
||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz
|
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]:?}" https://github.com/"$repo"/archive/"$release".tar.gz
|
||||||
tar xf /tmp/"$extension".tar.gz -C /tmp
|
tar xf /tmp/"$extension".tar.gz -C /tmp
|
||||||
cd /tmp/"$extension-$release" || exit 1
|
cd /tmp/"$extension-$release" || exit 1
|
||||||
phpize && ./configure "$args" && make && sudo make install
|
phpize && ./configure "$args" && make -j"$(nproc)" && sudo make install
|
||||||
enable_extension "$extension" "$prefix"
|
enable_extension "$extension" "$prefix"
|
||||||
) >/dev/null 2>&1
|
) >/dev/null 2>&1
|
||||||
add_extension_log "$extension-$release" "Installed and enabled"
|
add_extension_log "$extension-$release" "Installed and enabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to configure composer
|
|
||||||
configure_composer() {
|
|
||||||
tool_path=$1
|
|
||||||
sudo ln -sf "$tool_path" "$tool_path.phar"
|
|
||||||
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
add_log "$cross" "composer" "Could not download composer"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
composer -q global config process-timeout 0
|
|
||||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
|
||||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
|
||||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to extract tool version.
|
|
||||||
get_tool_version() {
|
|
||||||
tool=$1
|
|
||||||
param=$2
|
|
||||||
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
if [ "$param" != "snapshot" ]; then
|
|
||||||
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
|
|
||||||
else
|
|
||||||
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
|
|
||||||
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
|
|
||||||
echo "$trunk+$commit"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
|
||||||
add_tool() {
|
|
||||||
url=$1
|
|
||||||
tool=$2
|
|
||||||
ver_param=$3
|
|
||||||
tool_path="$tool_path_dir/$tool"
|
|
||||||
if [ ! -e "$tool_path" ]; then
|
|
||||||
rm -rf "$tool_path"
|
|
||||||
fi
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
IFS="," read -r -a urls <<< "$url"
|
|
||||||
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
|
||||||
else
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
||||||
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
|
||||||
url=$(echo $url | sed -e "s|releases/latest/download|releases/download/$(curl "${curl_opts[@]}" "$(echo "$url" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "$url" | sed -e "s/.*\///")" | cut -d '/' -f 1)|")
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$status_code" = "200" ]; then
|
|
||||||
sudo chmod a+x "$tool_path"
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
configure_composer "$tool_path"
|
|
||||||
elif [ "$tool" = "cs2pr" ]; then
|
|
||||||
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
|
||||||
elif [ "$tool" = "phan" ]; then
|
|
||||||
add_extension fileinfo "$apt_install php$version-fileinfo" extension >/dev/null 2>&1
|
|
||||||
add_extension ast "$apt_install php-ast" extension >/dev/null 2>&1
|
|
||||||
elif [ "$tool" = "phive" ]; then
|
|
||||||
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
|
||||||
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
|
||||||
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
|
||||||
elif [ "$tool" = "wp-cli" ]; then
|
|
||||||
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
|
||||||
fi
|
|
||||||
tool_version=$(get_tool_version "$tool" "$ver_param")
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
else
|
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup a tool using composer.
|
|
||||||
add_composertool() {
|
|
||||||
tool=$1
|
|
||||||
release=$2
|
|
||||||
prefix=$3
|
|
||||||
(
|
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
|
||||||
json=$(grep "$prefix$tool" /home/"$USER"/.composer/composer.json) &&
|
|
||||||
tool_version=$(get_tool_version 'echo' "$json") &&
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
if [ -e "$composer_bin/composer" ]; then
|
|
||||||
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup phpize and php-config.
|
# Function to setup phpize and php-config.
|
||||||
add_devtools() {
|
add_devtools() {
|
||||||
tool=$1
|
tool=$1
|
||||||
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
if ! command -v "$tool$version" >/dev/null; then
|
||||||
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
install_packages "php$version-dev" "php$version-xml"
|
||||||
fi
|
fi
|
||||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||||
|
if command -v pecl >/dev/null; then
|
||||||
configure_pecl >/dev/null 2>&1
|
configure_pecl >/dev/null 2>&1
|
||||||
add_log "$tick" "$tool" "Added $tool $semver"
|
fi
|
||||||
|
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup the nightly build from shivammathur/php-builder
|
# Function to setup the nightly build from shivammathur/php-builder
|
||||||
setup_nightly() {
|
setup_nightly() {
|
||||||
curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner" "$version"
|
curl "${curl_opts[@]:?}" "${github:?}"/php-builder/releases/latest/download/install.sh | bash -s "$runner" "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
||||||
setup_old_versions() {
|
setup_old_versions() {
|
||||||
curl "${curl_opts[@]}" "$github"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
curl "${curl_opts[@]:?}" "${github:?}"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||||
configure_pecl
|
configure_pecl
|
||||||
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
|
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
|
||||||
}
|
}
|
||||||
@ -366,48 +179,40 @@ setup_old_versions() {
|
|||||||
# Function to add PECL.
|
# Function to add PECL.
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
add_devtools phpize >/dev/null 2>&1
|
add_devtools phpize >/dev/null 2>&1
|
||||||
if [ ! -e /usr/bin/pecl ]; then
|
if ! command -v pecl >/dev/null; then
|
||||||
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1
|
install_packages php-pear
|
||||||
fi
|
fi
|
||||||
configure_pecl >/dev/null 2>&1
|
configure_pecl >/dev/null 2>&1
|
||||||
pecl_version=$(get_tool_version "pecl" "version")
|
pecl_version=$(get_tool_version "pecl" "version")
|
||||||
add_log "$tick" "PECL" "Added PECL $pecl_version"
|
add_log "${tick:?}" "PECL" "Added PECL $pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to switch versions of PHP binaries.
|
# Function to switch versions of PHP binaries.
|
||||||
switch_version() {
|
switch_version() {
|
||||||
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
||||||
if [ -e "/usr/bin/$tool$version" ]; then
|
if [ -e "/usr/bin/$tool$version" ]; then
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$version"
|
sudo update-alternatives --set $tool /usr/bin/"$tool$version" &
|
||||||
|
to_wait+=( $! )
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
wait "${to_wait[@]}"
|
||||||
|
|
||||||
# Function to get PHP version in semver format.
|
|
||||||
php_semver() {
|
|
||||||
if ! [[ "$version" =~ $nightly_versions ]]; then
|
|
||||||
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
|
|
||||||
else
|
|
||||||
php -v | head -n 1 | cut -f 2 -d ' '
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install packaged PHP
|
# Function to install packaged PHP
|
||||||
add_packaged_php() {
|
add_packaged_php() {
|
||||||
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
||||||
update_lists
|
update_lists
|
||||||
IFS=' ' read -r -a packages <<< "$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
|
IFS=' ' read -r -a packages <<<"$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
|
||||||
$apt_install "${packages[@]}"
|
$apt_install "${packages[@]}"
|
||||||
else
|
else
|
||||||
curl "${curl_opts[@]}" "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
curl "${curl_opts[@]:?}" "${github:?}"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update PHP.
|
# Function to update PHP.
|
||||||
update_php() {
|
update_php() {
|
||||||
initial_version=$(php_semver)
|
initial_version=$(php_semver)
|
||||||
use_package_cache="false"
|
use_package_cache="false" add_packaged_php
|
||||||
add_packaged_php
|
|
||||||
updated_version=$(php_semver)
|
updated_version=$(php_semver)
|
||||||
if [ "$updated_version" != "$initial_version" ]; then
|
if [ "$updated_version" != "$initial_version" ]; then
|
||||||
status="Updated to"
|
status="Updated to"
|
||||||
@ -418,9 +223,9 @@ update_php() {
|
|||||||
|
|
||||||
# Function to install PHP.
|
# Function to install PHP.
|
||||||
add_php() {
|
add_php() {
|
||||||
if [[ "$version" =~ $nightly_versions ]]; then
|
if [[ "$version" =~ ${nightly_versions:?} ]]; then
|
||||||
setup_nightly
|
setup_nightly
|
||||||
elif [[ "$version" =~ $old_versions ]]; then
|
elif [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
setup_old_versions
|
setup_old_versions
|
||||||
else
|
else
|
||||||
add_packaged_php
|
add_packaged_php
|
||||||
@ -428,68 +233,52 @@ add_php() {
|
|||||||
status="Installed"
|
status="Installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variables
|
# Function to Setup PHP
|
||||||
tick="✓"
|
setup_php() {
|
||||||
cross="✗"
|
step_log "Setup PHP"
|
||||||
pecl_config="false"
|
sudo mkdir -m 777 -p /var/run /run/php
|
||||||
version=$1
|
if [ "$(php-config --version 2>/dev/null | cut -c 1-3)" != "$version" ]; then
|
||||||
dist=$2
|
|
||||||
fail_fast=$3
|
|
||||||
nightly_versions="8.[0-1]"
|
|
||||||
old_versions="5.[3-5]"
|
|
||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
|
||||||
github="https://github.com/shivammathur"
|
|
||||||
apt_install="sudo $debconf_fix apt-get install -y"
|
|
||||||
apt_remove="sudo $debconf_fix apt-get remove -y"
|
|
||||||
composer_bin="/home/$USER/.composer/vendor/bin"
|
|
||||||
tool_path_dir="/usr/local/bin"
|
|
||||||
curl_opts=(-sL)
|
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
|
||||||
|
|
||||||
read_env
|
|
||||||
if [ "$runner" = "self-hosted" ]; then
|
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
|
||||||
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
self_hosted_setup >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setup PHP
|
|
||||||
step_log "Setup PHP"
|
|
||||||
sudo mkdir -m 777 -p /home/"$USER"/.composer /var/run /run/php
|
|
||||||
if [ "$existing_version" != "$version" ]; then
|
|
||||||
if [ ! -e "/usr/bin/php$version" ]; then
|
if [ ! -e "/usr/bin/php$version" ]; then
|
||||||
add_php >/dev/null 2>&1
|
add_php >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
if [ "$update" = "true" ]; then
|
if [ "${update:?}" = "true" ]; then
|
||||||
update_php >/dev/null 2>&1
|
update_php >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
status="Switched to"
|
status="Switched to"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ! [[ "$version" =~ $old_versions ]]; then
|
if ! [[ "$version" =~ ${old_versions:?}|${nightly_versions:?} ]]; then
|
||||||
switch_version >/dev/null 2>&1
|
switch_version >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$update" = "true" ]; then
|
if [ "$update" = "true" ]; then
|
||||||
update_php >/dev/null 2>&1
|
update_php >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
status="Found"
|
status="Found"
|
||||||
if [[ "$version" =~ $nightly_versions ]]; then
|
|
||||||
switch_version >/dev/null 2>&1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
semver=$(php_semver)
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
pecl_file="$scan_dir"/99-pecl.ini
|
||||||
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||||
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||||
|
sudo chmod 777 "$ini_file" "$pecl_file" "${tool_path_dir:?}"
|
||||||
|
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
|
add_log "${tick:?}" "PHP" "$status PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
semver=$(php_semver)
|
# Variables
|
||||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
version=$1
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
dist=$2
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
pecl_file="$scan_dir"/99-pecl.ini
|
apt_install="sudo $debconf_fix apt-get install -y"
|
||||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
apt_remove="sudo $debconf_fix apt-get remove -y"
|
||||||
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
|
||||||
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
# shellcheck source=.
|
||||||
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
. "${dist}"/../src/scripts/common.sh
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
. /etc/lsb-release
|
||||||
|
read_env
|
||||||
|
self_hosted_setup
|
||||||
|
setup_php
|
||||||
|
@ -97,7 +97,7 @@ Function Get-CleanPSProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function to install a powershell package from GitHub.
|
# Function to install a powershell package from GitHub.
|
||||||
Function Install-GitHubPackage() {
|
Function Install-PSPackage() {
|
||||||
param(
|
param(
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
$package,
|
$package,
|
||||||
@ -334,12 +334,15 @@ $cross = ([char]10007)
|
|||||||
$php_dir = 'C:\tools\php'
|
$php_dir = 'C:\tools\php'
|
||||||
$ext_dir = "$php_dir\ext"
|
$ext_dir = "$php_dir\ext"
|
||||||
$bin_dir = $php_dir
|
$bin_dir = $php_dir
|
||||||
|
$bintray = 'https://dl.bintray.com/shivammathur/php'
|
||||||
$github = 'https://github.com'
|
$github = 'https://github.com'
|
||||||
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
||||||
$current_profile = "$env:TEMP\setup-php.ps1"
|
$current_profile = "$env:TEMP\setup-php.ps1"
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$nightly_version = '8.[0-9]'
|
$nightly_version = '8.[0-9]'
|
||||||
$cert_source='CurrentUser'
|
$cert_source='CurrentUser'
|
||||||
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
||||||
|
$wc = New-Object System.Net.WebClient
|
||||||
|
|
||||||
$arch = 'x64'
|
$arch = 'x64'
|
||||||
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
||||||
@ -378,7 +381,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|||||||
|
|
||||||
Add-Printf >$null 2>&1
|
Add-Printf >$null 2>&1
|
||||||
Step-Log "Setup PhpManager"
|
Step-Log "Setup PhpManager"
|
||||||
Install-GitHubPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
|
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
|
||||||
Add-Log $tick "PhpManager" "Installed"
|
Add-Log $tick "PhpManager" "Installed"
|
||||||
|
|
||||||
Step-Log "Setup PHP"
|
Step-Log "Setup PHP"
|
||||||
@ -391,11 +394,11 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|||||||
$status = "Installed"
|
$status = "Installed"
|
||||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
||||||
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
|
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
|
||||||
Install-GitHubPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
|
||||||
}
|
}
|
||||||
if ($version -match $nightly_version) {
|
if ($version -match $nightly_version) {
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpNightly.ps1 -OutFile $php_dir\Install-PhpNightly.ps1 > $null 2>&1
|
$wc.DownloadFile("$bintray/Get-PhpNightly.ps1", "$php_dir\Get-PhpNightly.ps1") > $null 2>&1
|
||||||
& $php_dir\Install-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
||||||
} else {
|
} else {
|
||||||
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
||||||
}
|
}
|
||||||
@ -409,16 +412,13 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
|
|||||||
}
|
}
|
||||||
|
|
||||||
$installed = Get-Php -Path $php_dir
|
$installed = Get-Php -Path $php_dir
|
||||||
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
('date.timezone=UTC', 'memory_limit=-1') | foreach { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
||||||
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
|
|
||||||
if($version -lt "5.5") {
|
if($version -lt "5.5") {
|
||||||
ForEach($lib in "libeay32.dll", "ssleay32.dll") {
|
('libeay32.dll', 'ssleay32.dll') | ForEach { $wc.DownloadFile("$bintray/$_", "$php_dir\$_") >$null 2>&1 }
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/$lib -OutFile $php_dir\$lib >$null 2>&1
|
|
||||||
}
|
|
||||||
Enable-PhpExtension -Extension openssl, curl, mbstring -Path $php_dir
|
|
||||||
} else {
|
} else {
|
||||||
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
$enable_extensions += ('opcache')
|
||||||
}
|
}
|
||||||
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
||||||
Update-PhpCAInfo -Path $php_dir -Source $cert_source
|
Update-PhpCAInfo -Path $php_dir -Source $cert_source
|
||||||
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||||
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
|
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
|
||||||
|
Loading…
Reference in New Issue
Block a user