forked from uup-dump/api
Branch selection support
This commit is contained in:
parent
d10e24cf5b
commit
ca81835609
90
fetchupd.php
90
fetchupd.php
@ -50,6 +50,52 @@ function uupApiPrivateGetLatestBuild() {
|
||||
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(
|
||||
$arch = 'amd64',
|
||||
$ring = 'WIF',
|
||||
@ -60,14 +106,35 @@ function uupFetchUpd(
|
||||
$type = 'Production',
|
||||
$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();
|
||||
|
||||
$arch = strtolower($arch);
|
||||
$ring = strtoupper($ring);
|
||||
$flight = ucwords(strtolower($flight));
|
||||
$flight = 'Active';
|
||||
$np = uupApiPrivateNormalizeFetchParams($params);
|
||||
|
||||
$arch = $np['arch'];
|
||||
$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);
|
||||
|
||||
if(strtolower($build) == 'latest' || (!$build)) {
|
||||
@ -77,7 +144,6 @@ function uupFetchUpd(
|
||||
$build = explode('.', $build);
|
||||
if(isset($build[1])) $minor = intval($build[1]);
|
||||
$build = intval($build[0]);
|
||||
$sku = intval($sku);
|
||||
|
||||
if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) {
|
||||
return array('error' => 'UNKNOWN_ARCH');
|
||||
@ -103,6 +169,9 @@ function uupFetchUpd(
|
||||
return array('error' => 'ILLEGAL_MINOR');
|
||||
}
|
||||
|
||||
if(!in_array($branch, uupApiPrivateGetAcceptableBranches()))
|
||||
$branch = 'auto';
|
||||
|
||||
if($ring == 'DEV') $ring = 'WIF';
|
||||
if($ring == 'BETA') $ring = 'WIS';
|
||||
if($ring == 'RELEASEPREVIEW') $ring = 'RP';
|
||||
@ -116,13 +185,13 @@ function uupFetchUpd(
|
||||
$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);
|
||||
$fromCache = $cache->get();
|
||||
if($fromCache !== false) return $fromCache;
|
||||
|
||||
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);
|
||||
if($out === false || $out['error'] != 200) {
|
||||
consoleLogger('The request has failed');
|
||||
@ -150,7 +219,7 @@ function uupFetchUpd(
|
||||
$num++;
|
||||
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'])) {
|
||||
$errorCount++;
|
||||
continue;
|
||||
@ -180,7 +249,7 @@ function uupFetchUpd(
|
||||
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);
|
||||
|
||||
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
|
||||
@ -358,6 +427,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
|
||||
$temp['title'] = $updateTitle;
|
||||
$temp['ring'] = $ring;
|
||||
$temp['flight'] = $flight;
|
||||
$temp['branch'] = $branch;
|
||||
$temp['arch'] = $foundArch;
|
||||
$temp['build'] = $foundBuild;
|
||||
$temp['checkBuild'] = $build;
|
||||
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
function uupApiVersion() {
|
||||
return '1.43.5';
|
||||
return '1.44.0';
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__).'/auths.php';
|
||||
|
@ -16,8 +16,10 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// 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);
|
||||
|
||||
$blockUpgrades = 0;
|
||||
$flightEnabled = 1;
|
||||
$isRetail = 0;
|
||||
@ -164,6 +166,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
|
||||
'IsDeviceRetailDemo=0',
|
||||
'IsFlightingEnabled='.$flightEnabled,
|
||||
'IsRetailOS='.$isRetail,
|
||||
'LCUVer=0.0.0.0',
|
||||
'MediaBranch=',
|
||||
'MediaVersion='.$build,
|
||||
'CloudPBR=1',
|
||||
@ -212,6 +215,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
|
||||
'UpgradeAccepted=1',
|
||||
'UpgradeEligible=1',
|
||||
'UserInPlaceUpgrade=1',
|
||||
'VBSState=2',
|
||||
'Version_RS5=2000000000',
|
||||
'WuClientVer='.$build,
|
||||
);
|
||||
@ -308,8 +312,6 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
|
||||
$created = gmdate(DATE_W3C, $createdTime);
|
||||
$expires = gmdate(DATE_W3C, $expiresTime);
|
||||
|
||||
//$branch = branchFromBuild($info['checkBuild']);
|
||||
|
||||
$deviceAttributes = composeDeviceAttributes(
|
||||
isset($info['flight']) ? $info['flight'] : 'Active',
|
||||
isset($info['ring']) ? $info['ring'] : 'RETAIL',
|
||||
@ -318,6 +320,7 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
|
||||
isset($info['sku']) ? $info['sku'] : 48,
|
||||
$type,
|
||||
isset($info['flags']) ? $info['flags'] : [],
|
||||
isset($info['branch']) ? $info['branch'] : 'auto',
|
||||
);
|
||||
|
||||
return <<<XML
|
||||
@ -361,7 +364,7 @@ XML;
|
||||
}
|
||||
|
||||
// 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();
|
||||
if($encData === false)
|
||||
return false;
|
||||
@ -377,6 +380,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
|
||||
$expires = gmdate(DATE_W3C, $expiresTime);
|
||||
$cookieExpires = gmdate(DATE_W3C, $cookieExpiresTime);
|
||||
|
||||
if($branch == 'auto')
|
||||
$branch = branchFromBuild($build);
|
||||
|
||||
$mainProduct = 'Client.OS.rs2';
|
||||
@ -453,7 +457,8 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
|
||||
$arch,
|
||||
$sku,
|
||||
$type,
|
||||
$flags
|
||||
$flags,
|
||||
$branch
|
||||
);
|
||||
|
||||
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';
|
||||
|
Loading…
Reference in New Issue
Block a user