Skip to content

Commit 4627215

Browse files
Make PHAR build reproducible (the only remaining differences were in the timestamps for the files in the PHAR)
1 parent aca96fc commit 4627215

23 files changed

+1732
-0
lines changed

build.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@
350350
<arg path="${basedir}/build/tmp/phar-scoped" />
351351
</exec>
352352

353+
<exec executable="${basedir}/build/scripts/phar-set-timestamps/run.php" taskname="phar-set-timestamps" failonerror="true">
354+
<arg path="${basedir}/build/artifacts/phpunit-library-${_version}.phar" />
355+
</exec>
356+
353357
<copy file="${basedir}/build/templates/binary-phar-autoload.php.in" tofile="${basedir}/build/tmp/binary-phar-autoload.php"/>
354358
<replace file="${basedir}/build/tmp/binary-phar-autoload.php" token="X.Y.Z" value="${_version}"/>
355359

@@ -366,6 +370,10 @@
366370
<arg path="${basedir}/build/tmp/phar-scoped" />
367371
</exec>
368372

373+
<exec executable="${basedir}/build/scripts/phar-set-timestamps/run.php" taskname="phar-set-timestamps" failonerror="true">
374+
<arg path="${basedir}/build/artifacts/phpunit-${_version}.phar" />
375+
</exec>
376+
369377
<chmod file="${basedir}/build/artifacts/phpunit-${_version}.phar" perm="ugo+rx"/>
370378

371379
<delete dir="${basedir}/build/tmp"/>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"require": {
3+
"seld/phar-utils": "^1.2"
4+
},
5+
"config": {
6+
"optimize-autoloader": true
7+
}
8+
}

build/scripts/phar-set-timestamps/composer.lock

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env php
2+
<?php declare(strict_types=1);
3+
require __DIR__ . '/vendor/autoload.php';
4+
5+
if (!isset($argv[1]) || !is_file($argv[1])) {
6+
exit(1);
7+
}
8+
9+
use Seld\PharUtils\Timestamps;
10+
11+
$util = new Timestamps($argv[1]);
12+
13+
if (is_string(getenv('SOURCE_DATE_EPOCH'))) {
14+
$timestamp = new DateTime;
15+
$timestamp->setTimestamp((int) getenv('SOURCE_DATE_EPOCH'));
16+
} else {
17+
$timestamp = new DateTimeImmutable('now');
18+
}
19+
20+
$util->updateTimestamps($timestamp);
21+
22+
$util->save($argv[1], Phar::SHA512);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
if (PHP_VERSION_ID < 50600) {
6+
if (!headers_sent()) {
7+
header('HTTP/1.1 500 Internal Server Error');
8+
}
9+
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10+
if (!ini_get('display_errors')) {
11+
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12+
fwrite(STDERR, $err);
13+
} elseif (!headers_sent()) {
14+
echo $err;
15+
}
16+
}
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
21+
}
22+
23+
require_once __DIR__ . '/composer/autoload_real.php';
24+
25+
return ComposerAutoloaderInit386a05f6676643b8b2eb49288e20d079::getLoader();

0 commit comments

Comments
 (0)