diff --git a/__tests__/install.test.ts b/__tests__/install.test.ts index c6fa5d0b..fdab7ba1 100644 --- a/__tests__/install.test.ts +++ b/__tests__/install.test.ts @@ -46,7 +46,7 @@ jest.mock('../src/install', () => ({ case 'darwin': case 'linux': script = await install.build(os_version + '.sh', version, os_version); - script += 'sh script.sh ' + version + ' ' + __dirname; + script += 'bash script.sh ' + version + ' ' + __dirname; break; case 'win32': script = await install.build(os_version + '.sh', version, os_version); @@ -119,7 +119,7 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.3 '); + expect(script).toContain('bash script.sh 7.3 '); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true'); // @ts-ignore @@ -128,7 +128,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3'); + expect(script).toContain('bash script.sh 7.3'); expect(script).toContain('add_tool'); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', ''); @@ -138,7 +138,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3'); + expect(script).toContain('bash script.sh 7.3'); expect(script).toContain('add_tool'); }); @@ -147,7 +147,7 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.3 ' + __dirname); + expect(script).toContain('bash script.sh 7.3 ' + __dirname); setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', ''); // @ts-ignore @@ -156,7 +156,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3 ' + __dirname); + expect(script).toContain('bash script.sh 7.3 ' + __dirname); }); it('Test malformed version inputs', async () => { @@ -164,18 +164,18 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.4 ' + __dirname); + expect(script).toContain('bash script.sh 7.4 ' + __dirname); setEnv(8.0, 'darwin', '', '', '', '', ''); // @ts-ignore script = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 8.0 ' + __dirname); + expect(script).toContain('bash script.sh 8.0 ' + __dirname); setEnv(8, 'darwin', '', '', '', '', ''); // @ts-ignore script = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 8.0 ' + __dirname); + expect(script).toContain('bash script.sh 8.0 ' + __dirname); }); }); diff --git a/dist/index.js b/dist/index.js index 3e9b27f6..e869411a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2358,7 +2358,7 @@ async function run() { case 'darwin': case 'linux': script_path = await build(os_version + '.sh', version, os_version); - await exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname); + await exec_1.exec('bash ' + script_path + ' ' + version + ' ' + __dirname); break; case 'win32': script_path = await build('win32.ps1', version, os_version); diff --git a/src/install.ts b/src/install.ts index db021ce0..f3675450 100644 --- a/src/install.ts +++ b/src/install.ts @@ -67,7 +67,7 @@ export async function run(): Promise { case 'darwin': case 'linux': script_path = await build(os_version + '.sh', version, os_version); - await exec('sh ' + script_path + ' ' + version + ' ' + __dirname); + await exec('bash ' + script_path + ' ' + version + ' ' + __dirname); break; case 'win32': script_path = await build('win32.ps1', version, os_version); diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 010b7b23..28489cf3 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -17,8 +17,8 @@ add_log() { } # Function to update php ppa -update_ppa() { - if [ "$ppa_updated" = "false" ]; then +update_lists() { + if [ "$lists_updated" = "false" ]; then sudo "$debconf_fix" apt-get update >/dev/null 2>&1 fi } @@ -87,7 +87,7 @@ add_extension() { add_log "$tick" "$extension" "Enabled" elif ! check_extension "$extension"; then eval "$install_command" >/dev/null 2>&1 || - (update_ppa && eval "$install_command" >/dev/null 2>&1) || + (update_lists && eval "$install_command" >/dev/null 2>&1) || sudo pecl install -f "$extension" >/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" @@ -134,7 +134,7 @@ update_extension() { if [ "$final_version" != "$current_version" ]; then version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version") if [ -z "$version_exists" ]; then - update_ppa + update_lists fi $apt_install php"$version"-"$extension" fi @@ -184,7 +184,7 @@ add_composertool() { # Function to setup phpize and php-config add_devtools() { if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then - update_ppa && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1 + update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1 fi 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 @@ -193,19 +193,7 @@ add_devtools() { # Function to setup the nightly build from master branch setup_master() { - update_ppa && $apt_install libzip-dev libwebp-dev >/dev/null 2>&1 - tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz - install_dir=~/php/"$version" - bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file" - sudo mkdir -m 777 -p ~/php - curl -o /tmp/"$tar_file" -sSL "$bintray_url" - sudo tar xf /tmp/"$tar_file" -C ~/php - for tool_path in "$install_dir"/bin/*; do - tool=$(basename "$tool_path") - sudo cp "$tool_path" /usr/bin/"$tool$version" - sudo update-alternatives --install /usr/bin/"$tool" "$tool" /usr/bin/"$tool$version" 50 >/dev/null 2>&1 - done - sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini + curl -sSL https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github" } # Function to setup PECL @@ -222,7 +210,7 @@ add_pecl() { switch_version() { for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do if [ -e "/usr/bin/$tool$version" ]; then - sudo update-alternatives --set $tool /usr/bin/"$tool$version" >/dev/null 2>&1 + sudo update-alternatives --set $tool /usr/bin/"$tool$version" fi done } @@ -239,7 +227,7 @@ php_semver() { # Variables tick="✓" cross="✗" -ppa_updated="false" +lists_updated="false" pecl_config="false" version=$1 debconf_fix="DEBIAN_FRONTEND=noninteractive" @@ -254,17 +242,18 @@ sudo mkdir -p /var/run /run/php if [ "$existing_version" != "$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then if [ "$version" = "8.0" ]; then - setup_master + setup_master >/dev/null 2>&1 else - update_ppa - $apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1 + update_lists + IFS=' ' read -r -a packages <<< "$(echo "curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")" + $apt_install php"$version" "${packages[@]}" >/dev/null 2>&1 fi status="Installed" else status="Switched to" fi - switch_version + switch_version >/dev/null 2>&1 else status="Found" fi