use sha256 for generated packs

This commit is contained in:
luzeadev 2021-09-19 15:59:21 +02:00
parent e99a78cc2d
commit 8ca718ed8d
2 changed files with 12 additions and 21 deletions

View File

@ -36,10 +36,17 @@ function generatePack($updateId) {
$isku = $files['sku']; $isku = $files['sku'];
$files = $files['files']; $files = $files['files'];
if(!$files[key($files)]['sha256']) {
consoleLogger('Update is not SHA-256 capable!');
return 0;
}
$filesKeys = array_keys($files); $filesKeys = array_keys($files);
$filesToRead = array(); $filesToRead = array();
$aggregatedMetadata = preg_grep('/AggregatedMetadata/i', $filesKeys); $aggregatedMetadata = preg_grep('/AggregatedMetadata/i', $filesKeys);
if(!empty($aggregatedMetadata)) { if(!empty($aggregatedMetadata)) {
sort($aggregatedMetadata); sort($aggregatedMetadata);
$checkFile = $aggregatedMetadata[0]; $checkFile = $aggregatedMetadata[0];
@ -128,12 +135,6 @@ function generatePack($updateId) {
unset($loc, $checkEd, $dataFiles); unset($loc, $checkEd, $dataFiles);
} }
$keepPath = 0;
foreach($filesKeys as $val) {
if(preg_match('/^appx\/(.*?)\//i', $val)) $keepPath = 1;
if(preg_match('/^(retail)\/(.{3,5})\/fre\//i', $val)) $keepPath = 1;
}
$langsEditions = array(); $langsEditions = array();
$packages = array(); $packages = array();
foreach($filesToRead as $val) { foreach($filesToRead as $val) {
@ -157,25 +158,15 @@ function generatePack($updateId) {
foreach($xml->Packages->Package as $val) { foreach($xml->Packages->Package as $val) {
foreach($val->Payload->PayloadItem as $PayloadItem) { foreach($val->Payload->PayloadItem as $PayloadItem) {
$name = $PayloadItem['Path']; $sha256 = bin2hex(base64_decode($PayloadItem['PayloadHash']));
if($keepPath) { $packages[$lang][$edition][] = $sha256;
$name = str_replace('\\', '_', $name);
} else {
$name = preg_replace('/.*\\\/', '', $name);
}
$packages[$lang][$edition][] = $name;
} }
} }
if(@count($xml->AppX)) foreach($xml->AppX->AppXPackages->Package as $val) { if(@count($xml->AppX)) foreach($xml->AppX->AppXPackages->Package as $val) {
foreach($val->Payload->PayloadItem as $PayloadItem) { foreach($val->Payload->PayloadItem as $PayloadItem) {
$name = $PayloadItem['Path']; $sha256 = bin2hex(base64_decode($PayloadItem['PayloadHash']));
if($keepPath) { $packages[$lang][$edition][] = $sha256;
$name = str_replace('\\', '_', $name);
} else {
$name = preg_replace('/.*\\\/', '', $name);
}
$packages[$lang][$edition][] = $name;
} }
} }

View File

@ -2,7 +2,7 @@
require_once dirname(__FILE__).'/../api/shared/main.php'; require_once dirname(__FILE__).'/../api/shared/main.php';
function brand($script = null) { function brand($script = null) {
$projVersion = '1.0.3'; $projVersion = '1.1.0';
return 'UUP dump standalone v'.$projVersion; return 'UUP dump standalone v'.$projVersion;
} }