sign-manifest: derive ZIP filename from manifest URL, tolerant fallback
Previously the script assumed every ZIP was named proserve-{version}.zip.
That broke when an upload was named "Proserve v1.4.6.zip" (with space and
capital P, the natural name produced by Compress-Archive on a Proserve
v1.4.6/ folder).
Now the script:
1. Reads download.url from each version entry, takes basename().
2. If that exact file is missing, falls back to a glob *{version}*.zip
in builds/ — succeeds if exactly one match.
3. Logs a clear message in either case.
Also fix manifest example hostname (www.exemple-asterion.com → asterionvr.com).
This commit is contained in:
@@ -11,11 +11,11 @@
|
|||||||
"executable": "PROSERVE_UE_5_5.exe",
|
"executable": "PROSERVE_UE_5_5.exe",
|
||||||
"installFolderTemplate": "Proserve v{version}",
|
"installFolderTemplate": "Proserve v{version}",
|
||||||
"download": {
|
"download": {
|
||||||
"url": "https://www.exemple-asterion.com/PS_Launcher/builds/proserve-1.4.6.zip",
|
"url": "https://asterionvr.com/PS_Launcher/builds/proserve-1.4.6.zip",
|
||||||
"sizeBytes": 0,
|
"sizeBytes": 0,
|
||||||
"sha256": "REPLACE_AFTER_BUILD"
|
"sha256": "REPLACE_AFTER_BUILD"
|
||||||
},
|
},
|
||||||
"releaseNotesUrl": "https://www.exemple-asterion.com/PS_Launcher/api/releasenotes/1.4.6",
|
"releaseNotesUrl": "https://asterionvr.com/PS_Launcher/api/releasenotes/1.4.6",
|
||||||
"minLicenseDate": "2025-01-01",
|
"minLicenseDate": "2025-01-01",
|
||||||
"availableForDownload": true
|
"availableForDownload": true
|
||||||
},
|
},
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
"executable": "PROSERVE_UE_5_5.exe",
|
"executable": "PROSERVE_UE_5_5.exe",
|
||||||
"installFolderTemplate": "Proserve v{version}",
|
"installFolderTemplate": "Proserve v{version}",
|
||||||
"download": {
|
"download": {
|
||||||
"url": "https://www.exemple-asterion.com/PS_Launcher/builds/proserve-1.4.5.zip",
|
"url": "https://asterionvr.com/PS_Launcher/builds/proserve-1.4.5.zip",
|
||||||
"sizeBytes": 0,
|
"sizeBytes": 0,
|
||||||
"sha256": "REPLACE_AFTER_BUILD"
|
"sha256": "REPLACE_AFTER_BUILD"
|
||||||
},
|
},
|
||||||
"releaseNotesUrl": "https://www.exemple-asterion.com/PS_Launcher/api/releasenotes/1.4.5",
|
"releaseNotesUrl": "https://asterionvr.com/PS_Launcher/api/releasenotes/1.4.5",
|
||||||
"minLicenseDate": "2024-06-01",
|
"minLicenseDate": "2024-06-01",
|
||||||
"availableForDownload": true
|
"availableForDownload": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Met à jour les champs `download.sizeBytes` et `download.sha256` de versions.json
|
* Met à jour les champs `download.sizeBytes` et `download.sha256` de versions.json
|
||||||
* en lisant les ZIPs présents dans /builds/, puis (v0.4) signera le manifest avec Ed25519.
|
* en lisant les ZIPs présents dans /builds/. Le nom local du ZIP est dérivé du
|
||||||
|
* champ `download.url` (basename de l'URL), donc tu peux nommer ton fichier comme
|
||||||
|
* tu veux tant que le manifest pointe vers le bon nom.
|
||||||
*
|
*
|
||||||
* Usage (à exécuter via SSH OVH dans www/PS_Launcher/) :
|
* Usage (à exécuter via SSH OVH dans www/PS_Launcher/) :
|
||||||
* php tools/sign-manifest.php
|
* php tools/sign-manifest.php
|
||||||
*
|
*
|
||||||
* Convention attendue : pour chaque entrée du manifest, le ZIP est dans
|
* (v0.4) Ajoutera la signature Ed25519 globale du manifest.
|
||||||
* builds/proserve-{version}.zip
|
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
@@ -22,20 +23,43 @@ if (!is_file($manifestPath)) {
|
|||||||
|
|
||||||
$manifest = json_decode(file_get_contents($manifestPath), true, 512, JSON_THROW_ON_ERROR);
|
$manifest = json_decode(file_get_contents($manifestPath), true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
|
$updated = 0;
|
||||||
foreach ($manifest['versions'] as &$v) {
|
foreach ($manifest['versions'] as &$v) {
|
||||||
$version = $v['version'];
|
$version = $v['version'] ?? '?';
|
||||||
$zip = "$buildsDir/proserve-{$version}.zip";
|
$url = $v['download']['url'] ?? '';
|
||||||
if (!is_file($zip)) {
|
if ($url === '') {
|
||||||
echo " [skip] $version : ZIP absent ($zip)\n";
|
echo " [skip] $version : pas d'URL dans le manifest\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filename = basename(parse_url($url, PHP_URL_PATH) ?: '');
|
||||||
|
$zip = "$buildsDir/$filename";
|
||||||
|
|
||||||
|
if (!is_file($zip)) {
|
||||||
|
// Fallback : si le fichier n'existe pas exactement avec le nom de l'URL,
|
||||||
|
// on tente une recherche tolérante par version (espaces / casse / séparateurs).
|
||||||
|
$candidates = glob("$buildsDir/*{$version}*.zip", GLOB_NOSORT) ?: [];
|
||||||
|
$candidates = array_values(array_filter($candidates, 'is_file'));
|
||||||
|
if (count($candidates) === 1) {
|
||||||
|
$zip = $candidates[0];
|
||||||
|
echo " [info] $version : URL pointait vers '{$filename}', utilisé '" . basename($zip) . "' à la place\n";
|
||||||
|
} else {
|
||||||
|
echo " [skip] $version : ZIP introuvable pour $url\n";
|
||||||
|
if (count($candidates) > 1) {
|
||||||
|
echo " Plusieurs candidats : " . implode(', ', array_map('basename', $candidates)) . "\n";
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$size = filesize($zip);
|
$size = filesize($zip);
|
||||||
echo " [hash] $version : $size octets...";
|
echo " [hash] $version : " . basename($zip) . " ($size octets)...";
|
||||||
$sha = hash_file('sha256', $zip);
|
$sha = hash_file('sha256', $zip);
|
||||||
echo " sha256={$sha}\n";
|
echo " sha256={$sha}\n";
|
||||||
|
|
||||||
$v['download']['sizeBytes'] = $size;
|
$v['download']['sizeBytes'] = $size;
|
||||||
$v['download']['sha256'] = $sha;
|
$v['download']['sha256'] = $sha;
|
||||||
|
$updated++;
|
||||||
}
|
}
|
||||||
unset($v);
|
unset($v);
|
||||||
|
|
||||||
@@ -49,4 +73,4 @@ file_put_contents(
|
|||||||
$manifestPath,
|
$manifestPath,
|
||||||
json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
|
json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
|
||||||
);
|
);
|
||||||
echo "Manifest mis à jour : $manifestPath\n";
|
echo "Manifest mis à jour ({$updated} version(s)) : $manifestPath\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user