From c853ef74a443040b0128dc7d4677f9f68f4883ed Mon Sep 17 00:00:00 2001 From: whatever127 Date: Sun, 16 Jun 2019 19:00:45 +0200 Subject: [PATCH] Add support for fetching multiple architectures at once --- fetchupd.php | 19 +++++++------- get.php | 62 +++++++++++++++++++++++++++------------------ shared/main.php | 2 +- shared/requests.php | 40 +++++++++++++++++++---------- 4 files changed, 76 insertions(+), 47 deletions(-) diff --git a/fetchupd.php b/fetchupd.php index 7c432e1..a1089bf 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -1,6 +1,6 @@ '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>/', $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, ); } diff --git a/get.php b/get.php index 96e9c04..0bb2d32 100644 --- a/get.php +++ b/get.php @@ -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; diff --git a/shared/main.php b/shared/main.php index c13dadb..8f23ab4 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.21.8'; + return '1.22.0'; } require_once dirname(__FILE__).'/auths.php'; diff --git a/shared/requests.php b/shared/requests.php index e5fe0e0..7f85521 100644 --- a/shared/requests.php +++ b/shared/requests.php @@ -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',