Browse Source

Make builds more reproducible, refs #3927

Jordi Boggiano 10 years ago
parent
commit
92785ac677
2 changed files with 13 additions and 1 deletions
  1. 6 1
      bin/compile
  2. 7 0
      src/Composer/Compiler.php

+ 6 - 1
bin/compile

@@ -1,6 +1,11 @@
 #!/usr/bin/env php
 <?php
 
+$cwd = getcwd();
+chdir(__DIR__.'/../');
+shell_exec('php bin/composer install -q');
+chdir($cwd);
+
 require __DIR__.'/../src/bootstrap.php';
 
 use Composer\Compiler;
@@ -12,6 +17,6 @@ try {
     $compiler = new Compiler();
     $compiler->compile();
 } catch (\Exception $e) {
-    echo 'Failed to compile phar: ['.get_class($e).'] '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine();
+    echo 'Failed to compile phar: ['.get_class($e).'] '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().PHP_EOL;
     exit(1);
 }

+ 7 - 0
src/Composer/Compiler.php

@@ -73,6 +73,10 @@ class Compiler
 
         $phar->startBuffering();
 
+        $finderSort = function ($a, $b) {
+            return strcmp($a, $b);
+        };
+
         $finder = new Finder();
         $finder->files()
             ->ignoreVCS(true)
@@ -80,6 +84,7 @@ class Compiler
             ->notName('Compiler.php')
             ->notName('ClassLoader.php')
             ->in(__DIR__.'/..')
+            ->sort($finderSort)
         ;
 
         foreach ($finder as $file) {
@@ -91,6 +96,7 @@ class Compiler
         $finder->files()
             ->name('*.json')
             ->in(__DIR__ . '/../../res')
+            ->sort($finderSort)
         ;
 
         foreach ($finder as $file) {
@@ -109,6 +115,7 @@ class Compiler
             ->in(__DIR__.'/../../vendor/symfony/')
             ->in(__DIR__.'/../../vendor/seld/jsonlint/')
             ->in(__DIR__.'/../../vendor/justinrainbow/json-schema/')
+            ->sort($finderSort)
         ;
 
         foreach ($finder as $file) {