ni_release / sha256 changes (#19)

add preliminary support for ni_release Apps as standalone edition
if equivalent cab files exist, exclude updates msu files (from download only)
exclude unnecessary baseless/express files
append 8-sha1 name suffix only for dupliicate files
This commit is contained in:
abbodi1406 2022-03-05 21:46:31 +03:00 committed by GitHub
parent 972cff36a5
commit a46a5628c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 52 deletions

146
get.php
View File

@ -79,6 +79,8 @@ function uupGetFiles(
}
}
$appEdition = 0;
if(!is_array($desiredEdition)) {
$desiredEdition = strtoupper($desiredEdition);
$fileListSource = $desiredEdition;
@ -104,6 +106,8 @@ function uupGetFiles(
case 'UPDATEONLY': break;
case 'APP': $appEdition = 1;
default:
if(!isset($genPack[$usePack][$desiredEdition])) {
return array('error' => 'UNSUPPORTED_COMBINATION');
@ -164,45 +168,52 @@ function uupGetFiles(
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
}
if(!$sha256capable) {
$baseless = preg_grep('/^baseless_|-baseless\....$/i', array_keys($filesInfoList));
foreach($baseless as $val) {
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
}
$psf = array_keys($filesInfoList);
$psf = preg_grep('/\.psf$/i', $psf);
$psfk = preg_grep('/Windows(10|11)\.0-KB.*/i', $psf);
$psfk = preg_grep('/.*-EXPRESS/i', $psfk, PREG_GREP_INVERT);
if($build > 21380) foreach($psfk as $key => $val) {
if(isset($psf[$key])) unset($psf[$key]);
}
unset($psfk);
$removeFiles = array();
foreach($psf as $val) {
$name = preg_replace('/\.psf$/i', '', $val);
$removeFiles[] = $name;
unset($filesInfoList[$val]);
}
unset($index, $name, $psf);
$temp = preg_grep('/'.$updateArch.'_.*|arm64\.arm_.*|arm64\.x86_.*/i', $removeFiles);
foreach($temp as $key => $val) {
if(isset($filesInfoList[$val.'.cab'])) unset($filesInfoList[$val.'.cab']);
unset($removeFiles[$key]);
}
unset($temp);
foreach($removeFiles as $val) {
if(isset($filesInfoList[$val.'.esd'])) {
if(isset($filesInfoList[$val.'.cab'])) unset($filesInfoList[$val.'.cab']);
}
}
unset($removeFiles);
$baseless = preg_grep('/^baseless_|Windows(10|11)\.0-KB.*-EXPRESS|SSU-.*-EXPRESS/i', array_keys($filesInfoList));
foreach($baseless as $val) {
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
}
$psf = array_keys($filesInfoList);
$psf = preg_grep('/\.psf$/i', $psf);
$psfk = preg_grep('/Windows(10|11)\.0-KB.*/i', $psf);
$psfk = preg_grep('/.*-EXPRESS/i', $psfk, PREG_GREP_INVERT);
foreach($psfk as $key => $val) {
if(isset($psf[$key])) unset($psf[$key]);
}
unset($psfk);
$removeFiles = array();
foreach($psf as $val) {
$name = preg_replace('/\.psf$/i', '', $val);
$removeFiles[] = $name;
unset($filesInfoList[$val]);
}
unset($index, $name, $psf);
$temp = preg_grep('/'.$updateArch.'_.*|arm64\.arm_.*|arm64\.x86_.*/i', $removeFiles);
foreach($temp as $key => $val) {
if(isset($filesInfoList[$val.'.cab'])) unset($filesInfoList[$val.'.cab']);
unset($removeFiles[$key]);
}
unset($temp);
foreach($removeFiles as $val) {
if(isset($filesInfoList[$val.'.esd'])) {
if(isset($filesInfoList[$val.'.cab'])) unset($filesInfoList[$val.'.cab']);
}
}
unset($removeFiles);
$msu = array_keys($filesInfoList);
$msu = preg_grep('/\.msu$/i', $msu);
$removeMSUs = array();
foreach($msu as $val) {
$name = preg_replace('/\.msu$/i', '', $val);
$removeMSUs[] = $name;
}
unset($index, $name, $msu);
$filesInfoKeys = array_keys($filesInfoList);
switch($fileListSource) {
@ -215,10 +226,17 @@ function uupGetFiles(
}
unset($removeFiles);
foreach($removeMSUs as $val) {
if(isset($filesInfoList[$val.'.cab'])) {
if(isset($filesInfoList[$val.'.msu'])) unset($filesInfoList[$val.'.msu']);
}
}
unset($removeMSUs);
$filesInfoKeys = array_keys($filesInfoList);
$temp = preg_grep('/.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $filesInfoKeys);
$filesInfoKeys = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\.cab/i', $filesInfoKeys);
$filesInfoKeys = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\....$/i', $filesInfoKeys);
if(count($filesInfoKeys) == 0) {
return array('error' => 'NOT_CUMULATIVE_UPDATE');
}
@ -238,11 +256,21 @@ function uupGetFiles(
if($updateSku == 135) $uupCleanFunc = 'uupCleanHolo';
if($fileListSource == 'GENERATEDPACKS') {
foreach($removeMSUs as $val) {
if(isset($filesInfoList[$val.'.cab'])) {
if(isset($filesInfoList[$val.'.msu'])) unset($filesInfoList[$val.'.msu']);
}
}
unset($removeMSUs);
$filesInfoKeys = array_keys($filesInfoList);
$temp = preg_grep('/Windows(10|11)\.0-KB.*-EXPRESS|Windows(10|11)\.0-KB.*-baseless|SSU-.*-.{3,5}-EXPRESS/i', $filesInfoKeys, PREG_GREP_INVERT);
if($build > 21380) {
$temp = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\.cab|.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $temp);
if($appEdition) {
$temp = preg_grep('/.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $temp);
} else if($build > 21380) {
$temp = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\....$|.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $temp);
} else {
$temp = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\.cab/i', $temp);
$temp = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\....$/i', $temp);
}
$filesPacksList = array_merge($filesPacksList, $temp);
@ -390,9 +418,12 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
}
if($sha256capable) {
$n = strrpos($name, '.');
if($n === false) $n = strlen($name);
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
$tempname = uupCleanSha256($name);
if(isset($files[$tempname])) {
$newName = uupAppendSha1($tempname, $sha1);
} else {
$newName = $tempname;
}
} else {
$newName = $uupCleanFunc($name);
}
@ -459,9 +490,12 @@ function uupGetOfflineFiles($info) {
$sha256 = isset($val['sha256']) ? $val['sha256'] : null;
if($sha256capable) {
$n = strrpos($name, '.');
if($n === false) $n = strlen($name);
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
$tempname = uupCleanSha256($name);
if(isset($files[$tempname])) {
$newName = uupAppendSha1($tempname, $sha1);
} else {
$newName = $tempname;
}
} else {
$newName = $uupCleanFunc($name);
}
@ -487,6 +521,24 @@ function uupGetOfflineFiles($info) {
return $files;
}
function uupAppendSha1($name, $sha1) {
$n = strrpos($name, '.');
if($n === false) $n = strlen($name);
return substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
}
function uupCleanSha256($name) {
$replace = array(
'prss_signed_appx_' => null,
'~31bf3856ad364e35' => null,
'~~.' => '.',
'~.' => '.',
'~' => '-',
);
return strtr($name, $replace);
}
function uupCleanName($name) {
$replace = array(
'cabs_' => null,

View File

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

View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2021 UUP dump API authors
Copyright 2022 UUP dump API authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ require_once dirname(__FILE__).'/../listid.php';
function uupGetInfoTexts() {
$fancyLangNames = array(
'neutral' => 'Any Language',
'ar-sa' => 'Arabic (Saudi Arabia)',
'bg-bg' => 'Bulgarian',
'cs-cz' => 'Czech',
@ -61,6 +62,8 @@ function uupGetInfoTexts() {
);
$fancyEditionNames = array(
'APP' => 'Microsoft Store Inbox Apps',
'FOD' => 'Features on Demand (Capabilities)',
'CLOUD' => 'Windows S',
'CLOUDN' => 'Windows S N',
'CLOUDE' => 'Windows Lean',

View File

@ -26,7 +26,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
$arch = $arch[0];
}
if($sku == 125 || $sku == 126 || $sku == 7 || $sku == 8 || $sku == 12 || $sku == 13 || $sku == 79 || $sku == 80 || $sku == 120 || $sku == 145 || $sku == 146 || $sku == 147 || $sku == 148 || $sku == 159 || $sku == 160 || $sku == 406 || $sku == 407 || $sku == 408)
if($sku == 125 || $sku == 126)
$blockUpgrades = 1;
$dvcFamily = 'Windows.Desktop';
@ -34,9 +34,10 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
if($sku == 119) {
$dvcFamily = 'Windows.Team';
}
if($sku == 7 || $sku == 8 || $sku == 12 || $sku == 13 || $sku == 79 || $sku == 80 || $sku == 120 || $sku == 145 || $sku == 146 || $sku == 147 || $sku == 148 || $sku == 159 || $sku == 160 || $sku == 406 || $sku == 407 || $sku == 408) {
if(in_array($sku, [7,8,12,13,79,80,120,145,146,147,148,159,160,406,407,408])) {
$dvcFamily = 'Windows.Server';
$insType = 'Server';
$blockUpgrades = 1;
}
/*/ Hololens
if($sku == 135) {
@ -331,7 +332,7 @@ function composeFetchUpdRequest($device, $encData, $arch, $flight, $ring, $build
$branch = branchFromBuild($build);
$mainProduct = 'Client.OS.rs2';
if($sku == 7 || $sku == 8 || $sku == 12 || $sku == 13 || $sku == 79 || $sku == 80 || $sku == 120 || $sku == 145 || $sku == 146 || $sku == 147 || $sku == 148 || $sku == 159 || $sku == 160 || $sku == 406 || $sku == 407 || $sku == 408) {
if(in_array($sku, [7,8,12,13,79,80,120,145,146,147,148,159,160,406,407,408])) {
$mainProduct = 'Server.OS';
}
/*/ Hololens