Deprecate old packs system and replace it with internal generated packs
This commit is contained in:
1 parent
888cc470cb
commit
d1911c2424
54 files changed
+224
-254
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright 2018 UUP dump API authors
|
||||
Copyright 2019 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.
|
||||
@@ -16,7 +16,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
function uupApiVersion() {
|
||||
return '1.17.3';
|
||||
return '1.18.0';
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__).'/auths.php';
|
||||
|
||||
+166
-26
@@ -15,7 +15,9 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
function uupGetPacks($build = 15063) {
|
||||
require_once dirname(__FILE__).'/../listid.php';
|
||||
|
||||
function uupGetInfoTexts() {
|
||||
$fancyLangNames = array(
|
||||
'ar-sa' => 'Arabic (Saudi Arabia)',
|
||||
'bg-bg' => 'Bulgarian',
|
||||
@@ -61,7 +63,7 @@ function uupGetPacks($build = 15063) {
|
||||
$fancyEditionNames = array(
|
||||
'CLOUD' => 'Windows 10 S',
|
||||
'CLOUDN' => 'Windows 10 S N',
|
||||
'CLOUDE' => 'Windows 10 CloudE',
|
||||
'CLOUDE' => 'Windows 10 Lean',
|
||||
'CORE' => 'Windows 10 Home',
|
||||
'CORECOUNTRYSPECIFIC' => 'Windows 10 Home China',
|
||||
'COREN' => 'Windows 10 Home N',
|
||||
@@ -165,33 +167,171 @@ function uupGetPacks($build = 15063) {
|
||||
'STARTERN',
|
||||
);
|
||||
|
||||
if($build < 17063) {
|
||||
require dirname(__FILE__).'/packs/legacy.php';
|
||||
} elseif ($build >= 17661) {
|
||||
require dirname(__FILE__).'/packs/17661.php';
|
||||
} elseif ($build >= 17655) {
|
||||
require dirname(__FILE__).'/packs/17655.php';
|
||||
} elseif ($build >= 17650) {
|
||||
require dirname(__FILE__).'/packs/17650.php';
|
||||
} elseif ($build >= 17634) {
|
||||
require dirname(__FILE__).'/packs/17634.php';
|
||||
} elseif ($build >= 17623) {
|
||||
require dirname(__FILE__).'/packs/17623.php';
|
||||
} elseif ($build >= 17093) {
|
||||
require dirname(__FILE__).'/packs/17093.php';
|
||||
} elseif ($build >= 17063) {
|
||||
require dirname(__FILE__).'/packs/17063.php';
|
||||
}
|
||||
|
||||
return array(
|
||||
'packs' => $packs,
|
||||
'packsForLangs' => $packsForLangs,
|
||||
'editionPacks' => $editionPacks,
|
||||
'fancyEditionNames' => $fancyEditionNames,
|
||||
'fancyLangNames' => $fancyLangNames,
|
||||
'allEditions' => $allEditions,
|
||||
'skipNeutral' => $skipNeutral,
|
||||
'skipLangPack' => $skipLangPack,
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
function uupGetGenPacks($build = 15063, $arch = null, $updateId = null) {
|
||||
$internalPacks = dirname(__FILE__).'/packs';
|
||||
|
||||
if(!file_exists($internalPacks.'/metadata.json')) {
|
||||
if(!uupCreateInternalPacksMetadata($internalPacks)) {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($updateId)) {
|
||||
if(file_exists('packs/'.$updateId.'.json.gz')) {
|
||||
$genPack = @gzdecode(@file_get_contents('packs/'.$updateId.'.json.gz'));
|
||||
if(empty($genPack)) return array();
|
||||
|
||||
$genPack = json_decode($genPack, 1);
|
||||
return $genPack;
|
||||
}
|
||||
}
|
||||
|
||||
$metadata = @file_get_contents($internalPacks.'/metadata.json');
|
||||
if(empty($metadata)) {
|
||||
return array();
|
||||
} else {
|
||||
$metadata = json_decode($metadata, 1);
|
||||
}
|
||||
|
||||
$hashDetermined = 0;
|
||||
$useAllHashesForBuild = 0;
|
||||
|
||||
if($updateId) {
|
||||
if(isset($metadata['knownIds'][$updateId])) {
|
||||
$hash = $metadata['knownIds'][$updateId];
|
||||
$hashDetermined = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$hashDetermined) {
|
||||
foreach($metadata['knownBuilds'] as $buildNum => $val) {
|
||||
if($build < $buildNum) continue;
|
||||
$useBuild = $buildNum;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!isset($useBuild)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if(!$arch && !isset($metadata['knownBuilds'][$useBuild][$arch])) {
|
||||
$genPack = array();
|
||||
foreach($metadata['knownBuilds'][$useBuild] as $hash) {
|
||||
$temp = @gzdecode(@file_get_contents($internalPacks.'/'.$hash.'.json.gz'));
|
||||
if(!empty($temp)) {
|
||||
$temp = json_decode($temp, 1);
|
||||
$genPack = array_merge_recursive($genPack, $temp);
|
||||
unset($temp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$hash = $metadata['knownBuilds'][$useBuild][$arch];
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($genPack)) {
|
||||
$genPack = @gzdecode(@file_get_contents($internalPacks.'/'.$hash.'.json.gz'));
|
||||
if(!empty($genPack)) {
|
||||
$genPack = json_decode($genPack, 1);
|
||||
} else {
|
||||
$genPack = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $genPack;
|
||||
}
|
||||
|
||||
//Function to regenerate internal packs. Should not be used when not needed.
|
||||
function uupCreateInternalPacksMetadata($internalPacks) {
|
||||
$metadataCreationAllowed = 0;
|
||||
if(!$metadataCreationAllowed) return false;
|
||||
|
||||
$builds = uupListIds();
|
||||
if(isset($ids['error'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$builds = $builds['builds'];
|
||||
|
||||
if(!file_exists('packs')) return false;
|
||||
|
||||
if(!file_exists($internalPacks)) {
|
||||
if(!mkdir($internalPacks)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
rmdir($internalPacks);
|
||||
mkdir($internalPacks);
|
||||
}
|
||||
|
||||
$files = scandir('packs');
|
||||
$files = preg_grep('/\.json.gz$/', $files);
|
||||
|
||||
$packs = array();
|
||||
foreach($builds as $build) {
|
||||
$uuid = $build['uuid'];
|
||||
$file = $uuid.'.json.gz';
|
||||
|
||||
if(!file_exists('packs/'.$file)) continue;
|
||||
|
||||
$genPack = @gzdecode(@file_get_contents('packs/'.$file));
|
||||
$hash = hash('sha1', $genPack);
|
||||
|
||||
if(!file_exists($internalPacks.'/'.$hash.'.json.gz')) {
|
||||
if(!copy('packs/'.$file, $internalPacks.'/'.$hash.'.json.gz')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$packs['knownIds'][$uuid] = $hash;
|
||||
|
||||
$buildNum = explode('.', $build['build']);
|
||||
$buildNum = $buildNum[0];
|
||||
|
||||
$packs['knownBuilds'][$buildNum][$build['arch']] = $hash;
|
||||
}
|
||||
|
||||
file_put_contents($internalPacks.'/metadata.json', json_encode($packs)."\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Emulation of legacy packs. Do not use in new scripts due to extremely slow process.
|
||||
function uupGetPacks($build = 15063) {
|
||||
$returnArray = uupGetInfoTexts();
|
||||
$genPack = uupGetGenPacks($build);
|
||||
|
||||
foreach($genPack as $lang => $editions) {
|
||||
$packsForLangs[$lang] = array_keys($editions);
|
||||
$packsForLangs[$lang][] = $lang;
|
||||
|
||||
foreach(array_keys($editions) as $edition) {
|
||||
foreach($editions[$edition] as $name) {
|
||||
$newName = preg_replace('/^cabs_|^metadataesd_|~31bf3856ad364e35/i', '', $name);
|
||||
$newName = preg_replace('/~~\.|~\./', '.', $newName);
|
||||
$newName = preg_replace('/~/', '-', $newName);
|
||||
$newName = strtolower($newName);
|
||||
$packs[$lang][$edition][] = $newName;
|
||||
}
|
||||
|
||||
$editionPacks[$edition] = $edition;
|
||||
$packs[$edition][$edition] = array();
|
||||
$skipNeutral[$edition] = 1;
|
||||
$skipLangPack[$edition] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$returnArray['packs'] = $packs;
|
||||
$returnArray['packsForLangs'] = $packsForLangs;
|
||||
$returnArray['editionPacks'] = $editionPacks;
|
||||
$returnArray['skipNeutral'] = $skipNeutral;
|
||||
$returnArray['skipLangPack'] = $skipLangPack;
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"knownIds":{"07bad6fe-06da-4452-bd62-1d0eae0e63f4":"ce78d1195e98375737eb4782e02f105eefc23ed2","6d042185-6e5d-4d3a-acc9-c4f3931405d7":"22c7a1aca5e636221131e8ffbd95539d1be9076c","c0f6df87-d718-4126-b581-32c27e21768f":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","f48384f3-003d-44b9-842d-1b3531838632":"ce78d1195e98375737eb4782e02f105eefc23ed2","d875d801-3a38-4050-92c5-06549e67d417":"ce78d1195e98375737eb4782e02f105eefc23ed2","f87ec3a7-9b42-4084-9b89-eb158a746bc2":"22c7a1aca5e636221131e8ffbd95539d1be9076c","511b4bb0-36b4-4ae6-980f-4ba540afb6b1":"22c7a1aca5e636221131e8ffbd95539d1be9076c","c4ce5f54-0671-4627-abd4-14d23d69d303":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","35a14623-6419-429f-a23e-d58a2df834a7":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","4344ad18-1824-46c2-b061-a6bde442f9e0":"ce78d1195e98375737eb4782e02f105eefc23ed2","99a031f7-e355-4035-824f-dfa7c123007d":"22c7a1aca5e636221131e8ffbd95539d1be9076c","bbce38ca-984d-48be-9ecc-d711b4d782f3":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","c8a1fff6-b54d-4612-8a5d-9f998e49e7f9":"ce78d1195e98375737eb4782e02f105eefc23ed2","18dc4f14-e80c-45bd-a5fe-59dc535a2b70":"22c7a1aca5e636221131e8ffbd95539d1be9076c","f5848825-1661-45b6-90ff-34d06493936d":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","e7a79b40-4a05-4a5d-bc10-ae0893d3d72e":"ce78d1195e98375737eb4782e02f105eefc23ed2","ef0cc27c-aa0e-49f3-9986-0283c2b9aa58":"22c7a1aca5e636221131e8ffbd95539d1be9076c","c2788266-0f68-4946-8e57-bb76f14efbf7":"c054f6ca03936fe8c9a24118309d1576b6cb9cc5","336eb3e4-088d-4655-9001-ed63af038fe9":"f71509579ac540dc9a42e9d058362d81d619db11","8dbf6c34-f2d2-4897-b427-3224c67baf4f":"2301e6f354ec0ef46adea9515efc656be62eef91","04f7fd70-7c36-44a1-8706-5453cd3e5957":"554a82fd55becdef5a05cd1cdaf890f3d19811c9","eb41ff55-18a0-4697-ac5f-130b5e61e990":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","11d565a1-dd13-4c93-8b82-77632904472d":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","a88a172b-fda0-41d5-ae37-739e55398212":"7a93eee07bdd8b747563b8d8eac58af40d3c60a8","457dca69-1db7-447f-9954-a302c8c429ca":"7a93eee07bdd8b747563b8d8eac58af40d3c60a8","b73a7c32-cc13-4c67-bb7c-15ae8ca91359":"f549c78f06373a8153f0774bdd547682fb0f5750","179ab677-e69c-4f0d-ad35-f7aa2893d97d":"f549c78f06373a8153f0774bdd547682fb0f5750","97203804-e2ab-4bf7-a0c8-4ed30364fed4":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","34a57fad-0160-4c8d-a761-30bf8b7e8687":"7a93eee07bdd8b747563b8d8eac58af40d3c60a8","08864bfd-6519-4baf-8d4c-eb4fe3c6a9b0":"f549c78f06373a8153f0774bdd547682fb0f5750","819f5a8e-0107-4494-8b9b-99ebd0cb0acb":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","4bc0b3e6-9560-4426-840a-6f8e3fcaffb5":"aba27664fd4185b6e5332444629f56e0d40a913e","a674ea13-7440-4672-bf03-e001383ea0b7":"f549c78f06373a8153f0774bdd547682fb0f5750","a98df484-7ad4-4106-9d41-b90ac66d9ebf":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","3807d0a6-dd31-47c1-9925-2dfdc5f0608d":"7a93eee07bdd8b747563b8d8eac58af40d3c60a8","2e3b8472-af57-4e1f-8dfa-65dde0c64458":"f549c78f06373a8153f0774bdd547682fb0f5750","9e0e0f20-6bb5-413b-8a99-850ee78692de":"8236e50d00b40cfa7fdca5ec3b60ec603e852a26","325e6f92-b648-4345-bb0c-263d4d300bad":"acb1facaf6b1a1da2a3bfe0409402c22120b74a6","76c7f20c-6d90-4e5a-9b5e-cdb48c70f9b4":"f549c78f06373a8153f0774bdd547682fb0f5750","b4659c07-4e9e-41f6-8283-373314ac1e01":"1013af5eb771adf320b8834e305fcef90099cfd6","32267b54-4a90-4b37-a1f9-120701dfcc93":"acb1facaf6b1a1da2a3bfe0409402c22120b74a6","abf1ceea-5d5b-4db9-aadf-89455af7863f":"f549c78f06373a8153f0774bdd547682fb0f5750","989dd610-0019-413f-a633-8447b9362164":"f71509579ac540dc9a42e9d058362d81d619db11","74ee9ff3-f336-419d-808d-44e884cb226a":"cd0d4cc32346750408f7d4f5e78ec9a6e5b79a0d","a5f5f069-69bc-42d5-a66e-0d5e06fd030f":"554a82fd55becdef5a05cd1cdaf890f3d19811c9","e4c6b03a-fb32-41c3-a6e4-3529498a84d3":"f71509579ac540dc9a42e9d058362d81d619db11","7edcc686-2b6d-4112-9107-d3f8a3f55220":"329e33732b38a3456df0631792c635c521f60341","d9b2eddb-1e76-4f80-b927-ed0b884e3c98":"554a82fd55becdef5a05cd1cdaf890f3d19811c9","2208459c-831a-4313-addc-b30c6e396384":"487d7e8509f9e1f788706f9f8cf1ac0067941f51","b04edebb-d0a3-4180-ac60-2cd7892b546d":"c9b0e97f010deeb941d5f8680d8737404481c313","2d56edb7-b215-498a-839e-fd307b778837":"c771f8b4535ea6e73c5d7406252d7306c0e11b56","23640b4d-cd89-4f65-af3a-3628fd976028":"487d7e8509f9e1f788706f9f8cf1ac0067941f51","34abbc89-f4ec-4106-9151-2a37d87a862b":"c9b0e97f010deeb941d5f8680d8737404481c313","c53448f3-0fc7-4601-ba45-38e85718963c":"c771f8b4535ea6e73c5d7406252d7306c0e11b56","c57f59c0-191c-43ce-a333-fc08697262be":"487d7e8509f9e1f788706f9f8cf1ac0067941f51","39921b92-3e94-4d78-b20c-004d1de349e2":"c9b0e97f010deeb941d5f8680d8737404481c313","234f26bd-07a0-484c-a9dc-fcac05a12a21":"c771f8b4535ea6e73c5d7406252d7306c0e11b56","5d6314ec-c1bc-41f0-a3f9-f2ccf9ea6868":"487d7e8509f9e1f788706f9f8cf1ac0067941f51","56dcc875-02e5-4d3f-b28d-5ab4ae897353":"487d7e8509f9e1f788706f9f8cf1ac0067941f51","2903ac87-bb9e-45d7-8517-7f61721fc882":"c9b0e97f010deeb941d5f8680d8737404481c313","ebf449e5-f320-430e-859e-fd5e7fbbe969":"c9b0e97f010deeb941d5f8680dLine truncated
|
||||
Reference in new issue
Block a user