Skip to content

Commit e795e30

Browse files
author
Alexander Pravdin
committed
Fixed PEAR packages mirroring
1 parent ef2a73a commit e795e30

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/Composer/Satis/Command/BuildCommand.php

+22-2
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,30 @@ private function dumpDownloads(array $config, array &$packages, InputInterface
384384
$output->writeln(sprintf("<info>Dumping '%s'.</info>", $name));
385385

386386
try {
387-
$path = $archiveManager->archive($package, $format, $directory);
387+
if ('pear-library' === $package->getType()) {
388+
// PEAR packages are archives already
389+
$filesystem = new Filesystem();
390+
$packageName = $archiveManager->getPackageFilename($package);
391+
$path =
392+
realpath($directory) . '/' . $packageName . '.' .
393+
pathinfo($package->getDistUrl(), PATHINFO_EXTENSION);
394+
if (!file_exists($path)) {
395+
$downloadDir = sys_get_temp_dir() . '/composer_archiver/' . $packageName;
396+
$filesystem->ensureDirectoryExists($downloadDir);
397+
$downloadManager->download($package, $downloadDir, false);
398+
$filesystem->ensureDirectoryExists($directory);
399+
copy($downloadDir . '/' . pathinfo($package->getDistUrl(), PATHINFO_BASENAME), $path);
400+
$filesystem->removeDirectory($downloadDir);
401+
}
402+
// Set archive format to `file` to tell composer to download it as is
403+
$archiveFormat = 'file';
404+
} else {
405+
$path = $archiveManager->archive($package, $format, $directory);
406+
$archiveFormat = $format;
407+
}
388408
$archive = basename($path);
389409
$distUrl = sprintf('%s/%s/%s', $endpoint, $config['archive']['directory'], $archive);
390-
$package->setDistType($format);
410+
$package->setDistType($archiveFormat);
391411
$package->setDistUrl($distUrl);
392412
$package->setDistSha1Checksum(hash_file('sha1', $path));
393413
$package->setDistReference($package->getSourceReference());

0 commit comments

Comments
 (0)