installMuslWrapper(); } if (!file_exists($cross_compile_lib) || !file_exists($cross_compile_gcc)) { $this->installMuslCrossMake(); } // TODO: add path using putenv instead of editing /etc/profile return true; } catch (RuntimeException) { return false; } } /** * @throws DownloaderException * @throws RuntimeException * @throws FileSystemException */ public function installMuslWrapper(): void { $prefix = ''; if (get_current_user() !== 'root') { $prefix = 'sudo '; logger()->warning('Current user is not root, using sudo for running command'); } $musl_version_name = 'musl-1.2.4'; $musl_source = [ 'type' => 'url', 'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz", ]; Downloader::downloadSource($musl_version_name, $musl_source); FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") ->exec('./configure --enable-wrapper=gcc') ->exec('make -j') ->exec("{$prefix}make install"); } /** * @throws DownloaderException * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ public function installMuslCrossMake(): void { $arch = arch2gnu(php_uname('m')); $musl_compile_source = [ 'type' => 'url', 'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz", ]; logger()->info('Downloading ' . $musl_compile_source['url']); Downloader::downloadSource('musl-compile', $musl_compile_source); logger()->info('Extracting musl-cross'); FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); shell(true)->exec('cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); } }