commit13
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Tempo\Purchasing\Delivery\AccessOverlay;
|
||||
|
||||
require dirname(__DIR__).'/integrations/sgf/access/AccessOverlay.php';
|
||||
|
||||
$host = realpath($argv[1] ?? dirname(__DIR__).'/../sgf-tempo');
|
||||
if (! $host) {
|
||||
throw new RuntimeException('Host inexistente.');
|
||||
}
|
||||
$files = AccessOverlay::prepare($host);
|
||||
$support = [];
|
||||
foreach (['InitialAuthority.php', 'AccessOverlay.php', 'routes.php', 'screen.php'] as $name) {
|
||||
$support[$name] = file_get_contents(dirname(__DIR__).'/integrations/sgf/access/'.$name);
|
||||
}
|
||||
$hash = hash('sha256', json_encode([$files, $support], JSON_THROW_ON_ERROR));
|
||||
$directory = dirname(__DIR__).'/storage/app/private/candidates/ACCESS-CANDIDATE-'.substr($hash, 0, 16);
|
||||
$manifest = ['format' => 'tempo.host-overlay.review.v1', 'activation_authorized' => false, 'installed' => false, 'host_version_preserved' => '0.1.1', 'files' => []];
|
||||
foreach ($files as $path => $file) {
|
||||
$target = $directory.'/'.$path;
|
||||
if (! is_dir(dirname($target))) {
|
||||
mkdir(dirname($target), 0700, true);
|
||||
}
|
||||
if (is_file($target) && hash_file('sha256', $target) !== $file['after_sha256']) {
|
||||
throw new RuntimeException('Artefacto imutável divergente.');
|
||||
}
|
||||
file_put_contents($target, $file['contents']);
|
||||
unset($file['contents']);
|
||||
$manifest['files'][$path] = $file;
|
||||
}
|
||||
foreach ($support as $name => $content) {
|
||||
if (is_file($directory.'/'.$name) && hash_file('sha256', $directory.'/'.$name) !== hash('sha256', $content)) {
|
||||
throw new RuntimeException('Artefacto de acesso imutável divergente.');
|
||||
}
|
||||
file_put_contents($directory.'/'.$name, $content);
|
||||
$manifest['support_files'][$name] = hash('sha256', $content);
|
||||
}
|
||||
file_put_contents($directory.'/manifest.json', json_encode($manifest, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
|
||||
echo json_encode(['directory' => $directory, 'installed' => false], JSON_THROW_ON_ERROR)."\n";
|
||||
Reference in New Issue
Block a user