@@ -384,10 +384,30 @@ private function dumpDownloads(array $config, array &$packages, InputInterface
384
384
$ output ->writeln (sprintf ("<info>Dumping '%s'.</info> " , $ name ));
385
385
386
386
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
+ }
388
408
$ archive = basename ($ path );
389
409
$ distUrl = sprintf ('%s/%s/%s ' , $ endpoint , $ config ['archive ' ]['directory ' ], $ archive );
390
- $ package ->setDistType ($ format );
410
+ $ package ->setDistType ($ archiveFormat );
391
411
$ package ->setDistUrl ($ distUrl );
392
412
$ package ->setDistSha1Checksum (hash_file ('sha1 ' , $ path ));
393
413
$ package ->setDistReference ($ package ->getSourceReference ());
0 commit comments