Branch selection support

This commit is contained in:
Kaenbyou Rin 2024-02-28 18:38:42 +01:00
parent d10e24cf5b
commit ca81835609
3 changed files with 93 additions and 18 deletions

View File

@ -50,6 +50,52 @@ function uupApiPrivateGetLatestBuild() {
return $build; return $build;
} }
function uupApiPrivateGetAcceptableBranches() {
return [
'auto',
'rs2_release',
'rs3_release',
'rs4_release',
'rs5_release',
'rs5_release_svc_hci',
'19h1_release',
'vb_release',
'fe_release_10x',
'fe_release',
'co_release',
'ni_release',
'zn_release',
'ge_release',
'rs_prerelease',
];
}
function uupApiPrivateNormalizeFetchParams($params) {
$np = array_replace([
'arch' => 'amd64',
'ring' => 'WIF',
'flight' => 'Active',
'branch' => 'ge_release',
'build' => 'latest',
'sku' => 48,
'type' => 'Production',
'flags' => [],
], $params);
if(!is_array($np['flags'])) $np['flags'] = [];
$np['arch'] = strtolower($np['arch']);
$np['ring'] = strtoupper($np['ring']);
$np['flight'] = ucwords(strtolower($np['flight']));
$np['branch'] = strtolower($np['branch']);
$np['build'] = strtolower($np['build']);
$np['sku'] = intval($np['sku']);
$np['type'] = ucwords(strtolower($np['type']));
$np['flags'] = array_map('strtolower', $np['flags']);
return $np;
}
function uupFetchUpd( function uupFetchUpd(
$arch = 'amd64', $arch = 'amd64',
$ring = 'WIF', $ring = 'WIF',
@ -60,14 +106,35 @@ function uupFetchUpd(
$type = 'Production', $type = 'Production',
$cacheRequests = 0 $cacheRequests = 0
) { ) {
[$build, $flags] = uupApiPrivateParseFlags($build);
$params = [
'arch' => $arch,
'ring' => $ring,
'flight' => $flight,
'build' => $build,
'sku' => $sku,
'type' => $type,
'flags' => $flags,
];
return uupFetchUpd2($params, $cacheRequests);
}
function uupFetchUpd2($params, $cacheRequests = 0) {
uupApiPrintBrand(); uupApiPrintBrand();
$arch = strtolower($arch); $np = uupApiPrivateNormalizeFetchParams($params);
$ring = strtoupper($ring);
$flight = ucwords(strtolower($flight)); $arch = $np['arch'];
$flight = 'Active'; $ring = $np['ring'];
$flight = 'Active';
$branch = $np['branch'];
$build = $np['build'];
$sku = $np['sku'];
$type = $np['type'];
$flags = $np['flags'];
[$build, $flags] = uupApiPrivateParseFlags($build);
$flagsStr = implode(',', $flags); $flagsStr = implode(',', $flags);
if(strtolower($build) == 'latest' || (!$build)) { if(strtolower($build) == 'latest' || (!$build)) {
@ -77,7 +144,6 @@ function uupFetchUpd(
$build = explode('.', $build); $build = explode('.', $build);
if(isset($build[1])) $minor = intval($build[1]); if(isset($build[1])) $minor = intval($build[1]);
$build = intval($build[0]); $build = intval($build[0]);
$sku = intval($sku);
if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) { if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) {
return array('error' => 'UNKNOWN_ARCH'); return array('error' => 'UNKNOWN_ARCH');
@ -103,6 +169,9 @@ function uupFetchUpd(
return array('error' => 'ILLEGAL_MINOR'); return array('error' => 'ILLEGAL_MINOR');
} }
if(!in_array($branch, uupApiPrivateGetAcceptableBranches()))
$branch = 'auto';
if($ring == 'DEV') $ring = 'WIF'; if($ring == 'DEV') $ring = 'WIF';
if($ring == 'BETA') $ring = 'WIS'; if($ring == 'BETA') $ring = 'WIS';
if($ring == 'RELEASEPREVIEW') $ring = 'RP'; if($ring == 'RELEASEPREVIEW') $ring = 'RP';
@ -116,13 +185,13 @@ function uupFetchUpd(
$type = 'Production'; $type = 'Production';
} }
$res = "api-fetch-$arch-$ring-$flight-$build-$flagsStr-$minor-$sku-$type"; $res = "api-fetch-$arch-$ring-$flight-$branch-$build-$flagsStr-$minor-$sku-$type";
$cache = new UupDumpCache($res); $cache = new UupDumpCache($res);
$fromCache = $cache->get(); $fromCache = $cache->get();
if($fromCache !== false) return $fromCache; if($fromCache !== false) return $fromCache;
consoleLogger('Fetching information from the server...'); consoleLogger('Fetching information from the server...');
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags]; $composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags, $branch];
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs); $out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
if($out === false || $out['error'] != 200) { if($out === false || $out['error'] != 200) {
consoleLogger('The request has failed'); consoleLogger('The request has failed');
@ -150,7 +219,7 @@ function uupFetchUpd(
$num++; $num++;
consoleLogger("Checking build information for update {$num} of {$updatesNum}..."); consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags); $info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch);
if(isset($info['error'])) { if(isset($info['error'])) {
$errorCount++; $errorCount++;
continue; continue;
@ -180,7 +249,7 @@ function uupFetchUpd(
return $data; return $data;
} }
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags) { function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch) {
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo); $updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
$updates = preg_replace('/<Update>/', "\n<Update>", $out); $updates = preg_replace('/<Update>/', "\n<Update>", $out);
@ -358,6 +427,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['branch'] = $branch;
$temp['arch'] = $foundArch; $temp['arch'] = $foundArch;
$temp['build'] = $foundBuild; $temp['build'] = $foundBuild;
$temp['checkBuild'] = $build; $temp['checkBuild'] = $build;

View File

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

View File

@ -16,8 +16,10 @@ limitations under the License.
*/ */
// Composes DeviceAttributes parameter needed to fetch data // Composes DeviceAttributes parameter needed to fetch data
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags) { function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags, $branch) {
if($branch == 'auto')
$branch = branchFromBuild($build); $branch = branchFromBuild($build);
$blockUpgrades = 0; $blockUpgrades = 0;
$flightEnabled = 1; $flightEnabled = 1;
$isRetail = 0; $isRetail = 0;
@ -164,6 +166,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'IsDeviceRetailDemo=0', 'IsDeviceRetailDemo=0',
'IsFlightingEnabled='.$flightEnabled, 'IsFlightingEnabled='.$flightEnabled,
'IsRetailOS='.$isRetail, 'IsRetailOS='.$isRetail,
'LCUVer=0.0.0.0',
'MediaBranch=', 'MediaBranch=',
'MediaVersion='.$build, 'MediaVersion='.$build,
'CloudPBR=1', 'CloudPBR=1',
@ -212,6 +215,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'UpgradeAccepted=1', 'UpgradeAccepted=1',
'UpgradeEligible=1', 'UpgradeEligible=1',
'UserInPlaceUpgrade=1', 'UserInPlaceUpgrade=1',
'VBSState=2',
'Version_RS5=2000000000', 'Version_RS5=2000000000',
'WuClientVer='.$build, 'WuClientVer='.$build,
); );
@ -308,8 +312,6 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
$created = gmdate(DATE_W3C, $createdTime); $created = gmdate(DATE_W3C, $createdTime);
$expires = gmdate(DATE_W3C, $expiresTime); $expires = gmdate(DATE_W3C, $expiresTime);
//$branch = branchFromBuild($info['checkBuild']);
$deviceAttributes = composeDeviceAttributes( $deviceAttributes = composeDeviceAttributes(
isset($info['flight']) ? $info['flight'] : 'Active', isset($info['flight']) ? $info['flight'] : 'Active',
isset($info['ring']) ? $info['ring'] : 'RETAIL', isset($info['ring']) ? $info['ring'] : 'RETAIL',
@ -318,6 +320,7 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
isset($info['sku']) ? $info['sku'] : 48, isset($info['sku']) ? $info['sku'] : 48,
$type, $type,
isset($info['flags']) ? $info['flags'] : [], isset($info['flags']) ? $info['flags'] : [],
isset($info['branch']) ? $info['branch'] : 'auto',
); );
return <<<XML return <<<XML
@ -361,7 +364,7 @@ XML;
} }
// Composes POST data for fetching the latest update information from Windows Update // Composes POST data for fetching the latest update information from Windows Update
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) { function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = [], $branch = 'auto') {
$encData = uupEncryptedData(); $encData = uupEncryptedData();
if($encData === false) if($encData === false)
return false; return false;
@ -377,6 +380,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$expires = gmdate(DATE_W3C, $expiresTime); $expires = gmdate(DATE_W3C, $expiresTime);
$cookieExpires = gmdate(DATE_W3C, $cookieExpiresTime); $cookieExpires = gmdate(DATE_W3C, $cookieExpiresTime);
if($branch == 'auto')
$branch = branchFromBuild($build); $branch = branchFromBuild($build);
$mainProduct = 'Client.OS.rs2'; $mainProduct = 'Client.OS.rs2';
@ -453,7 +457,8 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$arch, $arch,
$sku, $sku,
$type, $type,
$flags $flags,
$branch
); );
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false'; $syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';