Add hash generator step

This commit is contained in:
Michael Babker 2018-09-01 09:16:44 -05:00
parent 17b2521ef1
commit 6b62a397df
2 changed files with 34 additions and 0 deletions

View File

@ -16,3 +16,4 @@ tar zcf ../packages/com_patchtester.tar.gz .
zip -r ../packages/com_patchtester.zip .
cd ../../
composer install
php build/patchtester/hash_generator.php

View File

@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
* Script used to generate hashes for release packages
*
* Usage: php build/patchtester/hash_generator.php
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
$packageDir = dirname(__DIR__) . '/packages';
$hashes = array();
/** @var DirectoryIterator $file */
foreach (new DirectoryIterator($packageDir) as $file)
{
if ($file->isDir() || $file->isDot())
{
continue;
}
$hashes[$file->getFilename()] = array(
'sha384' => hash_file('sha384', $file->getPathname()),
);
}
$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;