2018-09-01 14:16:44 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2022-09-08 08:54:04 +00:00
|
|
|
|
2018-09-01 14:16:44 +00:00
|
|
|
/**
|
|
|
|
* Script used to generate hashes for release packages
|
|
|
|
*
|
|
|
|
* Usage: php build/patchtester/hash_generator.php
|
|
|
|
*
|
2018-09-01 14:32:23 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
|
2018-09-01 14:16:44 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
$packageDir = dirname(__DIR__) . '/packages';
|
|
|
|
|
|
|
|
$hashes = array();
|
|
|
|
|
|
|
|
/** @var DirectoryIterator $file */
|
2022-09-08 08:54:04 +00:00
|
|
|
foreach (new DirectoryIterator($packageDir) as $file) {
|
|
|
|
if ($file->isDir() || $file->isDot()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$hashes[$file->getFilename()] = array(
|
|
|
|
'sha384' => hash_file('sha384', $file->getPathname()),
|
|
|
|
);
|
2018-09-01 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$jsonOptions = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT : 0;
|
|
|
|
|
|
|
|
@file_put_contents($packageDir . '/checksums.json', json_encode($hashes, $jsonOptions));
|
|
|
|
|
|
|
|
echo 'Checksums file generated' . PHP_EOL . PHP_EOL;
|