Browse Source

Add phar-utils package to update timestamps after the build is done, refs #3927

Jordi Boggiano 10 years ago
parent
commit
facdd8a503
4 changed files with 56 additions and 3 deletions
  1. 3 1
      bin/compile
  2. 2 1
      composer.json
  3. 45 1
      composer.lock
  4. 6 0
      src/Composer/Compiler.php

+ 3 - 1
bin/compile

@@ -3,7 +3,9 @@
 
 $cwd = getcwd();
 chdir(__DIR__.'/../');
-shell_exec('php bin/composer install -q');
+// Install with the current version to force it having the right ClassLoader version
+// Install without dev packages to clean up the included classmap from phpunit classes
+shell_exec('php bin/composer install -q --no-dev');
 chdir($cwd);
 
 require __DIR__.'/../src/bootstrap.php';

+ 2 - 1
composer.json

@@ -27,7 +27,8 @@
         "seld/jsonlint": "~1.0",
         "symfony/console": "~2.5",
         "symfony/finder": "~2.2",
-        "symfony/process": "~2.1"
+        "symfony/process": "~2.1",
+        "seld/phar-utils": "~1.0"
     },
     "require-dev": {
         "phpunit/phpunit": "~4.5",

+ 45 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "9a6a4c54f625e54ffe83b995dd796620",
+    "hash": "3b9e15f9521bb0a41897f65f76c1c7de",
     "packages": [
         {
             "name": "justinrainbow/json-schema",
@@ -118,6 +118,50 @@
             ],
             "time": "2015-01-04 21:18:15"
         },
+        {
+            "name": "seld/phar-utils",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Seldaek/phar-utils.git",
+                "reference": "9e36488921bc9252f9712190931966b2fe817e51"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/9e36488921bc9252f9712190931966b2fe817e51",
+                "reference": "9e36488921bc9252f9712190931966b2fe817e51",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Seld\\PharUtils\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggiano@seld.be"
+                }
+            ],
+            "description": "PHAR file format utilities, for when PHP phars you up",
+            "keywords": [
+                "phra"
+            ],
+            "time": "2015-05-01 12:39:58"
+        },
         {
             "name": "symfony/console",
             "version": "v2.6.6",

+ 6 - 0
src/Composer/Compiler.php

@@ -15,6 +15,7 @@ namespace Composer;
 use Composer\Json\JsonFile;
 use Symfony\Component\Finder\Finder;
 use Symfony\Component\Process\Process;
+use Seld\PharUtils\Timestamps;
 
 /**
  * The Compiler class compiles composer into a phar
@@ -143,6 +144,11 @@ class Compiler
         $this->addFile($phar, new \SplFileInfo(__DIR__.'/../../LICENSE'), false);
 
         unset($phar);
+
+        // resign the phar with reproducible timestamp / signature
+        $util = new Timestamps($pharFile);
+        $util->updateTimestamps($this->versionDate);
+        $util->save($pharFile, \Phar::SHA1);
     }
 
     private function addFile($phar, $file, $strip = true)