Add target release selection support
This commit is contained in:
+19
-4
@@ -33,6 +33,15 @@ function uupApiPrivateParseFlags($str) {
|
||||
return [$split[0], $flagsSafe];
|
||||
}
|
||||
|
||||
function uupApiPrivateParseRing($str) {
|
||||
$split = explode(':', $str);
|
||||
if(!isset($split[1])) {
|
||||
return [$split[0], -1];
|
||||
}
|
||||
|
||||
return $split;
|
||||
}
|
||||
|
||||
function uupApiPrivateGetLatestBuild() {
|
||||
$ids = uupListIds();
|
||||
|
||||
@@ -100,6 +109,7 @@ function uupApiPrivateNormalizeFetchParams($params) {
|
||||
'sku' => 48,
|
||||
'type' => 'Production',
|
||||
'flags' => [],
|
||||
'targetRelease' => -1,
|
||||
], $params);
|
||||
|
||||
if(!is_array($np['flags'])) $np['flags'] = [];
|
||||
@@ -113,6 +123,7 @@ function uupApiPrivateNormalizeFetchParams($params) {
|
||||
$np['sku'] = intval($np['sku']);
|
||||
$np['type'] = ucwords(strtolower($np['type']));
|
||||
$np['flags'] = array_map('strtolower', $np['flags']);
|
||||
$np['targetRelease'] = intval($np['targetRelease']);
|
||||
|
||||
return $np;
|
||||
}
|
||||
@@ -128,6 +139,7 @@ function uupFetchUpd(
|
||||
$cacheRequests = 0
|
||||
) {
|
||||
[$build, $flags] = uupApiPrivateParseFlags($build);
|
||||
[$ring, $targetRelease] = uupApiPrivateParseRing($ring);
|
||||
|
||||
$params = [
|
||||
'arch' => $arch,
|
||||
@@ -138,6 +150,7 @@ function uupFetchUpd(
|
||||
'sku' => $sku,
|
||||
'type' => $type,
|
||||
'flags' => $flags,
|
||||
'targetRelease' => $targetRelease,
|
||||
];
|
||||
|
||||
return uupFetchUpd2($params, $cacheRequests);
|
||||
@@ -157,6 +170,7 @@ function uupFetchUpd2($params, $cacheRequests = 0) {
|
||||
$sku = $np['sku'];
|
||||
$type = $np['type'];
|
||||
$flags = $np['flags'];
|
||||
$targetRelease = $np['targetRelease'];
|
||||
|
||||
$flagsStr = implode(',', $flags);
|
||||
|
||||
@@ -214,13 +228,13 @@ function uupFetchUpd2($params, $cacheRequests = 0) {
|
||||
$type = 'Production';
|
||||
}
|
||||
|
||||
$res = "api-fetch-$arch-$ring-$flight-$branch-$build-$flagsStr-$minor-$sku-$type";
|
||||
$res = "api-fetch-$arch-$ring-$flight-$branch-$build-$flagsStr-$minor-$sku-$type-$targetRelease";
|
||||
$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, $branch];
|
||||
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags, $branch, $targetRelease];
|
||||
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
|
||||
if($out === false || $out['error'] != 200) {
|
||||
consoleLogger('The request has failed');
|
||||
@@ -248,7 +262,7 @@ function uupFetchUpd2($params, $cacheRequests = 0) {
|
||||
$num++;
|
||||
consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
|
||||
|
||||
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch);
|
||||
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch, $targetRelease);
|
||||
if(isset($info['error'])) {
|
||||
$errorCount++;
|
||||
continue;
|
||||
@@ -278,7 +292,7 @@ function uupFetchUpd2($params, $cacheRequests = 0) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch) {
|
||||
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch, $targetRelease) {
|
||||
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
|
||||
|
||||
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
|
||||
@@ -493,6 +507,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
|
||||
$temp['ring'] = $ring;
|
||||
$temp['flight'] = $flight;
|
||||
$temp['branch'] = $branch;
|
||||
$temp['targetRelease'] = $targetRelease;
|
||||
$temp['arch'] = $foundArch;
|
||||
$temp['fetchArch'] = $arch == 'all' ? 'amd64' : $arch;
|
||||
$temp['build'] = $foundBuild;
|
||||
|
||||
+10
-3
@@ -16,7 +16,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Composes DeviceAttributes parameter needed to fetch data
|
||||
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags, $branch) {
|
||||
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags, $branch, $targetRelease) {
|
||||
if($branch == 'auto')
|
||||
$branch = branchFromBuild($build);
|
||||
|
||||
@@ -241,6 +241,11 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
|
||||
'WuClientVer='.$build,
|
||||
);
|
||||
|
||||
if($bldnum >= 26100) {
|
||||
$attrib[] = 'FlightUpgradeTarget='.$targetRelease;
|
||||
$attrib[] = 'IsFutureKeyEnabled=1';
|
||||
}
|
||||
|
||||
if(in_array('thisonly', $flags)) {
|
||||
$attrib[] = 'MediaBranch='.$branch;
|
||||
}
|
||||
@@ -363,6 +368,7 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
|
||||
$type,
|
||||
isset($info['flags']) ? $info['flags'] : [],
|
||||
isset($info['branch']) ? $info['branch'] : 'auto',
|
||||
isset($info['targetRelease']) ? $info['targetRelease'] : -1
|
||||
);
|
||||
|
||||
return <<<XML
|
||||
@@ -406,7 +412,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 = [], $branch = 'auto') {
|
||||
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = [], $branch = 'auto', $targetRelease = -1) {
|
||||
$encData = uupEncryptedData();
|
||||
if($encData === false)
|
||||
return false;
|
||||
@@ -506,7 +512,8 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
|
||||
$sku,
|
||||
$type,
|
||||
$flags,
|
||||
$branch
|
||||
$branch,
|
||||
$targetRelease
|
||||
);
|
||||
|
||||
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';
|
||||
|
||||
Reference in New Issue
Block a user