From bbfc3c2d290273fe9d3f0407799a5d845ea50036 Mon Sep 17 00:00:00 2001 From: Howard Wu Date: Tue, 11 Apr 2023 00:43:27 +0800 Subject: [PATCH] Refine WSA download links generate Refine dependencies install --- installer/Install.ps1 | 17 ++++----- scripts/build.sh | 8 +++-- scripts/generateWSALinks.py | 72 +++++++++++++++++++++---------------- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/installer/Install.ps1 b/installer/Install.ps1 index dca2155..3d501b9 100644 --- a/installer/Install.ps1 +++ b/installer/Install.ps1 @@ -101,20 +101,17 @@ If ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform'). [xml]$Xml = Get-Content ".\AppxManifest.xml"; $Name = $Xml.Package.Identity.Name; +Write-Host "Installing $Name version: $($Xml.Package.Identity.Version)" $ProcessorArchitecture = $Xml.Package.Identity.ProcessorArchitecture; $Dependencies = $Xml.Package.Dependencies.PackageDependency; $Dependencies | ForEach-Object { - If ($_.Name -Eq "Microsoft.VCLibs.140.00.UWPDesktop") { - $HighestInstalledVCLibsVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture; - If ( $HighestInstalledVCLibsVersion -Lt $_.MinVersion ) { - Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "Microsoft.VCLibs.$ProcessorArchitecture.14.00.Desktop.appx" - } + $InstalledVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture; + If ( $InstalledVersion -Lt $_.MinVersion ) { + Write-Host "Dependency package $($_.Name) $ProcessorArchitecture required minimum version: $($_.MinVersion). Installing...." + Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "$($_.Name)_$ProcessorArchitecture.appx" } - ElseIf ($_.Name -Match "Microsoft.UI.Xaml") { - $HighestInstalledXamlVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture; - If ( $HighestInstalledXamlVersion -Lt $_.MinVersion ) { - Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "Microsoft.UI.Xaml_$ProcessorArchitecture.appx" - } + Else { + Write-Host "Dependency package $($_.Name) $ProcessorArchitecture current version: $InstalledVersion. Nothing to do." } } diff --git a/scripts/build.sh b/scripts/build.sh index d0c7de6..60581db 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -372,8 +372,9 @@ RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort echo -e "Build: RELEASE_TYPE=$RELEASE_NAME" WSA_ZIP_PATH=$DOWNLOAD_DIR/wsa-$RELEASE_TYPE.zip -vclibs_PATH="$DOWNLOAD_DIR/Microsoft.VCLibs.$ARCH.14.00.Desktop.appx" -xaml_PATH="$DOWNLOAD_DIR/Microsoft.UI.Xaml_$ARCH.appx" +vclibs_PATH="$DOWNLOAD_DIR/Microsoft.VCLibs.140.00_$ARCH.appx" +UWPVCLibs_PATH="$DOWNLOAD_DIR/Microsoft.VCLibs.140.00.UWPDesktop_$ARCH.appx" +xaml_PATH="$DOWNLOAD_DIR/Microsoft.UI.Xaml.2.8_$ARCH.appx" MAGISK_ZIP=magisk-$MAGISK_VER.zip MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP KERNEL_VER="5.10.117.2" # TODO: Get from kernel @@ -444,7 +445,7 @@ else # Offline mode ANDROID_API=32 update_gapps_zip_name fi - declare -A FILES_CHECK_LIST=([WSA_ZIP_PATH]="$WSA_ZIP_PATH" [xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH") + declare -A FILES_CHECK_LIST=([WSA_ZIP_PATH]="$WSA_ZIP_PATH" [xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH") if [ "$GAPPS_BRAND" != "none" ] || [ "$ROOT_SOL" = "magisk" ]; then FILES_CHECK_LIST+=(["MAGISK_PATH"]="$MAGISK_PATH") fi @@ -833,6 +834,7 @@ fi echo "Remove signature and add scripts" $SUDO rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR/wsa/$ARCH/AppxBlockMap.xml" "$WORK_DIR/wsa/$ARCH/AppxSignature.p7x" "$WORK_DIR/wsa/$ARCH/AppxMetadata" || abort cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort +cp "$UWPVCLibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort cp "../bin/$ARCH/makepri.exe" "$WORK_DIR/wsa/$ARCH" || abort cp "../xml/priconfig.xml" "$WORK_DIR/wsa/$ARCH/xml/" || abort cp ../installer/MakePri.ps1 "$WORK_DIR/wsa/$ARCH" || abort diff --git a/scripts/generateWSALinks.py b/scripts/generateWSALinks.py index fcd65a1..f378cfe 100644 --- a/scripts/generateWSALinks.py +++ b/scripts/generateWSALinks.py @@ -64,7 +64,7 @@ if ms_account_conf.is_file(): with open(ms_account_conf, "r") as f: conf = Prop(f.read()) user = conf.get('user_code') -print(f"Generating WSA download link: arch={arch} release_type={release_name}", flush=True) +print(f"Generating WSA download link: arch={arch} release_type={release_name}\n", flush=True) with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f: cookie_content = f.read().format(user) @@ -88,26 +88,36 @@ out = session.post( doc = minidom.parseString(html.unescape(out.text)) filenames = {} -for node in doc.getElementsByTagName('Files'): - filenames[node.parentNode.parentNode.getElementsByTagName( - 'ID')[0].firstChild.nodeValue] = f"{node.firstChild.attributes['InstallerSpecificIdentifier'].value}_{node.firstChild.attributes['FileName'].value}" - pass +for node in doc.getElementsByTagName('ExtendedUpdateInfo')[0].getElementsByTagName('Updates')[0].getElementsByTagName('Update'): + node_xml = node.getElementsByTagName('Xml')[0] + node_files = node_xml.getElementsByTagName('Files') + if not node_files: + continue + else: + for node_file in node_files[0].getElementsByTagName('File'): + if node_file.hasAttribute('InstallerSpecificIdentifier') and node_file.hasAttribute('FileName'): + filenames[node.getElementsByTagName('ID')[0].firstChild.nodeValue] = (f"{node_file.attributes['InstallerSpecificIdentifier'].value}_{node_file.attributes['FileName'].value}", + node_xml.getElementsByTagName('ExtendedProperties')[0].attributes['PackageIdentityName'].value) -identities = [] -for node in doc.getElementsByTagName('SecuredFragment'): - filename = filenames[node.parentNode.parentNode.parentNode.getElementsByTagName('ID')[ - 0].firstChild.nodeValue] - update_identity = node.parentNode.parentNode.firstChild - identities += [(update_identity.attributes['UpdateID'].value, - update_identity.attributes['RevisionNumber'].value, filename)] +identities = {} +for node in doc.getElementsByTagName('NewUpdates')[0].getElementsByTagName('UpdateInfo'): + node_xml = node.getElementsByTagName('Xml')[0] + if not node_xml.getElementsByTagName('SecuredFragment'): + continue + else: + id = node.getElementsByTagName('ID')[0].firstChild.nodeValue + update_identity = node_xml.getElementsByTagName('UpdateIdentity')[0] + if id in filenames: + fileinfo = filenames[id] + if fileinfo[0] not in identities: + identities[fileinfo[0]] = ([update_identity.attributes['UpdateID'].value, + update_identity.attributes['RevisionNumber'].value], fileinfo[1]) with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f: FE3_file_content = f.read() if not download_dir.is_dir(): download_dir.mkdir() -tmpdownlist = open(download_dir/tempScript, 'a') - def send_req(i, v, out_file, out_file_name): out = session.post( @@ -119,22 +129,25 @@ def send_req(i, v, out_file, out_file_name): for l in doc.getElementsByTagName("FileLocation"): url = l.getElementsByTagName("Url")[0].firstChild.nodeValue if len(url) != 99: - print(f"download link: {url} to {out_file}", flush=True) - tmpdownlist.writelines(url + '\n') - tmpdownlist.writelines(f' dir={download_dir}\n') - tmpdownlist.writelines(f' out={out_file_name}\n') - + print(f"download link: {url}\npath: {out_file}\n", flush=True) + with open(download_dir/tempScript, 'a') as tmpdownlist: + tmpdownlist.writelines(url + '\n') + tmpdownlist.writelines(f' dir={download_dir}\n') + tmpdownlist.writelines(f' out={out_file_name}\n') threads = [] -for i, v, f in identities: - if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f): - out_file_name = f"Microsoft.UI.Xaml_{arch}.appx" +for filename, values in identities.items(): + if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", filename): + out_file_name = f"{values[1]}_{arch}.appx" out_file = download_dir / out_file_name - # elif re.match(f"Microsoft\.VCLibs\..+\.UWPDesktop_.*_{arch}_.*\.appx", f): - # out_file_name = f"Microsoft.VCLibs.140.00.UWPDesktop_{arch}.appx" - # out_file = download_dir / out_file_name - elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", f): - wsa_long_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', f).group() + elif re.match(f"Microsoft\.VCLibs\..+\.UWPDesktop_.*_{arch}_.*\.appx", filename): + out_file_name = f"{values[1]}_{arch}.appx" + out_file = download_dir / out_file_name + elif re.match(f"Microsoft\.VCLibs\..+_.*_{arch}_.*\.appx", filename): + out_file_name = f"{values[1]}_{arch}.appx" + out_file = download_dir / out_file_name + elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", filename): + wsa_long_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group() print(f'WSA Version={wsa_long_ver}\n', flush=True) main_ver = wsa_long_ver.split(".")[0] with open(os.environ['WSA_WORK_ENV'], 'a') as environ_file: @@ -144,12 +157,9 @@ for i, v, f in identities: out_file = download_dir / out_file_name else: continue - th = Thread(target=send_req, args=(i, v, out_file, out_file_name)) + th = Thread(target=send_req, args=(values[0][0], values[0][1], out_file, out_file_name)) threads.append(th) th.daemon = True th.start() -tmpdownlist.writelines(f'https://aka.ms/Microsoft.VCLibs.{arch}.14.00.Desktop.appx\n') -tmpdownlist.writelines(f' dir={download_dir}\n') for th in threads: th.join() -tmpdownlist.close()