Skip to content

Commit

Permalink
Also look up 7zz on linux/macOS, fixes #9951
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jul 12, 2021
1 parent b602b19 commit be58b36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Composer/Command/DiagnoseCommand.php
Expand Up @@ -177,12 +177,18 @@ protected function execute(InputInterface $input, OutputInterface $output)

$finder = new ExecutableFinder;
$hasSystemUnzip = (bool) $finder->find('unzip');
$hasSystem7zip = (bool) $finder->find('7z', null, array('C:\Program Files\7-Zip'));
$bin7zip = '';
if ($hasSystem7zip = (bool) $finder->find('7z', null, array('C:\Program Files\7-Zip'))) {
$bin7zip = '7z';
}
if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
$bin7zip = '7zz';
}

$io->write(
'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
. ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
. ', ' . ($hasSystem7zip ? '<comment>7-Zip present</comment>' : '<comment>7-Zip not available</comment>')
. ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
);

return $this->exitCode;
Expand Down
3 changes: 3 additions & 0 deletions src/Composer/Downloader/ZipDownloader.php
Expand Up @@ -49,6 +49,9 @@ public function download(PackageInterface $package, $path, PackageInterface $pre
if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) { // 7z linux/macOS support is only used if unzip is not present
self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
}
if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) { // 7zz linux/macOS support is only used if unzip is not present
self::$unzipCommands[] = array('7zz', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
}
}

if (null === self::$hasZipArchive) {
Expand Down

0 comments on commit be58b36

Please sign in to comment.