warning('Current user is not root, using sudo for running command'); } // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. $musl_version_name = 'musl-1.2.4'; $musl_source = [ 'type' => 'url', 'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz", ]; logger()->info('Downloading ' . $musl_source['url']); Downloader::downloadSource($musl_version_name, $musl_source); FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); logger()->info('Installing musl wrapper'); shell()->cd(SOURCE_PATH . "/{$musl_version_name}") ->exec('./configure --disable-gcc-wrapper') ->exec('make -j') ->exec("{$prefix}make install"); // TODO: add path using putenv instead of editing /etc/profile return true; } catch (RuntimeException) { return false; } } /** @noinspection PhpUnused */ /** * @throws FileSystemException * @throws WrongUsageException */ #[AsFixItem('fix-musl-cross-make')] public function fixMuslCrossMake(): bool { try { $prefix = ''; if (get_current_user() !== 'root') { $prefix = 'sudo '; logger()->warning('Current user is not root, using sudo for running command'); } $arch = arch2gnu(php_uname('m')); PackageManager::installPackage("musl-toolchain-{$arch}-linux"); $pkg_root = PKG_ROOT_PATH . "/musl-toolchain-{$arch}-linux"; shell()->exec("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl"); FileSystem::removeDir($pkg_root); return true; } catch (RuntimeException) { return false; } } }