MagiskOnWSA Download and Version Discovery
Overview
This flow resolves the external packages that a MagiskOnWSA build needs before the build can assemble WSA with root and optional Google apps. The covered scripts all append aria2-style download entries to a caller-provided temporary download list: each selected URL is written followed by dir=<download_dir> and out=<file_name>, so downstream build steps can fetch the files into the shared download directory without rediscovering them. The scripts are normally invoked from the MagiskOnWSA/scripts working directory; when the download directory argument is empty they write to MagiskOnWSA/download via Path.cwd().parent / "download".
Path map for this discovery area:
- MagiskOnWSA/…/generateWSALinks.py resolves Microsoft Store/Windows Update links for the WSA msixbundle plus architecture-specific Microsoft UI Xaml and VCLibs dependencies.
- MagiskOnWSA/…/generateMagiskLink.py resolves the selected Magisk channel zip and the
cust.imgadd-on asset from the latestLSPosed/WSA-AddonGitHub release. - MagiskOnWSA/…/generateKernelSULink.py resolves a KernelSU WSA kernel zip from the fixed
tiann/KernelSUrelease tag and records the release name into the environment file named byWSA_WORK_ENV. - MagiskOnWSA/…/generateGappsLink.py resolves GApps
.rcand architecture-specific.imgassets from the latestLSPosed/WSA-AddonGitHub release. - MagiskOnWSA/…/WSAUpdateChecker.py is the scheduled/update-check side of the same discovery logic: it compares current tracked appversion files with live WSA, Magisk, and MindTheGapps versions, then sets GitHub Actions environment variables when a rebuild should be triggered.
- MagiskOnWSA/…/GetCookie.xml, MagiskOnWSA/…/WUIDRequest.xml, and MagiskOnWSA/…/FE3FileUrl.xml are SOAP request templates used by the WSA discovery and WSA update-check paths. MagiskOnWSA/…/priconfig.xml is a PRI resource indexing config in the same XML area, but it is not read by these Python discovery scripts.
MagiskOnWSA/…/generateWSALinks.py accepts arch, release_type, download_dir, tempScript, and optional skip_wsa_download arguments. It maps release types (retail, RP, WIS, WIF) to display names for logging, reads an optional Microsoft account user_code from <download_dir>/.ms_account, and uses the hard-coded Microsoft Store category id 858014f3-3934-4abe-8078-4aa193e74ca8. It posts MagiskOnWSA/…/GetCookie.xml to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx, extracts the returned EncryptedData, then posts MagiskOnWSA/…/WUIDRequest.xml with {user, cookie, category id, release_type} to the same endpoint. The response is parsed for ExtendedUpdateInfo/Updates/Update file metadata and NewUpdates/UpdateInfo update identities. For every matching file identity, the script can request a secured file URL by posting MagiskOnWSA/…/FE3FileUrl.xml to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured with {user, UpdateID, RevisionNumber, release_type}.
The WSA script selects only the latest MicrosoftCorporationII.WindowsSubsystemForAndroid_*.msixbundle build by parsing dotted build versions from filenames and comparing them with packaging.version. It writes that bundle as wsa-<release_type>.zip unless skip_wsa_download is set. It also includes matching Microsoft.UI.Xaml..._<arch>_*.appx, Microsoft.VCLibs...UWPDesktop..._<arch>_*.appx, and Microsoft.VCLibs..._<arch>_*.appx dependencies, naming those outputs from the package identity plus architecture. URL resolution for these selected identities is threaded; each successful FileLocation/Url whose text length is not 99 is appended to the shared temp script.
MagiskOnWSA/…/generateMagiskLink.py accepts magisk_ver, download_dir, and tempScript. Empty magisk_ver defaults to stable; stable, beta, canary, and debug are resolved by downloading https://github.com/topjohnwu/magisk-files/raw/master/<channel>.json and reading magisk.link, falling back to https://fastly.jsdelivr.net/gh/topjohnwu/magisk-files@master/<channel>.json on exception. Output names are magisk-<channel>.zip. The same script also calls https://api.github.com/repos/LSPosed/WSA-Addon/releases/latest and appends the first asset whose name matches cust.img. If a token file exists in the current working directory, it is used as a GitHub bearer token for that WSA-Addon request.
MagiskOnWSA/…/generateKernelSULink.py accepts arch, download_dir, tempScript, kernelVersion, and final file_name. It maps x64 to x86_64 and arm64 to arm64, then queries https://api.github.com/repos/tiann/KernelSU/releases/tags/v2.1.2. Among zip assets matching kernel-WSA-<abi>-<kernelVersion>*.zip, it extracts the version embedded in the asset name, keeps the highest one with packaging.version, then appends that asset URL using the caller-provided output filename. It also reads and rewrites the properties file at os.environ['WSA_WORK_ENV'], setting KERNELSU_VER to the GitHub release name.
MagiskOnWSA/…/generateGappsLink.py accepts arch, download_dir, tempScript, android_api, and file_name, although the final argument is not used for the output name. It maps WSA architectures to release asset ABI names and maps Android API 30, 32, and 33 to GApps release strings 11.0, 12.1, and 13.0. It queries the latest LSPosed/WSA-Addon GitHub release, optionally authenticated by a local token file, and appends all assets matching either gapps.*<release>.*.rc or gapps.*<release>.*<abi>.*.img. The download output names remain the asset names from the release.
MagiskOnWSA/…/WSAUpdateChecker.py checks whether a GitHub Actions update branch should be refreshed. It reads GITHUB_ENV for writing workflow outputs and API_KEY for GitHub API authorization. For WSA, WSAChecker() uses the same Microsoft FE3 category id and the same MagiskOnWSA/…/GetCookie.xml and MagiskOnWSA/…/WUIDRequest.xml SOAP templates as generateWSALinks.py, but only parses the highest WSA msixbundle version; it does not request file URLs through FE3FileUrl.xml. It compares that live version against https://raw.githubusercontent.com/YT-Advanced/WSA-Script/update/<release_type>.appversion, writes the current value to ../<release_type>.appversion, and when a newer live version exists it checks out or creates the update branch, replaces the appversion file, and appends SHOULD_BUILD=yes, RELEASE_TYPE=<release_type>, and a human-readable MSG to GITHUB_ENV.
The same update checker handles Magisk and GApps via MagiskandGappsChecker(). For Magisk it compares the tracked magisk.appversion against magisk.version in https://github.com/topjohnwu/magisk-files/raw/master/stable.json. For GApps it compares gapps.appversion against the latest release name from https://api.github.com/repos/YT-Advanced/MindTheGappsBuilder/releases/latest. The checker first tries WSA stable without a user token, then Magisk, then MindTheGapps; if it can fetch a Microsoft account token from https://api.github.com/repos/bubbles-wow/MS-Account-Token/contents/token.cfg, it also checks WSA Insider Fast (WIF) with that user_code.
Coupling
- If MagiskOnWSA/…/GetCookie.xml, MagiskOnWSA/…/WUIDRequest.xml, or MagiskOnWSA/…/FE3FileUrl.xml changes placeholder order, update both MagiskOnWSA/…/generateWSALinks.py and MagiskOnWSA/…/WSAUpdateChecker.py call sites. They use positional
str.format(...), so a template placeholder reorder silently sends the wronguser, cookie, update id, revision, category id, or flight ring. - If WSA package naming changes in Microsoft FE3 responses, update the regexes in both MagiskOnWSA/…/generateWSALinks.py and MagiskOnWSA/…/WSAUpdateChecker.py. Both scripts infer the latest WSA build from
MicrosoftCorporationII.WindowsSubsystemForAndroid_*.msixbundlefilenames rather than from a typed API field. - If build tooling changes the temporary download-list format, update all four link generators: MagiskOnWSA/…/generateWSALinks.py, MagiskOnWSA/…/generateMagiskLink.py, MagiskOnWSA/…/generateKernelSULink.py, and MagiskOnWSA/…/generateGappsLink.py all append the same three-line aria2 entry shape.
- If GitHub authentication behavior changes, check both MagiskOnWSA/…/generateMagiskLink.py and MagiskOnWSA/…/generateGappsLink.py. They look for a plain
tokenfile in the current working directory, while MagiskOnWSA/…/WSAUpdateChecker.py readsAPI_KEYfrom the environment. - If KernelSU versioning or release location changes, update MagiskOnWSA/…/generateKernelSULink.py together with any build step that consumes
KERNELSU_VERfromWSA_WORK_ENV; the link generator currently hard-codes the upstream release tagv2.1.2and only updates the environment file after finding a matching asset.
Risks
- MagiskOnWSA/…/generateWSALinks.py and MagiskOnWSA/…/WSAUpdateChecker.py disable TLS verification on their Microsoft FE3
requests.Sessioninstances. If FE3 responses are intercepted or malformed, the scripts can write incorrect WSA download URLs or trigger a false update without certificate validation stopping the run. - MagiskOnWSA/…/generateWSALinks.py filters
FileLocation/Urlvalues by checkinglen(url) != 99. If Microsoft changes the shape or length of placeholder/error URLs, the script may accept an unusable URL or discard a valid WSA dependency URL. - MagiskOnWSA/…/generateKernelSULink.py assumes the GitHub API response for
tiann/KernelSUincludesx-ratelimit-remainingand that matching asset names contain a parseable dotted version inasset_name.split("-")[3]. A GitHub error shape or asset naming change can raise before the explicit “No KernelSU release found” path and leave the download list incomplete. - MagiskOnWSA/…/WSAUpdateChecker.py mutates
../<type>.appversionbefore it knows whether a newer version exists and shells out togit checkout -f update || git switch --discard-changes --orphan updateafter detecting a change. If the working directory layout or branch policy changes, this update check can overwrite the wrong relative file or discard pending changes in the workflow checkout.