26 lines
1.0 KiB
PHP
26 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$root = dirname(__DIR__).'/packages/';
|
|
$manifest = json_decode(file_get_contents($root.'runtime-manifest.json'), true, 32, JSON_THROW_ON_ERROR);
|
|
if (($manifest['version'] ?? null) !== 1
|
|
|| ! is_array($manifest['files'] ?? null)
|
|
|| ! isset($manifest['files']['budget-control/bootstrap.php'], $manifest['files']['payables/bootstrap.php'])) {
|
|
fwrite(STDERR, "Manifesto de execução incompleto ou incompatível.\n");
|
|
exit(1);
|
|
}
|
|
$errors = [];
|
|
foreach ($manifest['files'] as $path => $expected) {
|
|
if (! preg_match('~^(budget-control|payables)/(bootstrap\.php|README\.md|(src|ui)/[A-Za-z]+\.php)$~D', $path)
|
|
|| ! is_file($root.$path)
|
|
|| hash_file('sha256', $root.$path) !== $expected) {
|
|
$errors[] = $path;
|
|
}
|
|
}
|
|
if ($errors) {
|
|
fwrite(STDERR, 'Pacotes de execução divergentes: '.implode(', ', $errors)."\n");
|
|
exit(1);
|
|
}
|
|
fwrite(STDOUT, count($manifest['files'])." ficheiros de execução conferidos por SHA-256. Sem dependência da pasta SGF.\n");
|