Add support for fetching multiple architectures at once

This commit is contained in:
whatever127 2019-06-16 19:00:45 +02:00
parent 8ed69debc2
commit c853ef74a4
4 changed files with 76 additions and 47 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
Copyright 2019 UUP dump API authors Copyright 2019 whatever127
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -60,7 +60,7 @@ function uupFetchUpd(
$build = intval($build[0]); $build = intval($build[0]);
$sku = intval($sku); $sku = intval($sku);
if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm')) { if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) {
return array('error' => 'UNKNOWN_ARCH'); return array('error' => 'UNKNOWN_ARCH');
} }
@ -192,8 +192,9 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
return array('error' => 'EMPTY_FILELIST'); return array('error' => 'EMPTY_FILELIST');
} }
preg_match('/Version\=".*?"/', $updateInfo, $foundBuild); preg_match('/ProductReleaseInstalled Name\=".*\.(.*?)" Version\="10\.0\.(.*?)"/', $updateInfo, $info);
$foundBuild = preg_replace('/Version="10\.0\.|"/', '', $foundBuild[0]); $foundArch = strtolower($info[1]);
$foundBuild = $info[2];
$updateTitle = preg_grep('/<Title>.*<\/Title>/', $updateMeta); $updateTitle = preg_grep('/<Title>.*<\/Title>/', $updateMeta);
sort($updateTitle); sort($updateTitle);
@ -214,7 +215,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle); $updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle);
} }
$updateTitle = preg_replace("/ ?\d{4}-\d{2}\w* ?| ?$arch ?| ?x64 ?/i", '', $updateTitle); $updateTitle = preg_replace("/ ?\d{4}-\d{2}\w* ?| ?$foundArch ?| ?x64 ?/i", '', $updateTitle);
if(!preg_match("/$foundBuild/i", $updateTitle)) { if(!preg_match("/$foundBuild/i", $updateTitle)) {
$updateTitle = $updateTitle.' ('.$foundBuild.')'; $updateTitle = $updateTitle.' ('.$foundBuild.')';
@ -235,7 +236,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
consoleLogger("--- UPDATE INFORMATION ---"); consoleLogger("--- UPDATE INFORMATION ---");
consoleLogger("Title: ".$updateTitle); consoleLogger("Title: ".$updateTitle);
consoleLogger("Architecture: ".$arch); consoleLogger("Architecture: ".$foundArch);
consoleLogger("Build number: ".$foundBuild); consoleLogger("Build number: ".$foundBuild);
consoleLogger("Update ID: ".$updateString); consoleLogger("Update ID: ".$updateString);
consoleLogger("--- UPDATE INFORMATION ---"); consoleLogger("--- UPDATE INFORMATION ---");
@ -278,7 +279,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$temp['title'] = $updateTitle; $temp['title'] = $updateTitle;
$temp['ring'] = $ring; $temp['ring'] = $ring;
$temp['flight'] = $flight; $temp['flight'] = $flight;
$temp['arch'] = $arch; $temp['arch'] = $foundArch;
$temp['build'] = $foundBuild; $temp['build'] = $foundBuild;
$temp['checkBuild'] = $build; $temp['checkBuild'] = $build;
$temp['sku'] = $sku; $temp['sku'] = $sku;
@ -307,7 +308,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$ids = uupListIds(); $ids = uupListIds();
if(!isset($ids['error'])) { if(!isset($ids['error'])) {
$ids = $ids['builds']; $ids = $ids['builds'];
$buildName = $foundBuild.' '.$updateTitle.' '.$arch; $buildName = $foundBuild.' '.$updateTitle.' '.$foundArch;
foreach($ids as $val) { foreach($ids as $val) {
$testName = $val['build'].' '.$val['title'].' '.$val['arch']; $testName = $val['build'].' '.$val['title'].' '.$val['arch'];
@ -325,7 +326,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
'updateId' => $updateString, 'updateId' => $updateString,
'updateTitle' => $updateTitle, 'updateTitle' => $updateTitle,
'foundBuild' => $foundBuild, 'foundBuild' => $foundBuild,
'arch' => $arch, 'arch' => $foundArch,
'fileWrite' => $fileWrite, 'fileWrite' => $fileWrite,
); );
} }

16
get.php
View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
Copyright 2019 UUP dump API authors Copyright 2019 whatever127
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -71,6 +71,7 @@ function uupGetFiles(
} }
} }
if(!is_array($desiredEdition)) {
$desiredEdition = strtoupper($desiredEdition); $desiredEdition = strtoupper($desiredEdition);
$fileListSource = $desiredEdition; $fileListSource = $desiredEdition;
@ -104,6 +105,19 @@ function uupGetFiles(
$fileListSource = 'GENERATEDPACKS'; $fileListSource = 'GENERATEDPACKS';
break; break;
} }
} else {
$fileListSource = 'GENERATEDPACKS';
$filesList = array();
foreach($desiredEdition as $edition) {
$edition = strtoupper($edition);
if(!isset($genPack[$usePack][$edition])) {
return array('error' => 'UNSUPPORTED_COMBINATION');
}
$filesList = array_merge($filesList, $genPack[$usePack][$edition]);
}
}
$rev = 1; $rev = 1;
if(preg_match('/_rev\./', $updateId)) { if(preg_match('/_rev\./', $updateId)) {

View File

@ -16,7 +16,7 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '1.21.8'; return '1.22.0';
} }
require_once dirname(__FILE__).'/auths.php'; require_once dirname(__FILE__).'/auths.php';

View File

@ -33,7 +33,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku) {
$attrib = array( $attrib = array(
'App=WU_OS', 'App=WU_OS',
'AppVer='.$build, 'AppVer='.$build,
'AttrDataVer=62', 'AttrDataVer=63',
'BlockFeatureUpdates='.$blockUpgrades, 'BlockFeatureUpdates='.$blockUpgrades,
'BranchReadinessLevel=CB', 'BranchReadinessLevel=CB',
'CurrentBranch='.$branch, 'CurrentBranch='.$branch,
@ -58,7 +58,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku) {
'OEMModel=Largehard Device Model 42069', 'OEMModel=Largehard Device Model 42069',
'OEMModelBaseBoard=Largehard Base Board', 'OEMModelBaseBoard=Largehard Base Board',
'OEMName_Uncleaned=Largehard Corporation', 'OEMName_Uncleaned=Largehard Corporation',
'OSArchitecture='.$arch, 'OSArchitecture='.$arch[0],
'OSSkuId='.$sku, 'OSSkuId='.$sku,
'OSUILocale=en-US', 'OSUILocale=en-US',
'OSVersion='.$build, 'OSVersion='.$build,
@ -187,17 +187,31 @@ function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build
$mainProduct = 'Client.OS.rs2'; $mainProduct = 'Client.OS.rs2';
} }
$products = array( if($arch == 'all') {
'PN='.$mainProduct.'.'.$arch.'&Branch='.$branch.'&PrimaryOSProduct=1&Repairable=1&V='.$build.'&ReofferUpdate=1', $arch = array(
'PN=Windows.Appraiser.'.$arch.'&Repairable=1&V='.$build, 'amd64',
'PN=Windows.AppraiserData.'.$arch.'&Repairable=1&V='.$build, 'x86',
'PN=Windows.EmergencyUpdate.'.$arch.'&Repairable=1&V='.$build, 'arm64',
'PN=Windows.OOBE.'.$arch.'&IsWindowsOOBE=1&Repairable=1&V='.$build, 'arm',
'PN=Windows.UpdateStackPackage.'.$arch.'&Name=Update Stack Package&Repairable=1&V='.$build,
'PN=Hammer.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
'PN=MSRT.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
'PN=SedimentPack.'.$arch.'&Source=UpdateOrchestrator&V=0.0.0.0',
); );
}
if(!is_array($arch)) {
$arch = array($arch);
}
$products = array();
foreach($arch as $currArch) {
$products[] = "PN=$mainProduct.$currArch&Branch=$branch&PrimaryOSProduct=1&Repairable=1&V=$build&ReofferUpdate=1";
$products[] = "PN=Windows.Appraiser.$currArch&Repairable=1&V=$build";
$products[] = "PN=Windows.AppraiserData.$currArch&Repairable=1&V=$build";
$products[] = "PN=Windows.EmergencyUpdate.$currArch&Repairable=1&V=$build";
$products[] = "PN=Windows.OOBE.$currArch&IsWindowsOOBE=1&Repairable=1&V=$build";
$products[] = "PN=Windows.UpdateStackPackage.$currArch&Name=Update Stack Package&Repairable=1&V=$build";
$products[] = "PN=Hammer.$currArch&Source=UpdateOrchestrator&V=0.0.0.0";
$products[] = "PN=MSRT.$currArch&Source=UpdateOrchestrator&V=0.0.0.0";
$products[] = "PN=SedimentPack.$currArch&Source=UpdateOrchestrator&V=0.0.0.0";
}
$callerAttrib = array( $callerAttrib = array(
'Id=UpdateOrchestrator', 'Id=UpdateOrchestrator',