From d1df967dedc429578a10c84ea41fea72e419db3a Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Mon, 16 Oct 2017 18:03:26 +0200 Subject: [PATCH] Add support for Cumulative Updates --- fetchupd.php | 22 +++++++++++++--------- get.php | 32 +++++++++++++++++++++++++++----- shared/main.php | 4 ++-- shared/packs.php | 1 + 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/fetchupd.php b/fetchupd.php index 84cd150..524c5cf 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -144,15 +144,19 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build ksort($shaArray); - $temp = array( - 'title' => $updateTitle, - 'ring' => $ring, - 'flight' => $flight, - 'arch' => $arch, - 'build' => $foundBuild, - 'checkBuild' => $build, - 'files' => $shaArray, - ); + $temp = array(); + $temp['title'] = $updateTitle; + $temp['ring'] = $ring; + $temp['flight'] = $flight; + $temp['arch'] = $arch; + $temp['build'] = $foundBuild; + $temp['checkBuild'] = $build; + + if(preg_match('/Cumulative Update/', $updateTitle)) { + $temp['containsCU'] = 1; + } + + $temp['files'] = $shaArray; consoleLogger('Successfully parsed the information.'); consoleLogger('Writing new build information to the disk...'); diff --git a/get.php b/get.php index c556357..a27f0ae 100644 --- a/get.php +++ b/get.php @@ -45,12 +45,12 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac } } - if($desiredEdition) { + $desiredEdition = strtoupper($desiredEdition); + if($desiredEdition && $desiredEdition != 'UPDATEONLY') { if(!$usePack) { return array('error' => 'UNSPECIFIED_LANG'); } - $desiredEdition = strtoupper($desiredEdition); if(!isset($editionPacks[$desiredEdition])) { return array('error' => 'UNSUPPORTED_EDITION'); } @@ -78,6 +78,12 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $info = json_decode($info, true); } + if($desiredEdition == 'UPDATEONLY') { + if(!isset($info['containsCU']) || !$info['containsCU']) { + return array('error' => 'NOT_CUMULATIVE_UPDATE'); + } + } + $uupFix = 0; if(isset($info['needsFix'])) { if($info['needsFix'] == true) $uupFix = 1; @@ -150,8 +156,10 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $files = array_merge($files, array($name => $temp)); } } else { - $name = preg_replace('/\.psf$/', '', $name); - $removeFiles = array_merge($removeFiles, array($name)); + if(!preg_match('/^Windows10\.0-KB/', $name)) { + $name = preg_replace('/\.psf$/', '', $name); + $removeFiles = array_merge($removeFiles, array($name)); + } } } @@ -176,8 +184,22 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $filesKeys = array_keys($files); } - if($usePack) { + if($desiredEdition == 'UPDATEONLY') { + $removeFiles = preg_grep('/Windows10\.0-KB.*-EXPRESS/i', $filesKeys); + + foreach($removeFiles as $val) { + if(isset($files[$val])) unset($files[$val]); + } + + unset($removeFiles, $temp); + $filesKeys = array_keys($files); + + $filesKeys = preg_grep('/Windows10\.0-KB/i', $filesKeys); + } + + if($usePack && $desiredEdition != 'UPDATEONLY') { $removeFiles = preg_grep('/RetailDemo-OfflineContent/i', $filesKeys); + $removeFiles = preg_grep('/Windows10\.0-KB.*-EXPRESS/i', $filesKeys); foreach($removeFiles as $val) { if(isset($files[$val])) unset($files[$val]); diff --git a/shared/main.php b/shared/main.php index c162661..84ca855 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,12 +16,12 @@ limitations under the License. */ function uupApiVersion() { - return '1.2.1'; + return '1.3.0'; } function uupApiPrintBrand() { global $uupApiBrandPrinted; - + if(!isset($uupApiBrandPrinted)) { consoleLogger('UUP dump API v'.uupApiVersion()); $uupApiBrandPrinted = 1; diff --git a/shared/packs.php b/shared/packs.php index 39a136c..b8d12e8 100644 --- a/shared/packs.php +++ b/shared/packs.php @@ -37,6 +37,7 @@ $packs = array( 'Microsoft-Windows-Hello-Face-Resource-A-Package', 'Microsoft-Windows-Hello-Face-Resource-B-Package', 'Microsoft-OneCore-ApplicationModel-Sync-Desktop-FOD-Package', + 'Windows10\.0-KB', ), 'CLOUD' => array( 'Microsoft-Windows-EditionPack-Professional-Package',