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

62
get.php
View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2019 UUP dump API authors
Copyright 2019 whatever127
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -71,38 +71,52 @@ function uupGetFiles(
}
}
$desiredEdition = strtoupper($desiredEdition);
$fileListSource = $desiredEdition;
if(!is_array($desiredEdition)) {
$desiredEdition = strtoupper($desiredEdition);
$fileListSource = $desiredEdition;
switch($desiredEdition) {
case '0':
if($usePack) {
$fileListSource = 'GENERATEDPACKS';
switch($desiredEdition) {
case '0':
if($usePack) {
$fileListSource = 'GENERATEDPACKS';
$filesList = array();
foreach($genPack[$usePack] as $val) {
foreach($val as $package) {
$filesList[] = $package;
$filesList = array();
foreach($genPack[$usePack] as $val) {
foreach($val as $package) {
$filesList[] = $package;
}
}
array_unique($filesList);
sort($filesList);
}
break;
case 'WUBFILE': break;
case 'UPDATEONLY': break;
default:
if(!isset($genPack[$usePack][$desiredEdition])) {
return array('error' => 'UNSUPPORTED_COMBINATION');
}
array_unique($filesList);
sort($filesList);
}
break;
$filesList = $genPack[$usePack][$desiredEdition];
$fileListSource = 'GENERATEDPACKS';
break;
}
} else {
$fileListSource = 'GENERATEDPACKS';
$filesList = array();
foreach($desiredEdition as $edition) {
$edition = strtoupper($edition);
case 'WUBFILE': break;
case 'UPDATEONLY': break;
default:
if(!isset($genPack[$usePack][$desiredEdition])) {
if(!isset($genPack[$usePack][$edition])) {
return array('error' => 'UNSUPPORTED_COMBINATION');
}
$filesList = $genPack[$usePack][$desiredEdition];
$fileListSource = 'GENERATEDPACKS';
break;
$filesList = array_merge($filesList, $genPack[$usePack][$edition]);
}
}
$rev = 1;

View File

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

View File

@ -33,7 +33,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku) {
$attrib = array(
'App=WU_OS',
'AppVer='.$build,
'AttrDataVer=62',
'AttrDataVer=63',
'BlockFeatureUpdates='.$blockUpgrades,
'BranchReadinessLevel=CB',
'CurrentBranch='.$branch,
@ -58,7 +58,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku) {
'OEMModel=Largehard Device Model 42069',
'OEMModelBaseBoard=Largehard Base Board',
'OEMName_Uncleaned=Largehard Corporation',
'OSArchitecture='.$arch,
'OSArchitecture='.$arch[0],
'OSSkuId='.$sku,
'OSUILocale=en-US',
'OSVersion='.$build,
@ -187,17 +187,31 @@ function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build
$mainProduct = 'Client.OS.rs2';
}
$products = array(
'PN='.$mainProduct.'.'.$arch.'&Branch='.$branch.'&PrimaryOSProduct=1&Repairable=1&V='.$build.'&ReofferUpdate=1',
'PN=Windows.Appraiser.'.$arch.'&Repairable=1&V='.$build,
'PN=Windows.AppraiserData.'.$arch.'&Repairable=1&V='.$build,
'PN=Windows.EmergencyUpdate.'.$arch.'&Repairable=1&V='.$build,
'PN=Windows.OOBE.'.$arch.'&IsWindowsOOBE=1&Repairable=1&V='.$build,
'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($arch == 'all') {
$arch = array(
'amd64',
'x86',
'arm64',
'arm',
);
}
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(
'Id=UpdateOrchestrator',