Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 13b9799

Browse files
author
Michael Babker
committed
Add hash generator to build tools
1 parent 60d107c commit 13b9799

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

build/hash_generator.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* Script used to generate hashes for release packages
5+
*
6+
* Usage: php build/hash_generator.php
7+
*
8+
* @package Joomla.Plugin
9+
* @subpackage Installer.webinstaller
10+
*
11+
* @copyright Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
12+
* @license GNU General Public License version 2 or later; see LICENSE
13+
*/
14+
15+
$packageDir = __DIR__ . '/packages';
16+
17+
$hashes = array();
18+
19+
/** @var DirectoryIterator $file */
20+
foreach (new DirectoryIterator($packageDir) as $file)
21+
{
22+
if ($file->isDir() || $file->isDot())
23+
{
24+
continue;
25+
}
26+
27+
$hashes[$file->getFilename()] = array(
28+
'sha256' => hash_file('sha256', $file->getPathname()),
29+
'sha384' => hash_file('sha384', $file->getPathname()),
30+
'sha512' => hash_file('sha512', $file->getPathname()),
31+
);
32+
}
33+
34+
$jsonOptions = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT : 0;
35+
36+
@file_put_contents($packageDir . '/checksums.json', json_encode($hashes, $jsonOptions));
37+
38+
echo 'Checksums file generated' . PHP_EOL . PHP_EOL;

0 commit comments

Comments
 (0)