├── .gitignore ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug_report.yml ├── workflows │ ├── lock-closed-issues.yml │ ├── shellcheck.yml │ ├── lock.yml │ └── issue_moderator.yml └── pull_request_template.md ├── linker ├── aarch64 │ ├── libc.so │ ├── libm.so │ ├── libdl.so │ └── linker64 └── x86_64 │ ├── libc.so │ ├── libdl.so │ ├── libm.so │ └── linker64 ├── wine ├── aarch64 │ └── makepri.exe ├── x86_64 │ └── makepri.exe └── .cache │ └── winetricks │ └── msxml6 │ └── msxml6-KB973686-enu-amd64.exe ├── x64 ├── gapps │ └── product │ │ └── overlay │ │ └── GoogleWebViewOverlay.apk └── system │ └── system │ └── priv-app │ └── VpnDialogs │ └── VpnDialogs.apk ├── arm64 ├── gapps │ └── product │ │ └── overlay │ │ └── GoogleWebViewOverlay.apk └── system │ └── system │ └── priv-app │ └── VpnDialogs │ └── VpnDialogs.apk ├── .gitattributes ├── installer ├── Run.bat └── Install.ps1 ├── Custom-GApps.md ├── KernelSU.md ├── scripts ├── getWSAMainVersion.py ├── generateMagiskLink.py ├── extractWSA.py ├── fixGappsProp.py ├── extractMagisk.py ├── generateGappsLink.py ├── run.sh ├── install_deps.sh ├── generateWSALinks.py └── build.sh ├── xml ├── GetCookie.xml ├── FE3FileUrl.xml └── WUIDRequest.xml ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | download 2 | output 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [yujincheng08] 2 | -------------------------------------------------------------------------------- /linker/aarch64/libc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/aarch64/libc.so -------------------------------------------------------------------------------- /linker/aarch64/libm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/aarch64/libm.so -------------------------------------------------------------------------------- /linker/x86_64/libc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/x86_64/libc.so -------------------------------------------------------------------------------- /linker/x86_64/libdl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/x86_64/libdl.so -------------------------------------------------------------------------------- /linker/x86_64/libm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/x86_64/libm.so -------------------------------------------------------------------------------- /linker/x86_64/linker64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/x86_64/linker64 -------------------------------------------------------------------------------- /linker/aarch64/libdl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/aarch64/libdl.so -------------------------------------------------------------------------------- /linker/aarch64/linker64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/linker/aarch64/linker64 -------------------------------------------------------------------------------- /wine/aarch64/makepri.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/wine/aarch64/makepri.exe -------------------------------------------------------------------------------- /wine/x86_64/makepri.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/wine/x86_64/makepri.exe -------------------------------------------------------------------------------- /x64/gapps/product/overlay/GoogleWebViewOverlay.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/x64/gapps/product/overlay/GoogleWebViewOverlay.apk -------------------------------------------------------------------------------- /arm64/gapps/product/overlay/GoogleWebViewOverlay.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/arm64/gapps/product/overlay/GoogleWebViewOverlay.apk -------------------------------------------------------------------------------- /x64/system/system/priv-app/VpnDialogs/VpnDialogs.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/x64/system/system/priv-app/VpnDialogs/VpnDialogs.apk -------------------------------------------------------------------------------- /arm64/system/system/priv-app/VpnDialogs/VpnDialogs.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/arm64/system/system/priv-app/VpnDialogs/VpnDialogs.apk -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.py text eol=lf 2 | *.sh text eol=lf 3 | *.exe binary 4 | *.apk binary 5 | *.so binary 6 | *.xml text eol=crlf 7 | *.bat text eol=crlf 8 | *.ps1 text eol=crlf 9 | -------------------------------------------------------------------------------- /wine/.cache/winetricks/msxml6/msxml6-KB973686-enu-amd64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ingress007/MagiskOnWSALocal/HEAD/wine/.cache/winetricks/msxml6/msxml6-KB973686-enu-amd64.exe -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Ask a question/提问 4 | url: https://github.com/LSPosed/MagiskOnWSALocal/discussions/new?category=Q-A 5 | about: Please ask and answer questions here./如果有任何疑问请在这里提问 6 | -------------------------------------------------------------------------------- /.github/workflows/lock-closed-issues.yml: -------------------------------------------------------------------------------- 1 | name: Lock closed issue 2 | 3 | on: 4 | issues: 5 | types: [closed] 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: OSDKDev/lock-issues@v1 12 | with: 13 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 14 | -------------------------------------------------------------------------------- /installer/Run.bat: -------------------------------------------------------------------------------- 1 | :: Automated Install batch script by Syuugo 2 | 3 | @echo off 4 | if not exist Install.ps1 ( 5 | echo "Install.ps1" is not found. 6 | echo Press any key to exit 7 | pause>nul 8 | exit 1 9 | ) else ( 10 | start powershell.exe -ExecutionPolicy Bypass -File .\Install.ps1 11 | exit 12 | ) 13 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | Checklist 9 | 10 | - [ ] Referenced all related issues in the PR body (e.g. "Closes #xyz") 11 | - [ ] Have tested the modifications 12 | -------------------------------------------------------------------------------- /.github/workflows/shellcheck.yml: -------------------------------------------------------------------------------- 1 | name: Shell checker 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - '**.sh' 9 | workflow_dispatch: 10 | pull_request: 11 | 12 | permissions: {} 13 | 14 | jobs: 15 | shellcheck: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name : Checkout 19 | uses: actions/checkout@v3 20 | 21 | - name: Run ShellCheck 22 | id: check 23 | uses: ludeeus/action-shellcheck@master 24 | env: 25 | SHELLCHECK_OPTS: -e SC2086 26 | with: 27 | scandir: './scripts' 28 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: 'Lock Threads' 2 | 3 | on: 4 | issues: 5 | types: [closed] 6 | pull_request: 7 | types: [closed] 8 | workflow_dispatch: 9 | 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | 14 | concurrency: 15 | group: lock 16 | 17 | jobs: 18 | action: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: dessant/lock-threads@v4 22 | with: 23 | exclude-any-issue-labels: 'do-not-autoclose' 24 | exclude-any-pr-labels: 'do-not-autoclose' 25 | include-any-pr-labels: 'spam' 26 | -------------------------------------------------------------------------------- /Custom-GApps.md: -------------------------------------------------------------------------------- 1 | # How to install custom GApps 2 | 3 | 1. Build WSA without gapps to let the script download needed files 4 | 5 | `./build.sh --gapps-brand none` 6 | 1. 7 | - For OpenGApps 8 | 9 | Place custom OpenGApps to `download` folder and rename to `OpenGApps-{arch}-{variant}.zip` (e.g. `OpenGApps-x64-pico.zip`) 10 | - For MindTheGapps 11 | 12 | Place custom MindTheGapps to `download` folder and rename to `MindTheGapps-{arch}.zip` (e.g. `MindTheGapps-x64.zip`) 13 | 1. Build WSA offline 14 | 15 | `./build.sh --offline --gapps-brand {brand} --gapps-variant {variant}` 16 | -------------------------------------------------------------------------------- /.github/workflows/issue_moderator.yml: -------------------------------------------------------------------------------- 1 | name: Issue moderator 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | pull_request: 7 | types: [opened, edited] 8 | 9 | jobs: 10 | autoclose: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Check issue 14 | uses: tachiyomiorg/issue-moderator-action@v1 15 | with: 16 | repo-token: ${{ secrets.GITHUB_TOKEN }} 17 | auto-close-rules: | 18 | [ 19 | { 20 | "type": "title", 21 | "regex": ".*Short description.*", 22 | "message": "You did not fill out the description in the title" 23 | } 24 | ] 25 | auto-close-ignore-label: do-not-autoclose 26 | - name: Check PR 27 | uses: sumally/github-check-tasklist-action@v1 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request/新特性请求 3 | description: Suggest an idea./提出建议 4 | labels: [enhancement] 5 | title: "[Feature Request] Short description." 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: Is your feature request related to a problem?/你的请求是否与某个问题相关? 10 | placeholder: A clear and concise description of what the problem is./请清晰准确表述该问题。 11 | validations: 12 | required: true 13 | - type: textarea 14 | attributes: 15 | label: Describe the solution you'd like/描述你想要的解决方案 16 | placeholder: A clear and concise description of what you want to happen./请清晰准确描述新特性的预期行为 17 | validations: 18 | required: true 19 | - type: textarea 20 | attributes: 21 | label: Additional context/其他信息 22 | placeholder: Add any other context or screenshots about the feature request here./其他关于新特性的信息或者截图 23 | validations: 24 | required: false -------------------------------------------------------------------------------- /KernelSU.md: -------------------------------------------------------------------------------- 1 | # Install KernelSU 2 | 3 | ## Install Manager 4 | 5 | 1. Download KernelSU Manager from [![Build Manager](https://github.com/tiann/KernelSU/actions/workflows/build-manager.yml/badge.svg?event=push)](https://github.com/tiann/KernelSU/actions/workflows/build-manager.yml?query=event%3Apush+is%3Acompleted+branch%3Amain) (Download the artifact named `manager`). 6 | 7 | 1. Unzip the downloaded zip package and get the manager apk named `KernelSU_vx.x.x-xx-.....apk`. 8 | 9 | 1. Use the command `adb install .apk` to install the manager. 10 | 11 | ## Install Kernel 12 | 13 | 1. Download pre-build kernel from [![Build WSA-5.10.117-Kernel](https://github.com/tiann/KernelSU/actions/workflows/build-WSA-5.10.117-kernel.yml/badge.svg?event=push)](https://github.com/tiann/KernelSU/actions/workflows/build-WSA-5.10.117-kernel.yml?query=branch%3Amain+event%3Apush+is%3Acompleted) (Remember to download the same architecture). 14 | 15 | 1. Unzip the downloaded zip package and get the kernel file named `bzImage`. 16 | 17 | 1. Replace the kernel in the folder named `Tools` in the WSA directory with `bzImage`. 18 | 19 | 1. Restart WSA and then enjoy. 20 | -------------------------------------------------------------------------------- /scripts/getWSAMainVersion.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | import sys 22 | 23 | import zipfile 24 | from pathlib import Path 25 | 26 | arch = sys.argv[1] 27 | 28 | zip_name = "" 29 | wsa_zip_path= Path(sys.argv[2]).resolve() 30 | 31 | with zipfile.ZipFile(wsa_zip_path) as zip: 32 | for f in zip.filelist: 33 | if arch in f.filename.lower(): 34 | zip_name = f.filename 35 | ver_no = zip_name.split("_") 36 | long_ver = ver_no[1] 37 | ver = long_ver.split(".") 38 | main_ver = ver[0] 39 | print(main_ver) 40 | -------------------------------------------------------------------------------- /xml/GetCookie.xml: -------------------------------------------------------------------------------- 1 | 4 |
5 | http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetCookie 8 | urn:uuid:b9b43757-2247-4d7b-ae8f-a71ba8a22386 9 | https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx 12 | 15 | 16 | 2017-12-02T00:16:15.210Z 17 | 2017-12-29T06:25:43.943Z 18 | 19 | 22 | 23 | {} 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 2015-10-21T17:01:07.1472913Z 33 | 2017-12-02T00:16:15.217Z 34 | 1.40 35 | 36 | 37 |
-------------------------------------------------------------------------------- /scripts/generateMagiskLink.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | import sys 22 | 23 | import json 24 | import requests 25 | from pathlib import Path 26 | 27 | magisk_ver = sys.argv[1] 28 | download_dir = Path.cwd().parent / "download" if sys.argv[2] == "" else Path(sys.argv[2]).resolve() 29 | tempScript = sys.argv[3] 30 | print(f"Generating Magisk download link: release type={magisk_ver}", flush=True) 31 | if not magisk_ver: 32 | magisk_ver = "stable" 33 | if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug": 34 | try: 35 | magisk_link = json.loads(requests.get( 36 | f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_ver}.json").content)['magisk']['link'] 37 | except Exception: 38 | print("Failed to fetch from GitHub API, fallbacking to jsdelivr...") 39 | magisk_link = json.loads(requests.get( 40 | f"https://fastly.jsdelivr.net/gh/topjohnwu/magisk-files@master/{magisk_ver}.json").content)['magisk']['link'] 41 | print(f"download link: {magisk_link}", flush=True) 42 | 43 | with open(download_dir/tempScript, 'a') as f: 44 | f.writelines(f'{magisk_link}\n') 45 | f.writelines(f' dir={download_dir}\n') 46 | f.writelines(f' out=magisk-{magisk_ver}.zip\n') 47 | -------------------------------------------------------------------------------- /xml/FE3FileUrl.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo2 5 | urn:uuid:2cc99c2e-3b3e-4fb1-9e31-0cd30e6f43a0 6 | https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured 7 | 9 | 10 | 2017-08-01T00:29:01.868Z 11 | 2017-08-01T00:34:01.868Z 12 | 13 | 16 | 17 | {} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {} 27 | {} 28 | 29 | 30 | 31 | FileUrl 32 | FileDecryption 33 | 34 | BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={};AttrDataVer=21;SystemManufacturer=Microsoft Corporation;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;FlightingBranchName=external;FirmwareVersion=Hyper-V UEFI Release v2.5;SystemProductName=Virtual Machine;OSSkuId=48;FlightContent=Branch;App=WU;OEMName_Uncleaned=Microsoft Corporation;AppVer=10.0.22621.900;OSArchitecture=AMD64;SystemSKU=None;UpdateManagementGroup=2;IsFlightingEnabled=1;IsDeviceRetailDemo=0;TelemetryLevel=3;OSVersion=10.0.22621.900;DeviceFamily=Windows.Desktop; 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report/反馈 Bug 2 | description: Report errors or unexpected behavior./反馈错误或异常行为。 3 | labels: [bug] 4 | title: "[Bug] Short description." 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for reporting issues of MagiskOnWSALocal! 10 | 11 | To make it easier for us to help you please enter detailed information below. 12 | 13 | 感谢给 MagiskOnWSALocal 汇报问题! 14 | 为了使我们更好地帮助你,请提供以下信息。 15 | 为了防止重复汇报,标题请务必使用英文。 16 | - type: textarea 17 | attributes: 18 | label: Steps to reproduce/复现步骤 19 | value: | 20 | 1. 21 | 2. 22 | 3. 23 | validations: 24 | required: true 25 | - type: textarea 26 | attributes: 27 | label: Expected behaviour/预期行为 28 | placeholder: Tell us what should happen/正常情况下应该发生什么 29 | validations: 30 | required: true 31 | - type: textarea 32 | attributes: 33 | label: Actual behaviour/实际行为 34 | placeholder: Tell us what happens instead/实际上发生了什么 35 | validations: 36 | required: true 37 | - type: input 38 | attributes: 39 | label: MagiskOnWSALocal commit full SHA/MagiskOnWSALocal 提交的完整哈希 40 | description: Don't use 'latest'. Copy and paste full commit SHA, otherwise your issue will be closed./不要填用“最新”。复制并粘贴完整 commit SHA,不然 issue 会被关闭。 41 | validations: 42 | required: true 43 | - type: textarea 44 | attributes: 45 | label: Linux distribution info/Linux 发行版信息 46 | validations: 47 | required: true 48 | - type: input 49 | attributes: 50 | label: Windows version/Windows 版本 51 | placeholder: 10.0.22000.978 52 | validations: 53 | required: true 54 | - type: textarea 55 | attributes: 56 | label: Build Parameters/构建参数 57 | description: The script prints the build information each time you start a build. It looks like this, please copy and paste it./每次开始构建时脚本都会打印构建信息,它看起来是这样的,请复制并粘贴上来。 58 | placeholder: | 59 | COMMAND_LINE=--arch x64 --release-type retail --magisk-ver stable --gapps-brand MindTheGapps --gapps-variant pico --root-sol magisk 60 | INFO: Architecture: x64 61 | INFO: Release Type: retail 62 | INFO: Magisk Version: stable 63 | INFO: GApps Brand: MindTheGapps 64 | INFO: GApps Variant: pico 65 | INFO: Root Solution: magisk 66 | Build: RELEASE_TYPE=Retail 67 | validations: 68 | required: true 69 | - type: checkboxes 70 | id: latest 71 | attributes: 72 | label: Version requirement/版本要求 73 | options: 74 | - label: I am using latest commit of MagiskOnWSALocal/我正在使用最新 commit 的版本 75 | required: true 76 | - type: textarea 77 | attributes: 78 | label: Logs/日志 79 | description: Please copy and paste the error or submit a screenshot. Without log, the issue will be closed. /请复制粘贴错误或提交截图。无日志提交会被关闭。 80 | value: | 81 |
82 | 83 | ``` 84 | # Replace this line with the log / 将此行用日志替换 85 | ``` 86 |
87 | validations: 88 | required: true 89 | -------------------------------------------------------------------------------- /scripts/extractWSA.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | import sys 22 | 23 | import warnings 24 | import zipfile 25 | import os 26 | from pathlib import Path 27 | import re 28 | 29 | warnings.filterwarnings("ignore") 30 | 31 | arch = sys.argv[1] 32 | 33 | zip_name = "" 34 | wsa_zip_path= Path(sys.argv[2]).resolve() 35 | workdir = Path(sys.argv[3]) / "wsa" 36 | archdir = Path(workdir / arch) 37 | if not Path(workdir).is_dir(): 38 | workdir.mkdir() 39 | if not Path(archdir).is_dir(): 40 | archdir.mkdir() 41 | with zipfile.ZipFile(wsa_zip_path) as zip: 42 | for f in zip.filelist: 43 | if arch in f.filename.lower(): 44 | zip_name = f.filename 45 | output_name = zip_name[11:-5] 46 | if not Path(workdir / zip_name).is_file(): 47 | zip_path = workdir / zip_name 48 | print(f"unzipping to {workdir}", flush=True) 49 | zip.extract(f, workdir) 50 | ver_no = zip_name.split("_") 51 | long_ver = ver_no[1] 52 | ver = long_ver.split(".") 53 | main_ver = ver[0] 54 | rel = ver_no[3].split(".") 55 | rel_long = str(rel[0]) 56 | with open(os.environ['WSA_WORK_ENV'], 'a') as environ_file: 57 | environ_file.write(f'WSA_VER={long_ver}\n') 58 | environ_file.write(f'WSA_MAIN_VER={main_ver}\n') 59 | environ_file.write(f'WSA_REL={rel_long}\n') 60 | if 'language' in f.filename.lower() or 'scale' in f.filename.lower(): 61 | name = f.filename.split("-", 1)[1].split(".")[0] 62 | zip.extract(f, workdir) 63 | with zipfile.ZipFile(workdir / f.filename) as l: 64 | for g in l.filelist: 65 | if g.filename == 'resources.pri': 66 | g.filename = f'{name}.pri' 67 | l.extract(g, workdir / 'pri') 68 | elif g.filename == 'AppxManifest.xml': 69 | g.filename = f'{name}.xml' 70 | l.extract(g, workdir / 'xml') 71 | elif re.search(u'Images/.+\.png', g.filename): 72 | l.extract(g, archdir) 73 | with zipfile.ZipFile(zip_path) as zip: 74 | print(f"unzipping from {zip_path}", flush=True) 75 | zip.extractall(archdir) 76 | -------------------------------------------------------------------------------- /scripts/fixGappsProp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | from __future__ import annotations 22 | from io import TextIOWrapper 23 | from typing import OrderedDict 24 | from pathlib import Path 25 | import sys 26 | class Prop(OrderedDict): 27 | def __init__(self, file: TextIOWrapper) -> None: 28 | super().__init__() 29 | for i, line in enumerate(file.read().splitlines(False)): 30 | if '=' in line: 31 | k, v = line.split('=', 1) 32 | self[k] = v 33 | else: 34 | self[f".{i}"] = line 35 | 36 | def __str__(self) -> str: 37 | return '\n'.join([v if k.startswith('.') else f"{k}={v}" for k, v in self.items()]) 38 | 39 | def __iadd__(self, other: str) -> Prop: 40 | self[f".{len(self)}"] = other 41 | return self 42 | 43 | 44 | new_props = { 45 | ("product", "brand"): "google", 46 | ("product", "manufacturer"): "Google", 47 | ("build", "product"): "redfin", 48 | ("product", "name"): "redfin", 49 | ("product", "device"): "redfin", 50 | ("product", "model"): "Pixel 5", 51 | ("build", "flavor"): "redfin-user" 52 | } 53 | 54 | 55 | def description(sec: str, p: Prop) -> str: 56 | return f"{p[f'ro.{sec}.build.flavor']} {p[f'ro.{sec}.build.version.release_or_codename']} {p[f'ro.{sec}.build.id']} {p[f'ro.{sec}.build.version.incremental']} {p[f'ro.{sec}.build.tags']}" 57 | 58 | 59 | def fingerprint(sec: str, p: Prop) -> str: 60 | return f"""{p[f"ro.product.{sec}.brand"]}/{p[f"ro.product.{sec}.name"]}/{p[f"ro.product.{sec}.device"]}:{p[f"ro.{sec}.build.version.release"]}/{p[f"ro.{sec}.build.id"]}/{p[f"ro.{sec}.build.version.incremental"]}:{p[f"ro.{sec}.build.type"]}/{p[f"ro.{sec}.build.tags"]}""" 61 | 62 | 63 | def fix_prop(sec, prop): 64 | if not Path(prop).is_file(): 65 | return 66 | 67 | print(f"fixing {prop}", flush=True) 68 | with open(prop, 'r') as f: 69 | p = Prop(f) 70 | 71 | p += "# extra prop added by MagiskOnWSA" 72 | 73 | for k, v in new_props.items(): 74 | p[f"ro.{k[0]}.{k[1]}"] = v 75 | 76 | if k[0] == "build": 77 | p[f"ro.{sec}.{k[0]}.{k[1]}"] = v 78 | elif k[0] == "product": 79 | p[f"ro.{k[0]}.{sec}.{k[1]}"] = v 80 | 81 | p["ro.build.description"] = description(sec, p) 82 | p[f"ro.build.fingerprint"] = fingerprint(sec, p) 83 | p[f"ro.{sec}.build.description"] = description(sec, p) 84 | p[f"ro.{sec}.build.fingerprint"] = fingerprint(sec, p) 85 | p[f"ro.bootimage.build.fingerprint"] = fingerprint(sec, p) 86 | 87 | with open(prop, 'w') as f: 88 | f.write(str(p)) 89 | 90 | 91 | sys_path = sys.argv[1] 92 | for sec, prop in {"system": sys_path+"/system/build.prop", "product": sys_path+"/product/build.prop", "system_ext": sys_path+"/system_ext/build.prop", "vendor": sys_path+"/vendor/build.prop", "odm": sys_path+"/vendor/odm/etc/build.prop"}.items(): 93 | fix_prop(sec, prop) 94 | -------------------------------------------------------------------------------- /scripts/extractMagisk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | import sys 22 | import zipfile 23 | from pathlib import Path 24 | import platform 25 | import os 26 | from typing import OrderedDict 27 | 28 | class Prop(OrderedDict): 29 | def __init__(self, props: str=...) -> None: 30 | super().__init__() 31 | for i, line in enumerate(props.splitlines(False)): 32 | if '=' in line: 33 | k, v = line.split('=', 1) 34 | self[k] = v 35 | else: 36 | self[f".{i}"] = line 37 | 38 | def get(self, key: str) -> str: 39 | return self[key] 40 | 41 | is_x86_64 = platform.machine() in ("AMD64", "x86_64") 42 | host_abi = "x64" if is_x86_64 else "arm64" 43 | arch = sys.argv[1] 44 | magisk_zip = sys.argv[2] 45 | workdir = Path(sys.argv[3]) / "magisk" 46 | if not Path(workdir).is_dir(): 47 | workdir.mkdir() 48 | 49 | abi_map = {"x64": ["x86_64", "x86"], "arm64": ["arm64-v8a", "armeabi-v7a"]} 50 | 51 | def extract_as(zip, name, as_name, dir): 52 | info = zip.getinfo(name) 53 | info.filename = as_name 54 | zip.extract(info, workdir / dir) 55 | 56 | with zipfile.ZipFile(magisk_zip) as zip: 57 | props = Prop(zip.comment.decode().replace('\000', '\n')) 58 | versionName = props.get("version") 59 | versionCode = props.get("versionCode") 60 | print(f"Magisk version: {versionName} ({versionCode})", flush=True) 61 | with open(os.environ['WSA_WORK_ENV'], 'a') as environ_file: 62 | environ_file.write(f'MAGISK_VERSION_NAME={versionName}\n') 63 | environ_file.write(f'MAGISK_VERSION_CODE={versionCode}\n') 64 | extract_as( 65 | zip, f"lib/{ abi_map[arch][0] }/libmagisk64.so", "magisk64", "magisk") 66 | extract_as( 67 | zip, f"lib/{ abi_map[arch][1] }/libmagisk32.so", "magisk32", "magisk") 68 | standalone_policy = False 69 | try: 70 | zip.getinfo(f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so") 71 | standalone_policy = True 72 | except: 73 | pass 74 | extract_as( 75 | zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskinit", "magisk") 76 | if standalone_policy: 77 | extract_as( 78 | zip, f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so", "magiskpolicy", "magisk") 79 | else: 80 | extract_as( 81 | zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskpolicy", "magisk") 82 | extract_as( 83 | zip, f"lib/{ abi_map[arch][0] }/libmagiskboot.so", "magiskboot", "magisk") 84 | extract_as( 85 | zip, f"lib/{ abi_map[arch][0] }/libbusybox.so", "busybox", "magisk") 86 | if standalone_policy: 87 | extract_as( 88 | zip, f"lib/{ abi_map[host_abi][0] }/libmagiskpolicy.so", "magiskpolicy", ".") 89 | else: 90 | extract_as( 91 | zip, f"lib/{ abi_map[host_abi][0] }/libmagiskinit.so", "magiskpolicy", ".") 92 | extract_as(zip, f"assets/boot_patch.sh", "boot_patch.sh", "magisk") 93 | extract_as(zip, f"assets/util_functions.sh", 94 | "util_functions.sh", "magisk") 95 | -------------------------------------------------------------------------------- /scripts/generateGappsLink.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | from datetime import datetime 22 | import sys 23 | 24 | import requests 25 | import json 26 | import re 27 | from pathlib import Path 28 | 29 | arch = sys.argv[1] 30 | brand = sys.argv[2] 31 | variant = sys.argv[3] 32 | download_dir = Path.cwd().parent / \ 33 | "download" if sys.argv[4] == "" else Path(sys.argv[4]).resolve() 34 | tempScript = sys.argv[5] 35 | android_api = sys.argv[6] 36 | file_name = sys.argv[7] 37 | print(f"Generating {brand} download link: arch={arch} variant={variant}", flush=True) 38 | abi_map = {"x64": "x86_64", "arm64": "arm64"} 39 | android_api_map = {"30": "11.0", "32": "12.1", "33": "13.0"} 40 | release = android_api_map[android_api] 41 | if brand == "OpenGApps": 42 | try: 43 | res = requests.get(f"https://api.opengapps.org/list") 44 | j = json.loads(res.content) 45 | link = {i["name"]: i for i in j["archs"][abi_map[arch]] 46 | ["apis"][release]["variants"]}[variant]["zip"] 47 | DATE = j["archs"][abi_map[arch]]["date"] 48 | print(f"DATE={DATE}", flush=True) 49 | except Exception: 50 | print("Failed to fetch from OpenGApps API, fallbacking to SourceForge RSS...") 51 | res = requests.get( 52 | f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100') 53 | link = re.search(f'https://.*{abi_map[arch]}/.*{release}.*{variant}.*\.zip/download', res.text).group().replace( 54 | '.zip/download', '.zip').replace('sourceforge.net/projects/opengapps/files', 'downloads.sourceforge.net/project/opengapps') 55 | elif brand == "MindTheGapps": 56 | res = requests.get( 57 | f'https://sourceforge.net/projects/wsa-mtg/rss?path=/{abi_map[arch]}&limit=100') 58 | matched = re.search(f'https://.*{release}.*{abi_map[arch]}.*\.zip/download', res.text) 59 | if matched: 60 | link = matched.group().replace( 61 | '.zip/download', '.zip').replace('sourceforge.net/projects/wsa-mtg/files', 'downloads.sourceforge.net/project/wsa-mtg') 62 | else: 63 | print(f"Failed to fetch from SourceForge RSS, fallbacking to Github API...", flush=True) 64 | res = requests.get(f"https://api.github.com/repos/s1204IT/MindTheGappsBuilder/releases/latest") 65 | json_data = json.loads(res.content) 66 | headers = res.headers 67 | x_ratelimit_remaining = headers["x-ratelimit-remaining"] 68 | if res.status_code == 200: 69 | assets = json_data["assets"] 70 | for asset in assets: 71 | if re.match(f'.*{release}.*{abi_map[arch]}.*\.zip$', asset["name"]) and asset["content_type"] == "application/x-zip-compressed": 72 | link = asset["browser_download_url"] 73 | break 74 | elif res.status_code == 403 and x_ratelimit_remaining == '0': 75 | message = json_data["message"] 76 | print(f"Github API Error: {message}", flush=True) 77 | ratelimit_reset = headers["x-ratelimit-reset"] 78 | ratelimit_reset = datetime.fromtimestamp(int(ratelimit_reset)) 79 | print(f"The current rate limit window resets in {ratelimit_reset}", flush=True) 80 | exit(1) 81 | 82 | print(f"download link: {link}", flush=True) 83 | 84 | with open(download_dir/tempScript, 'a') as f: 85 | f.writelines(f'{link}\n') 86 | f.writelines(f' dir={download_dir}\n') 87 | f.writelines(f' out={file_name}\n') 88 | -------------------------------------------------------------------------------- /scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | # DEBUG=--debug 22 | # CUSTOM_MAGISK=--magisk-custom 23 | if [ ! "$BASH_VERSION" ]; then 24 | echo "Please do not use sh to run this script, just execute it directly" 1>&2 25 | exit 1 26 | fi 27 | cd "$(dirname "$0")" || exit 1 28 | 29 | ./install_deps.sh 30 | 31 | WHIPTAIL=$(command -v whiptail 2>/dev/null) 32 | DIALOG=$(command -v dialog 2>/dev/null) 33 | DIALOG=${WHIPTAIL:-$DIALOG} 34 | function Radiolist { 35 | declare -A o="$1" 36 | shift 37 | if ! $DIALOG --nocancel --radiolist "${o[title]}" 0 0 0 "$@" 3>&1 1>&2 2>&3; then 38 | echo "${o[default]}" 39 | fi 40 | } 41 | 42 | function YesNoBox { 43 | declare -A o="$1" 44 | shift 45 | $DIALOG --title "${o[title]}" --yesno "${o[text]}" 0 0 46 | } 47 | 48 | ARCH=$( 49 | Radiolist '([title]="Build arch" 50 | [default]="x64")' \ 51 | \ 52 | 'x64' "X86_64" 'on' \ 53 | 'arm64' "AArch64" 'off' 54 | ) 55 | 56 | RELEASE_TYPE=$( 57 | Radiolist '([title]="WSA release type" 58 | [default]="retail")' \ 59 | \ 60 | 'retail' "Stable Channel" 'on' \ 61 | 'release preview' "Release Preview Channel" 'off' \ 62 | 'insider slow' "Beta Channel" 'off' \ 63 | 'insider fast' "Dev Channel" 'off' 64 | ) 65 | 66 | if [ -z "${CUSTOM_MAGISK+x}" ]; then 67 | MAGISK_VER=$( 68 | Radiolist '([title]="Magisk version" 69 | [default]="stable")' \ 70 | \ 71 | 'stable' "Stable Channel" 'on' \ 72 | 'beta' "Beta Channel" 'off' \ 73 | 'canary' "Canary Channel" 'off' \ 74 | 'debug' "Canary Channel Debug Build" 'off' 75 | ) 76 | else 77 | MAGISK_VER=debug 78 | fi 79 | 80 | if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then 81 | GAPPS_BRAND=$( 82 | Radiolist '([title]="Which GApps do you want to install?" 83 | [default]="MindTheGapps")' \ 84 | \ 85 | 'OpenGApps' "This flavor may cause startup failure" 'off' \ 86 | 'MindTheGapps' "Recommend" 'on' 87 | ) 88 | else 89 | GAPPS_BRAND="none" 90 | fi 91 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 92 | # TODO: Keep it pico since other variants of opengapps are unable to boot successfully 93 | if [ "$DEBUG" = "1" ]; then 94 | GAPPS_VARIANT=$( 95 | Radiolist '([title]="Variants of GApps" 96 | [default]="pico")' \ 97 | \ 98 | 'super' "" 'off' \ 99 | 'stock' "" 'off' \ 100 | 'full' "" 'off' \ 101 | 'mini' "" 'off' \ 102 | 'micro' "" 'off' \ 103 | 'nano' "" 'off' \ 104 | 'pico' "" 'on' \ 105 | 'tvstock' "" 'off' \ 106 | 'tvmini' "" 'off' 107 | ) 108 | else 109 | GAPPS_VARIANT=pico 110 | fi 111 | else 112 | GAPPS_VARIANT="pico" 113 | fi 114 | 115 | if (YesNoBox '([title]="Remove Amazon Appstore" [text]="Do you want to keep Amazon Appstore?")'); then 116 | REMOVE_AMAZON="" 117 | else 118 | REMOVE_AMAZON="--remove-amazon" 119 | fi 120 | 121 | ROOT_SOL=$( 122 | Radiolist '([title]="Root solution" 123 | [default]="magisk")' \ 124 | \ 125 | 'magisk' "" 'on' \ 126 | 'none' "" 'off' 127 | ) 128 | 129 | if (YesNoBox '([title]="Compress output" [text]="Do you want to compress the output?")'); then 130 | COMPRESS_OUTPUT="--compress" 131 | else 132 | COMPRESS_OUTPUT="" 133 | fi 134 | if [ "$COMPRESS_OUTPUT" = "--compress" ]; then 135 | COMPRESS_FORMAT=$( 136 | Radiolist '([title]="Compress format" 137 | [default]="7z")' \ 138 | \ 139 | 'zip' "Zip" 'off' \ 140 | '7z' "7-Zip" 'on' \ 141 | 'xz' "tar.xz" 'off' 142 | ) 143 | fi 144 | # if (YesNoBox '([title]="Off line mode" [text]="Do you want to enable off line mode?")'); then 145 | # OFFLINE="--offline" 146 | # else 147 | # OFFLINE="" 148 | # fi 149 | # OFFLINE="--offline" 150 | clear 151 | declare -A RELEASE_TYPE_MAP=(["retail"]="retail" ["release preview"]="RP" ["insider slow"]="WIS" ["insider fast"]="WIF") 152 | COMMAND_LINE=(--arch "$ARCH" --release-type "${RELEASE_TYPE_MAP[$RELEASE_TYPE]}" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VARIANT" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$COMPRESS_OUTPUT" "$OFFLINE" "$DEBUG" "$CUSTOM_MAGISK" --compress-format "$COMPRESS_FORMAT") 153 | echo "COMMAND_LINE=${COMMAND_LINE[*]}" 154 | ./build.sh "${COMMAND_LINE[@]}" 155 | -------------------------------------------------------------------------------- /scripts/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | if [ ! "$BASH_VERSION" ]; then 22 | echo "Please do not use sh to run this script, just execute it directly" 1>&2 23 | exit 1 24 | fi 25 | cd "$(dirname "$0")" || exit 1 26 | SUDO="$(which sudo 2>/dev/null)" 27 | abort() { 28 | echo "Dependencies: an error has occurred, exit" 29 | exit 1 30 | } 31 | require_su() { 32 | if test "$(id -u)" != "0"; then 33 | if [ -z "$SUDO" ] && [ "$($SUDO id -u)" != "0" ]; then 34 | echo "ROOT/SUDO is required to run this script" 35 | abort 36 | fi 37 | fi 38 | } 39 | echo "Checking and ensuring dependencies" 40 | check_dependencies() { 41 | command -v whiptail >/dev/null 2>&1 || command -v dialog >/dev/null 2>&1 || NEED_INSTALL+=("whiptail") 42 | command -v seinfo >/dev/null 2>&1 || NEED_INSTALL+=("setools") 43 | command -v lzip >/dev/null 2>&1 || NEED_INSTALL+=("lzip") 44 | if [ ! -f /proc/sys/fs/binfmt_misc/WSLInterop ]; then 45 | command -v wine64 >/dev/null 2>&1 || NEED_INSTALL+=("wine") 46 | command -v winetricks >/dev/null 2>&1 || NEED_INSTALL+=("winetricks") 47 | fi 48 | command -v patchelf >/dev/null 2>&1 || NEED_INSTALL+=("patchelf") 49 | command -v resize2fs >/dev/null 2>&1 || NEED_INSTALL+=("e2fsprogs") 50 | command -v pip >/dev/null 2>&1 || NEED_INSTALL+=("python3-pip") 51 | command -v aria2c >/dev/null 2>&1 || NEED_INSTALL+=("aria2") 52 | command -v 7z > /dev/null 2>&1 || NEED_INSTALL+=("p7zip-full") 53 | command -v setfattr > /dev/null 2>&1 || NEED_INSTALL+=("attr") 54 | command -v xz > /dev/null 2>&1 || NEED_INSTALL+=("xz-utils") 55 | command -v unzip > /dev/null 2>&1 || NEED_INSTALL+=("unzip") 56 | } 57 | check_dependencies 58 | osrel=$(sed -n '/^ID_LIKE=/s/^.*=//p' /etc/os-release); 59 | declare -A os_pm_install; 60 | # os_pm_install["/etc/redhat-release"]=yum 61 | # os_pm_install["/etc/arch-release"]=pacman 62 | # os_pm_install["/etc/gentoo-release"]=emerge 63 | os_pm_install["/etc/SuSE-release"]=zypper 64 | os_pm_install["/etc/debian_version"]=apt-get 65 | # os_pm_install["/etc/alpine-release"]=apk 66 | 67 | declare -A PM_UPDATE_MAP; 68 | PM_UPDATE_MAP["yum"]="check-update" 69 | PM_UPDATE_MAP["pacman"]="-Syu --noconfirm" 70 | PM_UPDATE_MAP["emerge"]="-auDN @world" 71 | PM_UPDATE_MAP["zypper"]="ref" 72 | PM_UPDATE_MAP["apt-get"]="update" 73 | PM_UPDATE_MAP["apk"]="update" 74 | 75 | declare -A PM_INSTALL_MAP; 76 | PM_INSTALL_MAP["yum"]="install -y" 77 | PM_INSTALL_MAP["pacman"]="-S --noconfirm --needed" 78 | PM_INSTALL_MAP["emerge"]="-a" 79 | PM_INSTALL_MAP["zypper"]="in -y" 80 | PM_INSTALL_MAP["apt-get"]="install -y" 81 | PM_INSTALL_MAP["apk"]="add" 82 | 83 | check_package_manager() { 84 | for f in "${!os_pm_install[@]}"; do 85 | if [[ -f $f ]]; then 86 | PM="${os_pm_install[$f]}" 87 | break 88 | fi 89 | done 90 | if [[ "$osrel" = *"suse"* ]]; then 91 | PM="zypper" 92 | fi 93 | if [ -n "$PM" ]; then 94 | readarray -td ' ' UPDATE_OPTION <<<"${PM_UPDATE_MAP[$PM]} "; unset 'UPDATE_OPTION[-1]'; 95 | readarray -td ' ' INSTALL_OPTION <<<"${PM_INSTALL_MAP[$PM]} "; unset 'INSTALL_OPTION[-1]'; 96 | fi 97 | } 98 | 99 | check_package_manager 100 | if [ -n "${NEED_INSTALL[*]}" ]; then 101 | if [ -z "$PM" ]; then 102 | echo "Unable to determine package manager: Unsupported distros" 103 | abort 104 | else 105 | if [ "$PM" = "zypper" ]; then 106 | NEED_INSTALL_FIX=${NEED_INSTALL[*]} 107 | { 108 | NEED_INSTALL_FIX=${NEED_INSTALL_FIX//setools/setools-console} 2>&1 109 | NEED_INSTALL_FIX=${NEED_INSTALL_FIX//whiptail/dialog} 2>&1 110 | NEED_INSTALL_FIX=${NEED_INSTALL_FIX//xz-utils/xz} 2>&1 111 | } >> /dev/null 112 | 113 | readarray -td ' ' NEED_INSTALL <<<"$NEED_INSTALL_FIX "; unset 'NEED_INSTALL[-1]'; 114 | elif [ "$PM" = "apk" ]; then 115 | NEED_INSTALL_FIX=${NEED_INSTALL[*]} 116 | readarray -td ' ' NEED_INSTALL <<<"${NEED_INSTALL_FIX//p7zip-full/p7zip} "; unset 'NEED_INSTALL[-1]'; 117 | fi 118 | require_su 119 | if ! ($SUDO "$PM" "${UPDATE_OPTION[@]}" && $SUDO "$PM" "${INSTALL_OPTION[@]}" "${NEED_INSTALL[@]}") then abort; fi 120 | fi 121 | fi 122 | pip list --disable-pip-version-check | grep -E "^requests " >/dev/null 2>&1 || python3 -m pip install requests 123 | 124 | if [ ! -f /proc/sys/fs/binfmt_misc/WSLInterop ] && which wine64 > /dev/null; then 125 | winetricks list-installed | grep -E "^msxml6" >/dev/null 2>&1 || { 126 | cp -r ../wine/.cache/* ~/.cache 127 | winetricks msxml6 || abort 128 | } 129 | fi 130 | -------------------------------------------------------------------------------- /installer/Install.ps1: -------------------------------------------------------------------------------- 1 | # Automated Install script by Midonei 2 | $Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA..." 3 | function Test-Administrator { 4 | [OutputType([bool])] 5 | param() 6 | process { 7 | [Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent(); 8 | return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator); 9 | } 10 | } 11 | 12 | function Get-InstalledDependencyVersion { 13 | param ( 14 | [string]$Name, 15 | [string]$ProcessorArchitecture 16 | ) 17 | process { 18 | return Get-AppxPackage -Name $Name | ForEach-Object { if ($_.Architecture -eq $ProcessorArchitecture) { $_ } } | Sort-Object -Property Version | Select-Object -ExpandProperty Version -Last 1; 19 | } 20 | } 21 | 22 | function Finish { 23 | Clear-Host 24 | Start-Process "wsa://com.topjohnwu.magisk" 25 | Start-Process "wsa://com.android.vending" 26 | } 27 | 28 | If (-Not (Test-Administrator)) { 29 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force 30 | $proc = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs ConHost.exe -Args "powershell -ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath' EVAL" 31 | $proc.WaitForExit() 32 | If ($proc.ExitCode -Ne 0) { 33 | Clear-Host 34 | Write-Warning "Failed to launch start as Administrator`r`nPress any key to exit" 35 | $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); 36 | } 37 | exit 38 | } 39 | ElseIf (($args.Count -Eq 1) -And ($args[0] -Eq "EVAL")) { 40 | Start-Process ConHost.exe -Args "powershell -ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'" 41 | exit 42 | } 43 | 44 | $FileList = Get-Content -Path .\filelist.txt 45 | If (((Test-Path -Path $FileList) -Eq $false).Count) { 46 | Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist" 47 | $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') 48 | exit 1 49 | } 50 | 51 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" 52 | 53 | If ($(Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform').State -Ne "Enabled") { 54 | Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform' 55 | Clear-Host 56 | Write-Warning "Need restart to enable virtual machine platform`r`nPress y to restart or press any key to exit" 57 | $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') 58 | If ("y" -Eq $key.Character) { 59 | Restart-Computer -Confirm 60 | } 61 | Else { 62 | exit 1 63 | } 64 | } 65 | 66 | [xml]$Xml = Get-Content ".\AppxManifest.xml"; 67 | $Name = $Xml.Package.Identity.Name; 68 | $ProcessorArchitecture = $Xml.Package.Identity.ProcessorArchitecture; 69 | $Dependencies = $Xml.Package.Dependencies.PackageDependency; 70 | $Dependencies | ForEach-Object { 71 | If ($_.Name -Eq "Microsoft.VCLibs.140.00.UWPDesktop") { 72 | $HighestInstalledVCLibsVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture; 73 | If ( $HighestInstalledVCLibsVersion -Lt $_.MinVersion ) { 74 | Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "Microsoft.VCLibs.$ProcessorArchitecture.14.00.Desktop.appx" 75 | } 76 | } 77 | ElseIf ($_.Name -Match "Microsoft.UI.Xaml") { 78 | $HighestInstalledXamlVersion = Get-InstalledDependencyVersion -Name $_.Name -ProcessorArchitecture $ProcessorArchitecture; 79 | If ( $HighestInstalledXamlVersion -Lt $_.MinVersion ) { 80 | Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path "Microsoft.UI.Xaml_$ProcessorArchitecture.appx" 81 | } 82 | } 83 | } 84 | 85 | $Installed = $null 86 | $Installed = Get-AppxPackage -Name $Name 87 | 88 | If (($null -Ne $Installed) -And (-Not ($Installed.IsDevelopmentMode))) { 89 | Clear-Host 90 | Write-Warning "There is already one installed WSA. Please uninstall it first.`r`nPress y to uninstall existing WSA or press any key to exit" 91 | $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') 92 | If ("y" -Eq $key.Character) { 93 | Remove-AppxPackage -Package $Installed.PackageFullName 94 | } 95 | Else { 96 | exit 1 97 | } 98 | } 99 | Clear-Host 100 | Write-Host "Installing MagiskOnWSA..." 101 | Stop-Process -Name "WsaClient" -ErrorAction SilentlyContinue 102 | Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml 103 | If ($?) { 104 | Finish 105 | } 106 | ElseIf ($null -Ne $Installed) { 107 | Clear-Host 108 | Write-Error "Failed to update.`r`nPress any key to uninstall existing installation while preserving user data.`r`nTake in mind that this will remove the Android apps' icon from the start menu.`r`nIf you want to cancel, close this window now." 109 | $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') 110 | Remove-AppxPackage -PreserveApplicationData -Package $Installed.PackageFullName 111 | Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml 112 | If ($?) { 113 | Finish 114 | } 115 | } 116 | Write-Host "All Done!`r`nPress any key to exit" 117 | $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') 118 | -------------------------------------------------------------------------------- /scripts/generateWSALinks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | import html 22 | import os 23 | import re 24 | import sys 25 | import warnings 26 | from pathlib import Path 27 | from threading import Thread 28 | from typing import OrderedDict 29 | from xml.dom import minidom 30 | 31 | from requests import Session 32 | 33 | 34 | class Prop(OrderedDict): 35 | def __init__(self, props: str=...) -> None: 36 | super().__init__() 37 | for i, line in enumerate(props.splitlines(False)): 38 | if '=' in line: 39 | k, v = line.split('=', 1) 40 | self[k] = v 41 | else: 42 | self[f".{i}"] = line 43 | 44 | def get(self, key: str) -> str: 45 | return self[key] 46 | 47 | warnings.filterwarnings("ignore") 48 | 49 | arch = sys.argv[1] 50 | 51 | release_name_map = {"retail": "Retail", "RP": "Release Preview", 52 | "WIS": "Insider Slow", "WIF": "Insider Fast"} 53 | release_type = sys.argv[2] if sys.argv[2] != "" else "Retail" 54 | release_name = release_name_map[release_type] 55 | download_dir = Path.cwd().parent / "download" if sys.argv[3] == "" else Path(sys.argv[3]).resolve() 56 | ms_account_conf = download_dir/".ms_account" 57 | tempScript = sys.argv[4] 58 | cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8' 59 | user = '' 60 | session = Session() 61 | 62 | if ms_account_conf.is_file(): 63 | with open(ms_account_conf, "r") as f: 64 | conf = Prop(f.read()) 65 | user = conf.get('user_code') 66 | print(f"Generating WSA download link: arch={arch} release_type={release_name}", flush=True) 67 | with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f: 68 | cookie_content = f.read().format(user) 69 | 70 | out = session.post( 71 | 'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx', 72 | data=cookie_content, 73 | headers={'Content-Type': 'application/soap+xml; charset=utf-8'}, 74 | verify=False 75 | ) 76 | doc = minidom.parseString(out.text) 77 | cookie = doc.getElementsByTagName('EncryptedData')[0].firstChild.nodeValue 78 | 79 | with open(Path.cwd().parent / "xml/WUIDRequest.xml", "r") as f: 80 | cat_id_content = f.read().format(user, cookie, cat_id, release_type) 81 | 82 | out = session.post( 83 | 'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx', 84 | data=cat_id_content, 85 | headers={'Content-Type': 'application/soap+xml; charset=utf-8'}, 86 | verify=False 87 | ) 88 | 89 | doc = minidom.parseString(html.unescape(out.text)) 90 | 91 | filenames = {} 92 | for node in doc.getElementsByTagName('Files'): 93 | filenames[node.parentNode.parentNode.getElementsByTagName( 94 | 'ID')[0].firstChild.nodeValue] = f"{node.firstChild.attributes['InstallerSpecificIdentifier'].value}_{node.firstChild.attributes['FileName'].value}" 95 | pass 96 | 97 | identities = [] 98 | for node in doc.getElementsByTagName('SecuredFragment'): 99 | filename = filenames[node.parentNode.parentNode.parentNode.getElementsByTagName('ID')[ 100 | 0].firstChild.nodeValue] 101 | update_identity = node.parentNode.parentNode.firstChild 102 | identities += [(update_identity.attributes['UpdateID'].value, 103 | update_identity.attributes['RevisionNumber'].value, filename)] 104 | 105 | with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f: 106 | FE3_file_content = f.read() 107 | 108 | if not download_dir.is_dir(): 109 | download_dir.mkdir() 110 | tmpdownlist = open(download_dir/tempScript, 'a') 111 | 112 | def send_req(i,v,out_file,out_file_name): 113 | out = session.post( 114 | 'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured', 115 | data=FE3_file_content.format(user, i, v, release_type), 116 | headers={'Content-Type': 'application/soap+xml; charset=utf-8'}, 117 | verify=False 118 | ) 119 | doc = minidom.parseString(out.text) 120 | for l in doc.getElementsByTagName("FileLocation"): 121 | url = l.getElementsByTagName("Url")[0].firstChild.nodeValue 122 | if len(url) != 99: 123 | print(f"download link: {url} to {out_file}", flush=True) 124 | tmpdownlist.writelines(url + '\n') 125 | tmpdownlist.writelines(f' dir={download_dir}\n') 126 | tmpdownlist.writelines(f' out={out_file_name}\n') 127 | 128 | threads = [] 129 | for i, v, f in identities: 130 | if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f): 131 | out_file_name = f"Microsoft.UI.Xaml_{arch}.appx" 132 | out_file = download_dir / out_file_name 133 | # elif re.match(f"Microsoft\.VCLibs\..+\.UWPDesktop_.*_{arch}_.*\.appx", f): 134 | # out_file_name = f"Microsoft.VCLibs.140.00.UWPDesktop_{arch}.appx" 135 | # out_file = download_dir / out_file_name 136 | elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", f): 137 | wsa_long_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', f).group() 138 | print(f'WSA Version={wsa_long_ver}\n', flush=True) 139 | main_ver = wsa_long_ver.split(".")[0] 140 | with open(os.environ['WSA_WORK_ENV'], 'a') as environ_file: 141 | environ_file.write(f"DOWN_WSA_VERSION={wsa_long_ver}\n") 142 | environ_file.write(f"DOWN_WSA_MAIN_VERSION={main_ver}\n") 143 | out_file_name = f"wsa-{release_type}.zip" 144 | out_file = download_dir / out_file_name 145 | else: 146 | continue 147 | th = Thread(target=send_req, args=(i,v,out_file,out_file_name)) 148 | threads.append(th) 149 | th.daemon = True 150 | th.start() 151 | tmpdownlist.writelines(f'https://aka.ms/Microsoft.VCLibs.{arch}.14.00.Desktop.appx\n') 152 | tmpdownlist.writelines(f' dir={download_dir}\n') 153 | for th in threads: 154 | th.join() 155 | tmpdownlist.close() 156 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magisk on WSA (with Google Apps) 2 | 3 | :warning: For fork developers: Please don't build using GitHub Actions, as GitHub will count your forked GitHub Actions usage against this upstream repository, which may cause this upstream repository gets disabled by GitHub staff like [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA) because of numerous forks building GitHub Actions, and counting the forks' Action usage against this upstream repository. 4 | 5 | ## Support for generating from these systems 6 | 7 | - Linux (x86_64 or arm64) 8 | 9 | The following dependencies are required: 10 | 11 | | DistrOS | | | | | 12 | |:-------:|-------------------------------------------------------------------------------------------------|-------------------|------------|-----------| 13 | | Debian | `lzip wine winetricks patchelf e2fsprogs aria2 python3 python3-pip aria2 p7zip-full attr unzip` | `setools` | `whiptail` | `xz-util` | 14 | | SuSE | Same as above | `setools-console` | `dialog` | `xz` | 15 | 16 | The following components need to be installed using `winetricks`: `msxml6` 17 | 18 | The python3 library `requests` is used. 19 | 20 | Python version ≥ 3.7. 21 | - Recommended Use 22 | - Ubuntu (You can use [WSL2](https://apps.microsoft.com/store/search?publisher=Canonical%20Group%20Limited)) 23 | 24 | Ready to use right out of the box. 25 | - Debian (You can use [WSL2](https://apps.microsoft.com/store/detail/debian/9MSVKQC78PK6)) 26 | 27 | Need to add `contrib` sources to the source list to install winetricks. 28 | 29 | - OpenSUSE (You can use [WSL2](https://apps.microsoft.com/store/search?publisher=SUSE)) 30 | 31 | Ready to use right out of the box. 32 | 33 | `run.sh` will handle all dependencies automatically. 34 | 35 | No need to type any commands. 36 | - Other Distributions 37 | 38 | Install the dependencies manually. 39 | 40 | Use the command-line program `build.sh`. 41 | 42 | ## Features 43 | 44 | - Integrate Magisk and GApps in a few clicks within minutes 45 | - Keep each build up to date 46 | - Support both ARM64 and x64 47 | - Support all OpenGApps variants except for aroma (aroma does not support x86_64, please use super instead) 48 | - Remove Amazon Appstore 49 | - Fix VPN dialog not showing (use our [VpnDialogs app](https://github.com/LSPosed/VpnDialogs)) 50 | - Add device administration feature 51 | - Unattended installation 52 | - Automatically activates developers mode in Windows 11 53 | - Update to the new version while preserving data with a one-click script 54 | - Merged all language packs 55 | 56 | ## Text Guide 57 | 58 | 1. Star (if you like) 59 | 1. Clone the repo to local 60 | - Run `cd scripts` 61 | - Then run `./build.sh --help` (optional) to get the usage if you want to use CLI. 62 | 1. Run `./run.sh` under scripts directory. 63 | 1. Select the WSA version and its architecture (mostly x64). 64 | 1. Select the version of Magisk. 65 | 1. Choose which brand of GApps you want to install 66 | - OpenGApps 67 | 68 | Select the [OpenGApps variant](https://github.com/opengapps/opengapps/wiki#variants) you like. 69 | - MindTheGapps 70 | 71 | There is no other variant we can choose. 72 | 1. Select the root solution (none means no root) 73 | 1. If you are running the script for the first time, it will take some time to complete. After the script completes, two new folders named `output` and `download` will be generated in the `MagiskOnWSALocal` folder. Go to the `output` folder. While running the `./run.sh` script in the step 3, if you selected `Yes` for `Do you want to compress the output?` then in `output` folder you will see a compressed file called `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`or else there will be folder with the `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`. If there is a folder open it and skip to step 10. NOTE: The name of compressed file or the folder generated in the `output` folder may be different for you. It will be dependent on the choices made when executing `./run.sh` 74 | 1. Extract the compressed file and open the folder created after the extraction of the file. 75 | 1. Here look for file `Run.bat` and run it. 76 | - If you previously have a MagiskOnWSA installation, it will automatically uninstall the previous one while **preserving all user data** and install the new one, so don't worry about your data. 77 | - If you have an official WSA installation, you should uninstall it first. (In case you want to preserve your data, you can backup `%LOCALAPPDATA%\Packages\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe\LocalCache\userdata.vhdx` before uninstallation and restore it after installation.) 78 | - If the popup windows disappear **without asking administrative permission** and WSA is not installed successfully, you should manually run `Install.ps1` as administrator: 79 | 1. Press `Win+x` and select `Windows Terminal (Admin)` 80 | 2. Input `cd "{X:\path\to\your\extracted\folder}"` and press `enter`, and remember to replace `{X:\path\to\your\extracted\folder}` including the `{}`, for example `cd "D:\wsa"` 81 | 3. Input `PowerShell.exe -ExecutionPolicy Bypass -File .\Install.ps1` and press `enter` 82 | 4. The script will run and WSA will be installed 83 | 5. If this workaround does not work, your PC is not supported for WSA 84 | 1. Magisk/Play store will be launched. Enjoy by installing LSPosed-zygisk with zygisk enabled or Riru and LSPosed-riru 85 | 86 | ## FAQ 87 | 88 | - Can I delete the installed folder? 89 | 90 | No. 91 | - How can I update WSA to a new version? 92 | 93 | Delete the `download` folder 94 | Rerun the script, replace the content of your previous installation and rerun `Install.ps1`. Don't worry, your data will be preserved. 95 | - How can I get the logcat from WSA? 96 | 97 | `%LOCALAPPDATA%\Packages\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe\LocalState\diagnostics\logcat` 98 | - How can I update Magisk to a new version? 99 | 100 | Do the same as updating WSA 101 | - How to pass safetynet? 102 | 103 | Like all the other emulators, no way. 104 | - Virtualization is not enabled? 105 | 106 | `Install.ps1` helps you enable it if not enabled. After rebooting, rerun `Install.ps1` to install WSA. If it's still not working, you have to enable virtualization in BIOS. That's a long story so ask Google for help. 107 | - How to remount the system as read-write? 108 | 109 | No way in WSA since it's mounted as read-only by Hyper-V. You can modify the system by making a Magisk module. Or directly modify the system.img. Ask Google for help. 110 | - I cannot `adb connect localhost:58526` 111 | 112 | Make sure developer mode is enabled. If the issue persists, check the IP address of WSA on the setting page and try `adb connect ip:5555`. 113 | - Magisk online module list is empty? 114 | 115 | Magisk actively removes the online module repository. You can install the module locally or by `adb push module.zip /data/local/tmp` and `adb shell su -c magisk --install-module /data/local/tmp/module.zip`. 116 | - Can I use Magisk 23.0 stable or a lower version? 117 | 118 | No. Magisk has bugs preventing itself from running on WSA. Magisk 24+ has fixed them. So you must use Magisk 24 or higher version. 119 | - How can I get rid of Magisk? 120 | 121 | Choose `none` as the root solution. 122 | - How to install custom GApps? 123 | 124 | [Tutorial](./Custom-GApps.md) 125 | - Where can I download MindTheGapps? 126 | 127 | You can download from here [MindTheGapps](https://androidfilehost.com/?w=files&flid=322935) ([mirror](http://downloads.codefi.re/jdcteam/javelinanddart/gapps)) 128 | 129 | Note that there is no x86_64 pre-build, so you need to build it by yourself ([Repository](https://gitlab.com/MindTheGapps/vendor_gapps)). 130 | 131 | Or you can download the built package for 12.1 and 13 for x86_64 from [this page](https://sourceforge.net/projects/wsa-mtg/files/x86_64/). 132 | - Can I switch OpenGApps to MindTheGapps and keep user data in a previous build? 133 | 134 | No. You should wipe data after changing the GApps brand. Otherwise, you will find that the installed GApps are not recognized. 135 | 136 | - WSA with OpenGApps integrated fails to start. 137 | 138 | OpenGApps has not yet released a version built for Android 12L and 13, only built for Android 11, which may not be compatible and thus cause crashes. Consider switching to MindTheGapps. 139 | - How to install KernelSU? 140 | 141 | [Tutorial](./KernelSU.md) 142 | 143 | ## Credits 144 | 145 | - [StoreLib](https://github.com/StoreDev/StoreLib): API for downloading WSA 146 | - [Magisk](https://github.com/topjohnwu/Magisk): The most famous root solution on Android 147 | - [The Open GApps Project](https://opengapps.org): One of the most famous Google Apps packages solution 148 | - [WSA-Kernel-SU](https://github.com/LSPosed/WSA-Kernel-SU) and [kernel-assisted-superuser](https://git.zx2c4.com/kernel-assisted-superuser/): The kernel `su` for debugging Magisk Integration 149 | - [WSAGAScript](https://github.com/ADeltaX/WSAGAScript): The first GApps integration script for WSA 150 | 151 | _The repository is provided as a utility._ 152 | 153 | _Android is a trademark of Google LLC. Windows is a trademark of Microsoft LLC._ 154 | -------------------------------------------------------------------------------- /xml/WUIDRequest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdates 5 | urn:uuid:175df68c-4b91-41ee-b70b-f2208c65438e 6 | https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx 7 | 9 | 10 | 2017-08-05T02:03:05.038Z 11 | 2017-08-05T02:08:05.038Z 12 | 13 | 16 | 17 | {} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 2045-03-11T02:02:48Z 26 | {} 27 | 28 | 29 | false 30 | 31 | 1 32 | 2 33 | 3 34 | 11 35 | 19 36 | 544 37 | 549 38 | 2359974 39 | 2359977 40 | 5169044 41 | 8788830 42 | 23110993 43 | 23110994 44 | 54341900 45 | 54343656 46 | 59830006 47 | 59830007 48 | 59830008 49 | 60484010 50 | 62450018 51 | 62450019 52 | 62450020 53 | 66027979 54 | 66053150 55 | 97657898 56 | 98822896 57 | 98959022 58 | 98959023 59 | 98959024 60 | 98959025 61 | 98959026 62 | 104433538 63 | 104900364 64 | 105489019 65 | 117765322 66 | 129905029 67 | 130040031 68 | 132387090 69 | 132393049 70 | 133399034 71 | 138537048 72 | 140377312 73 | 143747671 74 | 158941041 75 | 158941042 76 | 158941043 77 | 158941044 78 | 159123858 79 | 159130928 80 | 164836897 81 | 164847386 82 | 164848327 83 | 164852241 84 | 164852246 85 | 164852252 86 | 164852253 87 | 88 | 89 | 10 90 | 17 91 | 2359977 92 | 5143990 93 | 5169043 94 | 5169047 95 | 8806526 96 | 9125350 97 | 9154769 98 | 10809856 99 | 23110995 100 | 23110996 101 | 23110999 102 | 23111000 103 | 23111001 104 | 23111002 105 | 23111003 106 | 23111004 107 | 24513870 108 | 28880263 109 | 30077688 110 | 30486944 111 | 30526991 112 | 30528442 113 | 30530496 114 | 30530501 115 | 30530504 116 | 30530962 117 | 30535326 118 | 30536242 119 | 30539913 120 | 30545142 121 | 30545145 122 | 30545488 123 | 30546212 124 | 30547779 125 | 30548797 126 | 30548860 127 | 30549262 128 | 30551160 129 | 30551161 130 | 30551164 131 | 30553016 132 | 30553744 133 | 30554014 134 | 30559008 135 | 30559011 136 | 30560006 137 | 30560011 138 | 30561006 139 | 30563261 140 | 30565215 141 | 30578059 142 | 30664998 143 | 30677904 144 | 30681618 145 | 30682195 146 | 30685055 147 | 30702579 148 | 30708772 149 | 30709591 150 | 30711304 151 | 30715418 152 | 30720106 153 | 30720273 154 | 30732075 155 | 30866952 156 | 30866964 157 | 30870749 158 | 30877852 159 | 30878437 160 | 30890151 161 | 30892149 162 | 30990917 163 | 31049444 164 | 31190936 165 | 31196961 166 | 31197811 167 | 31198836 168 | 31202713 169 | 31203522 170 | 31205442 171 | 31205557 172 | 31207585 173 | 31208440 174 | 31208451 175 | 31209591 176 | 31210536 177 | 31211625 178 | 31212713 179 | 31213588 180 | 31218518 181 | 31219420 182 | 31220279 183 | 31220302 184 | 31222086 185 | 31227080 186 | 31229030 187 | 31238236 188 | 31254198 189 | 31258008 190 | 36436779 191 | 36437850 192 | 36464012 193 | 41916569 194 | 47249982 195 | 47283134 196 | 58577027 197 | 58578040 198 | 58578041 199 | 58628920 200 | 59107045 201 | 59125697 202 | 59142249 203 | 60466586 204 | 60478936 205 | 66450441 206 | 66467021 207 | 66479051 208 | 75202978 209 | 77436021 210 | 77449129 211 | 85159569 212 | 90199702 213 | 90212090 214 | 96911147 215 | 97110308 216 | 98528428 217 | 98665206 218 | 98837995 219 | 98842922 220 | 98842977 221 | 98846632 222 | 98866485 223 | 98874250 224 | 98879075 225 | 98904649 226 | 98918872 227 | 98945691 228 | 98959458 229 | 98984707 230 | 100220125 231 | 100238731 232 | 100662329 233 | 100795834 234 | 100862457 235 | 103124811 236 | 103348671 237 | 104369981 238 | 104372472 239 | 104385324 240 | 104465831 241 | 104465834 242 | 104467697 243 | 104473368 244 | 104482267 245 | 104505005 246 | 104523840 247 | 104550085 248 | 104558084 249 | 104659441 250 | 104659675 251 | 104664678 252 | 104668274 253 | 104671092 254 | 104673242 255 | 104674239 256 | 104679268 257 | 104686047 258 | 104698649 259 | 104751469 260 | 104752478 261 | 104755145 262 | 104761158 263 | 104762266 264 | 104786484 265 | 104853747 266 | 104873258 267 | 104983051 268 | 105063056 269 | 105116588 270 | 105178523 271 | 105318602 272 | 105362613 273 | 105364552 274 | 105368563 275 | 105369591 276 | 105370746 277 | 105373503 278 | 105373615 279 | 105376634 280 | 105377546 281 | 105378752 282 | 105379574 283 | 105381626 284 | 105382587 285 | 105425313 286 | 105495146 287 | 105862607 288 | 105939029 289 | 105995585 290 | 106017178 291 | 106129726 292 | 106768485 293 | 107825194 294 | 111906429 295 | 115121473 296 | 115578654 297 | 116630363 298 | 117835105 299 | 117850671 300 | 118638500 301 | 118662027 302 | 118872681 303 | 118873829 304 | 118879289 305 | 118889092 306 | 119501720 307 | 119551648 308 | 119569538 309 | 119640702 310 | 119667998 311 | 119674103 312 | 119697201 313 | 119706266 314 | 119744627 315 | 119773746 316 | 120072697 317 | 120144309 318 | 120214154 319 | 120357027 320 | 120392612 321 | 120399120 322 | 120553945 323 | 120783545 324 | 120797092 325 | 120881676 326 | 120889689 327 | 120999554 328 | 121168608 329 | 121268830 330 | 121341838 331 | 121729951 332 | 121803677 333 | 122165810 334 | 125408034 335 | 127293130 336 | 127566683 337 | 127762067 338 | 127861893 339 | 128571722 340 | 128647535 341 | 128698922 342 | 128701748 343 | 128771507 344 | 129037212 345 | 129079800 346 | 129175415 347 | 129317272 348 | 129319665 349 | 129365668 350 | 129378095 351 | 129424803 352 | 129590730 353 | 129603714 354 | 129625954 355 | 129692391 356 | 129714980 357 | 129721097 358 | 129886397 359 | 129968371 360 | 129972243 361 | 130009862 362 | 130033651 363 | 130040030 364 | 130040032 365 | 130040033 366 | 130091954 367 | 130100640 368 | 130131267 369 | 130131921 370 | 130144837 371 | 130171030 372 | 130172071 373 | 130197218 374 | 130212435 375 | 130291076 376 | 130402427 377 | 130405166 378 | 130676169 379 | 130698471 380 | 130713390 381 | 130785217 382 | 131396908 383 | 131455115 384 | 131682095 385 | 131689473 386 | 131701956 387 | 132142800 388 | 132525441 389 | 132765492 390 | 132801275 391 | 133399034 392 | 134522926 393 | 134524022 394 | 134528994 395 | 134532942 396 | 134536993 397 | 134538001 398 | 134547533 399 | 134549216 400 | 134549317 401 | 134550159 402 | 134550214 403 | 134550232 404 | 134551154 405 | 134551207 406 | 134551390 407 | 134553171 408 | 134553237 409 | 134554199 410 | 134554227 411 | 134555229 412 | 134555240 413 | 134556118 414 | 134557078 415 | 134560099 416 | 134560287 417 | 134562084 418 | 134562180 419 | 134563287 420 | 134565083 421 | 134566130 422 | 134568111 423 | 134624737 424 | 134666461 425 | 134672998 426 | 134684008 427 | 134916523 428 | 135100527 429 | 135219410 430 | 135222083 431 | 135306997 432 | 135463054 433 | 135779456 434 | 135812968 435 | 136097030 436 | 136131333 437 | 136146907 438 | 136157556 439 | 136320962 440 | 136450641 441 | 136466000 442 | 136745792 443 | 136761546 444 | 136840245 445 | 138160034 446 | 138181244 447 | 138210071 448 | 138210107 449 | 138232200 450 | 138237088 451 | 138277547 452 | 138287133 453 | 138306991 454 | 138324625 455 | 138341916 456 | 138372035 457 | 138372036 458 | 138375118 459 | 138378071 460 | 138380128 461 | 138380194 462 | 138534411 463 | 138618294 464 | 138931764 465 | 139536037 466 | 139536038 467 | 139536039 468 | 139536040 469 | 140367832 470 | 140406050 471 | 140421668 472 | 140422973 473 | 140423713 474 | 140436348 475 | 140483470 476 | 140615715 477 | 140802803 478 | 140896470 479 | 141189437 480 | 141192744 481 | 141382548 482 | 141461680 483 | 141624996 484 | 141627135 485 | 141659139 486 | 141872038 487 | 141993721 488 | 142006413 489 | 142045136 490 | 142095667 491 | 142227273 492 | 142250480 493 | 142518788 494 | 142544931 495 | 142546314 496 | 142555433 497 | 142653044 498 | 143191852 499 | 143258496 500 | 143299722 501 | 143331253 502 | 143432462 503 | 143632431 504 | 143695326 505 | 144219522 506 | 144590916 507 | 145410436 508 | 146720405 509 | 150810438 510 | 151258773 511 | 151315554 512 | 151400090 513 | 151429441 514 | 151439617 515 | 151453617 516 | 151466296 517 | 151511132 518 | 151636561 519 | 151823192 520 | 151827116 521 | 151850642 522 | 152016572 523 | 153111675 524 | 153114652 525 | 153123147 526 | 153267108 527 | 153389799 528 | 153395366 529 | 153718608 530 | 154171028 531 | 154315227 532 | 154559688 533 | 154978771 534 | 154979742 535 | 154985773 536 | 154989370 537 | 155044852 538 | 155065458 539 | 155578573 540 | 156403304 541 | 159085959 542 | 159776047 543 | 159816630 544 | 160733048 545 | 160733049 546 | 160733050 547 | 160733051 548 | 160733056 549 | 164824922 550 | 164824924 551 | 164824926 552 | 164824930 553 | 164831646 554 | 164831647 555 | 164831648 556 | 164831650 557 | 164835050 558 | 164835051 559 | 164835052 560 | 164835056 561 | 164835057 562 | 164835059 563 | 164836898 564 | 164836899 565 | 164836900 566 | 164845333 567 | 164845334 568 | 164845336 569 | 164845337 570 | 164845341 571 | 164845342 572 | 164845345 573 | 164845346 574 | 164845349 575 | 164845350 576 | 164845353 577 | 164845355 578 | 164845358 579 | 164845361 580 | 164845364 581 | 164847387 582 | 164847388 583 | 164847389 584 | 164847390 585 | 164848328 586 | 164848329 587 | 164848330 588 | 164849448 589 | 164849449 590 | 164849451 591 | 164849452 592 | 164849454 593 | 164849455 594 | 164849457 595 | 164849461 596 | 164850219 597 | 164850220 598 | 164850222 599 | 164850223 600 | 164850224 601 | 164850226 602 | 164850227 603 | 164850228 604 | 164850229 605 | 164850231 606 | 164850236 607 | 164850237 608 | 164850240 609 | 164850242 610 | 164850243 611 | 164852242 612 | 164852243 613 | 164852244 614 | 164852247 615 | 164852248 616 | 164852249 617 | 164852250 618 | 164852251 619 | 164852254 620 | 164852256 621 | 164852257 622 | 164852258 623 | 164852259 624 | 164852260 625 | 164852261 626 | 164852262 627 | 164853061 628 | 164853063 629 | 164853071 630 | 164853072 631 | 164853075 632 | 168118980 633 | 168118981 634 | 168118983 635 | 168118984 636 | 168180375 637 | 168180376 638 | 168180378 639 | 168180379 640 | 168270830 641 | 168270831 642 | 168270833 643 | 168270834 644 | 168270835 645 | 646 | false 647 | true 648 | 649 | 650 | {} 651 | 652 | 653 | true 654 | false 655 | 656 | 657 | 658 | Extended 659 | 660 | 661 | en-US 662 | en 663 | 664 | 665 | 666 | en-US 667 | 668 | 669 | false 670 | BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={};AttrDataVer=21;SystemManufacturer=Microsoft Corporation;InstallLanguage=en-US;OSUILocale=en-US;InstallationType=Client;FlightingBranchName=external;FirmwareVersion=Hyper-V UEFI Release v2.5;SystemProductName=Virtual Machine;OSSkuId=48;FlightContent=Branch;App=WU;OEMName_Uncleaned=Microsoft Corporation;AppVer=10.0.22621.900;OSArchitecture=AMD64;SystemSKU=None;UpdateManagementGroup=2;IsFlightingEnabled=1;IsDeviceRetailDemo=0;TelemetryLevel=3;OSVersion=10.0.22621.900;DeviceFamily=Windows.Desktop; 671 | Interactive=1;IsSeeker=0; 672 | 673 | 674 | 675 | 676 | 677 | 678 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This file is part of MagiskOnWSALocal. 4 | # 5 | # MagiskOnWSALocal is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as 7 | # published by the Free Software Foundation, either version 3 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # MagiskOnWSALocal is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with MagiskOnWSALocal. If not, see . 17 | # 18 | # Copyright (C) 2023 LSPosed Contributors 19 | # 20 | 21 | if [ ! "$BASH_VERSION" ]; then 22 | echo "Please do not use sh to run this script, just execute it directly" 1>&2 23 | exit 1 24 | fi 25 | HOST_ARCH=$(uname -m) 26 | if [ "$HOST_ARCH" != "x86_64" ] && [ "$HOST_ARCH" != "aarch64" ]; then 27 | echo "Unsupported architectures: $HOST_ARCH" 28 | exit 1 29 | fi 30 | cd "$(dirname "$0")" || exit 1 31 | # export TMPDIR=$(dirname "$PWD")/WORK_DIR_ 32 | if [ "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then 33 | mkdir -p "$TMPDIR" 34 | fi 35 | WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1 36 | MOUNT_DIR="$WORK_DIR"/system 37 | SUDO="$(which sudo 2>/dev/null)" 38 | if [ -z "$SUDO" ]; then 39 | unset SUDO 40 | fi 41 | DOWNLOAD_DIR=../download 42 | DOWNLOAD_CONF_NAME=download.list 43 | umount_clean() { 44 | if [ -d "$MOUNT_DIR" ]; then 45 | echo "Cleanup Mount Directory" 46 | if [ -d "$MOUNT_DIR/vendor" ]; then 47 | $SUDO umount -v "$MOUNT_DIR"/vendor 48 | fi 49 | if [ -d "$MOUNT_DIR/product" ]; then 50 | $SUDO umount -v "$MOUNT_DIR"/product 51 | fi 52 | if [ -d "$MOUNT_DIR/system_ext" ]; then 53 | $SUDO umount -v "$MOUNT_DIR"/system_ext 54 | fi 55 | $SUDO umount -v "$MOUNT_DIR" 56 | $SUDO rm -rf "${WORK_DIR:?}" 57 | else 58 | rm -rf "${WORK_DIR:?}" 59 | fi 60 | if [ "$TMPDIR" ] && [ -d "$TMPDIR" ]; then 61 | echo "Cleanup Temp Directory" 62 | rm -rf "${TMPDIR:?}" 63 | unset TMPDIR 64 | fi 65 | rm -f "${DOWNLOAD_DIR:?}/$DOWNLOAD_CONF_NAME" 66 | } 67 | trap umount_clean EXIT 68 | OUTPUT_DIR=../output 69 | WSA_WORK_ENV="${WORK_DIR:?}"/ENV 70 | if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi 71 | touch "$WSA_WORK_ENV" 72 | export WSA_WORK_ENV 73 | clean_download() { 74 | if [ -d "$DOWNLOAD_DIR" ]; then 75 | echo "Cleanup Download Directory" 76 | if [ "$CLEAN_DOWNLOAD_WSA" ]; then 77 | rm -f "${WSA_ZIP_PATH:?}" 78 | fi 79 | if [ "$CLEAN_DOWNLOAD_MAGISK" ]; then 80 | rm -f "${MAGISK_PATH:?}" 81 | fi 82 | if [ "$CLEAN_DOWNLOAD_GAPPS" ]; then 83 | rm -f "${GAPPS_PATH:?}" 84 | fi 85 | fi 86 | } 87 | abort() { 88 | echo "Build: an error has occurred, exit" 89 | if [ -d "$WORK_DIR" ]; then 90 | echo -e "\nCleanup Work Directory" 91 | umount_clean 92 | fi 93 | clean_download 94 | exit 1 95 | } 96 | trap abort INT TERM 97 | 98 | Gen_Rand_Str() { 99 | head /dev/urandom | tr -dc '[:lower:]' | head -c"$1" 100 | } 101 | 102 | default() { 103 | ARCH=x64 104 | RELEASE_TYPE=retail 105 | MAGISK_VER=stable 106 | GAPPS_BRAND=MindTheGapps 107 | GAPPS_VARIANT=pico 108 | ROOT_SOL=magisk 109 | } 110 | 111 | exit_with_message() { 112 | echo "ERROR: $1" 113 | usage 114 | exit 1 115 | } 116 | 117 | ARCH_MAP=( 118 | "x64" 119 | "arm64" 120 | ) 121 | 122 | RELEASE_TYPE_MAP=( 123 | "retail" 124 | "RP" 125 | "WIS" 126 | "WIF" 127 | ) 128 | 129 | MAGISK_VER_MAP=( 130 | "stable" 131 | "beta" 132 | "canary" 133 | "debug" 134 | "release" 135 | ) 136 | 137 | GAPPS_BRAND_MAP=( 138 | "OpenGApps" 139 | "MindTheGapps" 140 | "none" 141 | ) 142 | 143 | GAPPS_VARIANT_MAP=( 144 | "super" 145 | "stock" 146 | "full" 147 | "mini" 148 | "micro" 149 | "nano" 150 | "pico" 151 | "tvstock" 152 | "tvmini" 153 | ) 154 | 155 | ROOT_SOL_MAP=( 156 | "magisk" 157 | "none" 158 | ) 159 | 160 | COMPRESS_FORMAT_MAP=( 161 | "7z" 162 | "xz" 163 | "zip" 164 | ) 165 | 166 | ARR_TO_STR() { 167 | local arr=("$@") 168 | local joined 169 | printf -v joined "%s, " "${arr[@]}" 170 | echo "${joined%, }" 171 | } 172 | GAPPS_PROPS_MSG1="\033[0;31mWARNING: Services such as the Play Store may stop working properly." 173 | GAPPS_PROPS_MSG2="We are not responsible for any problems caused by this!\033[0m" 174 | GAPPS_PROPS_MSG3="Info: https://support.google.com/android/answer/10248227" 175 | usage() { 176 | default 177 | echo -e " 178 | Usage: 179 | --arch Architecture of WSA. 180 | 181 | Possible values: $(ARR_TO_STR "${ARCH_MAP[@]}") 182 | Default: $ARCH 183 | 184 | --release-type Release type of WSA. 185 | RP means Release Preview, WIS means Insider Slow, WIF means Insider Fast. 186 | 187 | Possible values: $(ARR_TO_STR "${RELEASE_TYPE_MAP[@]}") 188 | Default: $RELEASE_TYPE 189 | 190 | --magisk-ver Magisk version. 191 | 192 | Possible values: $(ARR_TO_STR "${MAGISK_VER_MAP[@]}") 193 | Default: $MAGISK_VER 194 | 195 | --gapps-brand GApps brand. 196 | \"none\" for no integration of GApps 197 | 198 | Possible values: $(ARR_TO_STR "${GAPPS_BRAND_MAP[@]}") 199 | Default: $GAPPS_BRAND 200 | 201 | --gapps-variant GApps variant. 202 | 203 | Possible values: $(ARR_TO_STR "${GAPPS_VARIANT_MAP[@]}") 204 | Default: $GAPPS_VARIANT 205 | 206 | --root-sol Root solution. 207 | \"none\" means no root. 208 | 209 | Possible values: $(ARR_TO_STR "${ROOT_SOL_MAP[@]}") 210 | Default: $ROOT_SOL 211 | 212 | --compress-format 213 | Compress format of output file. 214 | If this option is not specified and --compress is not specified, the generated file will not be compressed 215 | 216 | Possible values: $(ARR_TO_STR "${COMPRESS_FORMAT_MAP[@]}") 217 | 218 | Additional Options: 219 | --remove-amazon Remove Amazon Appstore from the system 220 | --compress Compress the WSA, The default format is 7z, you can use the format specified by --compress-format 221 | --offline Build WSA offline 222 | --magisk-custom Install custom Magisk 223 | --skip-download-wsa Skip download WSA 224 | --debug Debug build mode 225 | --help Show this help message and exit 226 | --nofix-props No fix \"build.prop\" 227 | $GAPPS_PROPS_MSG1 228 | $GAPPS_PROPS_MSG2 229 | $GAPPS_PROPS_MSG3 230 | 231 | Example: 232 | ./build.sh --release-type RP --magisk-ver beta --gapps-variant pico --remove-amazon 233 | ./build.sh --arch arm64 --release-type WIF --gapps-brand OpenGApps --nofix-props 234 | ./build.sh --release-type WIS --gapps-brand none 235 | ./build.sh --offline --gapps-variant pico --magisk-custom 236 | " 237 | } 238 | 239 | ARGUMENT_LIST=( 240 | "arch:" 241 | "release-type:" 242 | "magisk-ver:" 243 | "gapps-brand:" 244 | "gapps-variant:" 245 | "nofix-props" 246 | "root-sol:" 247 | "compress-format:" 248 | "remove-amazon" 249 | "compress" 250 | "offline" 251 | "magisk-custom" 252 | "debug" 253 | "help" 254 | "skip-download-wsa" 255 | ) 256 | 257 | default 258 | 259 | opts=$( 260 | getopt \ 261 | --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ 262 | --name "$(basename "$0")" \ 263 | --options "" \ 264 | -- "$@" 265 | ) || exit_with_message "Failed to parse options, please check your input" 266 | 267 | eval set --"$opts" 268 | while [[ $# -gt 0 ]]; do 269 | case "$1" in 270 | --arch ) ARCH="$2"; shift 2 ;; 271 | --release-type ) RELEASE_TYPE="$2"; shift 2 ;; 272 | --gapps-brand ) GAPPS_BRAND="$2"; shift 2 ;; 273 | --gapps-variant ) GAPPS_VARIANT="$2"; shift 2 ;; 274 | --nofix-props ) NOFIX_PROPS="yes"; shift ;; 275 | --root-sol ) ROOT_SOL="$2"; shift 2 ;; 276 | --compress-format ) COMPRESS_FORMAT="$2"; shift 2 ;; 277 | --remove-amazon ) REMOVE_AMAZON="yes"; shift ;; 278 | --compress ) COMPRESS_OUTPUT="yes"; shift ;; 279 | --offline ) OFFLINE="on"; shift ;; 280 | --magisk-custom ) CUSTOM_MAGISK="debug"; shift ;; 281 | --magisk-ver ) MAGISK_VER="$2"; shift 2 ;; 282 | --debug ) DEBUG="on"; shift ;; 283 | --skip-download-wsa ) DOWN_WSA="no"; shift ;; 284 | --help ) usage; exit 0 ;; 285 | -- ) shift; break;; 286 | esac 287 | done 288 | 289 | if [ "$CUSTOM_MAGISK" ]; then 290 | if [ -z "$MAGISK_VER" ]; then 291 | MAGISK_VER=$CUSTOM_MAGISK 292 | fi 293 | fi 294 | 295 | check_list() { 296 | local input=$1 297 | if [ -n "$input" ]; then 298 | local name=$2 299 | shift 300 | local arr=("$@") 301 | local list_count=${#arr[@]} 302 | for i in "${arr[@]}"; do 303 | if [ "$input" == "$i" ]; then 304 | echo "INFO: $name: $input" 305 | break 306 | fi 307 | ((list_count--)) 308 | if (("$list_count" <= 0)); then 309 | exit_with_message "Invalid $name: $input" 310 | fi 311 | done 312 | fi 313 | } 314 | 315 | check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}" 316 | check_list "$RELEASE_TYPE" "Release Type" "${RELEASE_TYPE_MAP[@]}" 317 | check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}" 318 | check_list "$GAPPS_BRAND" "GApps Brand" "${GAPPS_BRAND_MAP[@]}" 319 | check_list "$GAPPS_VARIANT" "GApps Variant" "${GAPPS_VARIANT_MAP[@]}" 320 | check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}" 321 | check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}" 322 | 323 | if [ "$DEBUG" ]; then 324 | set -x 325 | fi 326 | 327 | require_su() { 328 | if test "$(id -u)" != "0"; then 329 | if [ -z "$SUDO" ] || [ "$($SUDO id -u)" != "0" ]; then 330 | echo "ROOT/SUDO is required to run this script" 331 | abort 332 | fi 333 | fi 334 | } 335 | 336 | declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast") 337 | declare -A ANDROID_API_MAP=(["30"]="11.0" ["32"]="12.1" ["33"]="13.0") 338 | RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort 339 | 340 | echo -e "Build: RELEASE_TYPE=$RELEASE_NAME" 341 | 342 | WSA_ZIP_PATH=$DOWNLOAD_DIR/wsa-$RELEASE_TYPE.zip 343 | vclibs_PATH=$DOWNLOAD_DIR/Microsoft.VCLibs."$ARCH".14.00.Desktop.appx 344 | xaml_PATH=$DOWNLOAD_DIR/Microsoft.UI.Xaml_"$ARCH".appx 345 | MAGISK_ZIP=magisk-$MAGISK_VER.zip 346 | MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP 347 | if [ "$CUSTOM_MAGISK" ]; then 348 | if [ ! -f "$MAGISK_PATH" ]; then 349 | echo "Custom Magisk $MAGISK_ZIP not found" 350 | MAGISK_ZIP=app-$MAGISK_VER.apk 351 | echo "Fallback to $MAGISK_ZIP" 352 | MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP 353 | if [ ! -f "$MAGISK_PATH" ]; then 354 | echo -e "Custom Magisk $MAGISK_ZIP not found\nPlease put custom Magisk in $DOWNLOAD_DIR" 355 | abort 356 | fi 357 | fi 358 | fi 359 | ANDROID_API=33 360 | update_gapps_zip_name() { 361 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 362 | ANDROID_API=30 363 | GAPPS_ZIP_NAME="$GAPPS_BRAND-$ARCH-${ANDROID_API_MAP[$ANDROID_API]}-$GAPPS_VARIANT".zip 364 | else 365 | GAPPS_ZIP_NAME="$GAPPS_BRAND-$ARCH-${ANDROID_API_MAP[$ANDROID_API]}".zip 366 | fi 367 | GAPPS_PATH=$DOWNLOAD_DIR/$GAPPS_ZIP_NAME 368 | } 369 | update_gapps_zip_name 370 | if [ -z "${OFFLINE+x}" ]; then 371 | require_su 372 | if [ "${DOWN_WSA}" != "no" ]; then 373 | echo "Generate Download Links" 374 | python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort 375 | # shellcheck disable=SC1091 376 | source "${WORK_DIR:?}/ENV" || abort 377 | else 378 | DOWN_WSA_MAIN_VERSION=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") 379 | fi 380 | if [[ "$DOWN_WSA_MAIN_VERSION" -lt 2211 ]]; then 381 | ANDROID_API=32 382 | update_gapps_zip_name 383 | fi 384 | if [ -z "${CUSTOM_MAGISK+x}" ]; then 385 | python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort 386 | fi 387 | if [ "$GAPPS_BRAND" != "none" ]; then 388 | python3 generateGappsLink.py "$ARCH" "$GAPPS_BRAND" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$ANDROID_API" "$GAPPS_ZIP_NAME" || abort 389 | fi 390 | 391 | echo "Download Artifacts" 392 | if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 --async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then 393 | echo "We have encountered an error while downloading files." 394 | exit 1 395 | fi 396 | else # Offline mode 397 | DOWN_WSA_MAIN_VERSION=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") 398 | if [[ "$DOWN_WSA_MAIN_VERSION" -lt 2211 ]]; then 399 | ANDROID_API=32 400 | update_gapps_zip_name 401 | fi 402 | declare -A FILES_CHECK_LIST=([WSA_ZIP_PATH]="$WSA_ZIP_PATH" [xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [MAGISK_PATH]="$MAGISK_PATH") 403 | for i in "${FILES_CHECK_LIST[@]}"; do 404 | if [ ! -f "$i" ]; then 405 | echo "Offline mode: missing [$i]." 406 | OFFLINE_ERR="1" 407 | fi 408 | done 409 | if [ "$GAPPS_BRAND" != 'none' ]; then 410 | if [ ! -f "$GAPPS_PATH" ]; then 411 | echo "Offline mode: missing [$GAPPS_PATH]." 412 | OFFLINE_ERR="1" 413 | fi 414 | fi 415 | if [ "$OFFLINE_ERR" ]; then 416 | echo "Offline mode: Some files are missing, please disable offline mode." 417 | exit 1 418 | fi 419 | require_su 420 | fi 421 | 422 | echo "Extract WSA" 423 | if [ -f "$WSA_ZIP_PATH" ]; then 424 | if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR"; then 425 | echo "Unzip WSA failed, is the download incomplete?" 426 | CLEAN_DOWNLOAD_WSA=1 427 | abort 428 | fi 429 | echo -e "Extract done\n" 430 | # shellcheck disable=SC1091 431 | source "${WORK_DIR:?}/ENV" || abort 432 | else 433 | echo "The WSA zip package does not exist, is the download incomplete?" 434 | exit 1 435 | fi 436 | 437 | echo "Extract Magisk" 438 | if [ -f "$MAGISK_PATH" ]; then 439 | MAGISK_VERSION_NAME="" 440 | MAGISK_VERSION_CODE=0 441 | if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then 442 | echo "Unzip Magisk failed, is the download incomplete?" 443 | CLEAN_DOWNLOAD_MAGISK=1 444 | abort 445 | fi 446 | # shellcheck disable=SC1091 447 | source "${WORK_DIR:?}/ENV" || abort 448 | $SUDO patchelf --replace-needed libc.so "../linker/$HOST_ARCH/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort 449 | $SUDO patchelf --replace-needed libm.so "../linker/$HOST_ARCH/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort 450 | $SUDO patchelf --replace-needed libdl.so "../linker/$HOST_ARCH/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort 451 | $SUDO chmod +x "../linker/$HOST_ARCH/linker64" || abort 452 | $SUDO patchelf --set-interpreter "../linker/$HOST_ARCH/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort 453 | chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort 454 | elif [ -z "${CUSTOM_MAGISK+x}" ]; then 455 | echo "The Magisk zip package does not exist, is the download incomplete?" 456 | exit 1 457 | else 458 | echo "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder." 459 | exit 1 460 | fi 461 | echo -e "done\n" 462 | 463 | if [ "$GAPPS_BRAND" != 'none' ]; then 464 | echo "Extract $GAPPS_BRAND" 465 | mkdir -p "$WORK_DIR"/gapps || abort 466 | if [ -f "$GAPPS_PATH" ]; then 467 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 468 | if ! unzip -p "$GAPPS_PATH" {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common'; then 469 | echo "Unzip OpenGApps failed, is the download incomplete?" 470 | CLEAN_DOWNLOAD_GAPPS=1 471 | abort 472 | fi 473 | else 474 | if ! unzip "$GAPPS_PATH" "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps; then 475 | echo "Unzip MindTheGapps failed, package is corrupted?" 476 | CLEAN_DOWNLOAD_GAPPS=1 477 | abort 478 | fi 479 | mv "$WORK_DIR"/gapps/system/* "$WORK_DIR"/gapps || abort 480 | rm -rf "${WORK_DIR:?}"/gapps/system || abort 481 | fi 482 | cp -r ../"$ARCH"/gapps/* "$WORK_DIR"/gapps || abort 483 | else 484 | echo "The $GAPPS_BRAND zip package does not exist." 485 | abort 486 | fi 487 | echo -e "Extract done\n" 488 | fi 489 | 490 | echo "Expand images" 491 | if [ ! -f /etc/mtab ]; then $SUDO ln -s /proc/self/mounts /etc/mtab; fi 492 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort 493 | SYSTEM_EXT_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/system_ext.img | cut -f1) + 20000)) 494 | if [ -d "$WORK_DIR"/gapps/system_ext ]; then 495 | SYSTEM_EXT_SIZE=$(( SYSTEM_EXT_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) 496 | fi 497 | resize2fs "$WORK_DIR"/wsa/"$ARCH"/system_ext.img "$SYSTEM_EXT_SIZE"s || abort 498 | 499 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/product.img || abort 500 | PRODUCT_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/product.img | cut -f1) + 20000)) 501 | if [ -d "$WORK_DIR"/gapps/product ]; then 502 | PRODUCT_SIZE=$(( PRODUCT_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps/product | cut -f1) )) 503 | fi 504 | resize2fs "$WORK_DIR"/wsa/"$ARCH"/product.img "$PRODUCT_SIZE"s || abort 505 | 506 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/system.img || abort 507 | SYSTEM_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/system.img | cut -f1) + 20000)) 508 | if [ -d "$WORK_DIR"/gapps ]; then 509 | SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps | cut -f1) - $(du --apparent-size -sB512 "$WORK_DIR"/gapps/product | cut -f1) )) 510 | if [ -d "$WORK_DIR"/gapps/system_ext ]; then 511 | SYSTEM_SIZE=$(( SYSTEM_SIZE - $(du --apparent-size -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) 512 | fi 513 | fi 514 | if [ -d "$WORK_DIR"/magisk ]; then 515 | SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/magisk/magisk | cut -f1) )) 516 | fi 517 | if [ -f "$MAGISK_PATH" ]; then 518 | SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$MAGISK_PATH" | cut -f1) )) 519 | fi 520 | if [ -d "../$ARCH/system" ]; then 521 | SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "../$ARCH/system" | cut -f1) )) 522 | fi 523 | resize2fs "$WORK_DIR"/wsa/"$ARCH"/system.img "$SYSTEM_SIZE"s || abort 524 | 525 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort 526 | VENDOR_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/vendor.img | cut -f1) + 20000)) 527 | resize2fs "$WORK_DIR"/wsa/"$ARCH"/vendor.img "$VENDOR_SIZE"s || abort 528 | echo -e "Expand images done\n" 529 | 530 | echo "Mount images" 531 | $SUDO mkdir "$MOUNT_DIR" || abort 532 | $SUDO mount -vo loop "$WORK_DIR"/wsa/"$ARCH"/system.img "$MOUNT_DIR" || abort 533 | $SUDO mount -vo loop "$WORK_DIR"/wsa/"$ARCH"/vendor.img "$MOUNT_DIR"/vendor || abort 534 | $SUDO mount -vo loop "$WORK_DIR"/wsa/"$ARCH"/product.img "$MOUNT_DIR"/product || abort 535 | $SUDO mount -vo loop "$WORK_DIR"/wsa/"$ARCH"/system_ext.img "$MOUNT_DIR"/system_ext || abort 536 | echo -e "done\n" 537 | 538 | if [ "$REMOVE_AMAZON" ]; then 539 | echo "Remove Amazon Appstore" 540 | find "${MOUNT_DIR:?}"/product/{etc/permissions,etc/sysconfig,framework,priv-app} 2>/dev/null | grep -e amazon -e venezia | $SUDO xargs rm -rf 541 | find "${MOUNT_DIR:?}"/system_ext/{etc/*permissions,framework,priv-app} 2>/dev/null | grep -e amazon -e venezia | $SUDO xargs rm -rf 542 | echo -e "done\n" 543 | fi 544 | 545 | echo "Add device administration features" 546 | $SUDO sed -i -e '/cts/a \ \ \ \ ' -e '/print/i \ \ \ \ ' "$MOUNT_DIR"/vendor/etc/permissions/windows.permissions.xml 547 | $SUDO setfattr -n security.selinux -v "u:object_r:vendor_configs_file:s0" "$MOUNT_DIR"/vendor/etc/permissions/windows.permissions.xml || abort 548 | echo -e "done\n" 549 | 550 | if [ "$ROOT_SOL" = 'magisk' ] || [ "$ROOT_SOL" = '' ]; then 551 | echo "Integrate Magisk" 552 | $SUDO mkdir "$MOUNT_DIR"/sbin 553 | $SUDO setfattr -n security.selinux -v "u:object_r:rootfs:s0" "$MOUNT_DIR"/sbin || abort 554 | $SUDO chown root:root "$MOUNT_DIR"/sbin 555 | $SUDO chmod 0700 "$MOUNT_DIR"/sbin 556 | $SUDO cp "$WORK_DIR"/magisk/magisk/* "$MOUNT_DIR"/sbin/ 557 | $SUDO cp "$MAGISK_PATH" "$MOUNT_DIR"/sbin/magisk.apk 558 | $SUDO tee -a "$MOUNT_DIR"/sbin/loadpolicy.sh </dev/null 559 | #!/system/bin/sh 560 | mkdir -p /data/adb/magisk 561 | cp /sbin/* /data/adb/magisk/ 562 | sync 563 | chmod -R 755 /data/adb/magisk 564 | restorecon -R /data/adb/magisk 565 | for module in \$(ls /data/adb/modules); do 566 | if ! [ -f "/data/adb/modules/\$module/disable" ] && [ -f "/data/adb/modules/\$module/sepolicy.rule" ]; then 567 | /sbin/magiskpolicy --live --apply "/data/adb/modules/\$module/sepolicy.rule" 568 | fi 569 | done 570 | EOF 571 | 572 | $SUDO find "$MOUNT_DIR"/sbin -type f -exec chmod 0755 {} \; 573 | $SUDO find "$MOUNT_DIR"/sbin -type f -exec chown root:root {} \; 574 | $SUDO find "$MOUNT_DIR"/sbin -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 575 | 576 | TMP_PATH=$(Gen_Rand_Str 8) 577 | echo "/dev/$TMP_PATH(/.*)? u:object_r:magisk_file:s0" | $SUDO tee -a "$MOUNT_DIR"/vendor/etc/selinux/vendor_file_contexts 578 | echo '/data/adb/magisk(/.*)? u:object_r:magisk_file:s0' | $SUDO tee -a "$MOUNT_DIR"/vendor/etc/selinux/vendor_file_contexts 579 | $SUDO "$WORK_DIR"/magisk/magiskpolicy --load "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --save "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --magisk "allow * magisk_file lnk_file *" || abort 580 | LOAD_POLICY_SVC_NAME=$(Gen_Rand_Str 12) 581 | PFD_SVC_NAME=$(Gen_Rand_Str 12) 582 | LS_SVC_NAME=$(Gen_Rand_Str 12) 583 | $SUDO tee -a "$MOUNT_DIR"/system/etc/init/hw/init.rc </dev/null 584 | on post-fs-data 585 | start adbd 586 | mkdir /dev/$TMP_PATH 587 | mount tmpfs tmpfs /dev/$TMP_PATH mode=0755 588 | copy /sbin/magisk64 /dev/$TMP_PATH/magisk64 589 | chmod 0755 /dev/$TMP_PATH/magisk64 590 | symlink ./magisk64 /dev/$TMP_PATH/magisk 591 | symlink ./magisk64 /dev/$TMP_PATH/su 592 | symlink ./magisk64 /dev/$TMP_PATH/resetprop 593 | copy /sbin/magisk32 /dev/$TMP_PATH/magisk32 594 | chmod 0755 /dev/$TMP_PATH/magisk32 595 | copy /sbin/magiskinit /dev/$TMP_PATH/magiskinit 596 | chmod 0755 /dev/$TMP_PATH/magiskinit 597 | copy /sbin/magiskpolicy /dev/$TMP_PATH/magiskpolicy 598 | chmod 0755 /dev/$TMP_PATH/magiskpolicy 599 | mkdir /dev/$TMP_PATH/.magisk 700 600 | mkdir /dev/$TMP_PATH/.magisk/mirror 700 601 | mkdir /dev/$TMP_PATH/.magisk/block 700 602 | copy /sbin/magisk.apk /dev/$TMP_PATH/stub.apk 603 | chmod 0644 /dev/$TMP_PATH/stub.apk 604 | rm /dev/.magisk_unblock 605 | exec_start $LOAD_POLICY_SVC_NAME 606 | start $PFD_SVC_NAME 607 | wait /dev/.magisk_unblock 40 608 | rm /dev/.magisk_unblock 609 | 610 | service $LOAD_POLICY_SVC_NAME /system/bin/sh /sbin/loadpolicy.sh 611 | user root 612 | seclabel u:r:magisk:s0 613 | oneshot 614 | 615 | service $PFD_SVC_NAME /dev/$TMP_PATH/magisk --post-fs-data 616 | user root 617 | seclabel u:r:magisk:s0 618 | oneshot 619 | 620 | service $LS_SVC_NAME /dev/$TMP_PATH/magisk --service 621 | class late_start 622 | user root 623 | seclabel u:r:magisk:s0 624 | oneshot 625 | 626 | on property:sys.boot_completed=1 627 | mkdir /data/adb/magisk 755 628 | copy /sbin/magisk.apk /data/adb/magisk/magisk.apk 629 | exec /dev/$TMP_PATH/magisk --boot-complete 630 | 631 | on property:init.svc.zygote=restarting 632 | exec /dev/$TMP_PATH/magisk --zygote-restart 633 | 634 | on property:init.svc.zygote=stopped 635 | exec /dev/$TMP_PATH/magisk --zygote-restart 636 | 637 | EOF 638 | echo -e "Integrate Magisk done\n" 639 | fi 640 | 641 | cp "$WORK_DIR/wsa/$ARCH/resources.pri" "$WORK_DIR"/wsa/pri/en-us.pri \ 642 | && cp "$WORK_DIR/wsa/$ARCH/AppxManifest.xml" "$WORK_DIR"/wsa/xml/en-us.xml && { 643 | echo "Merge Language Resources" 644 | tee "$WORK_DIR"/wsa/priconfig.xml </dev/null 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | EOF 653 | if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ]; then 654 | ../wine/"$HOST_ARCH"/makepri.exe new /pr "$(wslpath -w "$WORK_DIR"/wsa/pri)" /in MicrosoftCorporationII.WindowsSubsystemForAndroid /cf "$(wslpath -w "$WORK_DIR"/wsa/priconfig.xml)" /of "$(wslpath -w "$WORK_DIR"/wsa/"$ARCH"/resources.pri)" /o 655 | elif which wine64 > /dev/null; then 656 | wine64 ../wine/"$HOST_ARCH"/makepri.exe new /pr "$WORK_DIR"/wsa/pri /in MicrosoftCorporationII.WindowsSubsystemForAndroid /cf "$WORK_DIR"/wsa/priconfig.xml /of "$WORK_DIR"/wsa/"$ARCH"/resources.pri /o 657 | else 658 | res_merge_failed=1 659 | fi 660 | [ -z "$res_merge_failed" ] && sed -i -zE "s//\n$(cat "$WORK_DIR"/wsa/xml/* | grep -Po ']*/>' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/\$/\\$/g' | sed 's/\//\\\//g')\n<\/Resources>/g" "$WORK_DIR"/wsa/"$ARCH"/AppxManifest.xml && \ 661 | echo -e "Merge Language Resources done\n" 662 | } && [ -n "$res_merge_failed" ] && echo -e "Merge Language Resources failed\n" && unset res_merge_failed 663 | 664 | echo "Add extra packages" 665 | $SUDO cp -r ../"$ARCH"/system/* "$MOUNT_DIR" || abort 666 | find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -type d -exec chmod 0755 {} \; 667 | find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -type f -exec chmod 0644 {} \; 668 | find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -exec chown root:root {} \; 669 | find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 670 | echo -e "Add extra packages done\n" 671 | 672 | if [ "$GAPPS_BRAND" != 'none' ]; then 673 | echo "Integrate $GAPPS_BRAND" 674 | 675 | find "$WORK_DIR/gapps/" -mindepth 1 -type d -exec $SUDO chmod 0755 {} \; 676 | find "$WORK_DIR/gapps/" -mindepth 1 -type d -exec $SUDO chown root:root {} \; 677 | file_list="$(find "$WORK_DIR/gapps/" -mindepth 1 -type f | cut -d/ -f5-)" 678 | for file in $file_list; do 679 | $SUDO chown root:root "$WORK_DIR/gapps/${file}" 680 | $SUDO chmod 0644 "$WORK_DIR/gapps/${file}" 681 | done 682 | 683 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 684 | find "$WORK_DIR"/gapps/ -maxdepth 1 -mindepth 1 -type d -not -path '*product' -exec $SUDO cp --preserve=all -r {} "$MOUNT_DIR"/system \; || abort 685 | elif [ "$GAPPS_BRAND" = "MindTheGapps" ]; then 686 | $SUDO cp --preserve=all -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort 687 | if [ -e "$MOUNT_DIR"/system_ext/priv-app/SetupWizard ]; then 688 | rm -rf "${MOUNT_DIR:?}/system_ext/priv-app/Provision" 689 | fi 690 | fi 691 | $SUDO cp --preserve=all -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort 692 | 693 | find "$WORK_DIR"/gapps/product/overlay -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/overlay/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:vendor_overlay_file:s0" {} \; || abort 694 | 695 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 696 | find "$WORK_DIR"/gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/app/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 697 | find "$WORK_DIR"/gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/framework/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 698 | find "$WORK_DIR"/gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 699 | find "$WORK_DIR"/gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/app/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 700 | find "$WORK_DIR"/gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/framework/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 701 | find "$WORK_DIR"/gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/priv-app/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 702 | find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/etc/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 703 | find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system/etc/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 704 | else 705 | find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/app/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 706 | find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/etc/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 707 | find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/priv-app/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 708 | find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/framework/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 709 | 710 | find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/app/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 711 | find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/etc/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 712 | find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/priv-app/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 713 | find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/framework/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 714 | find "$WORK_DIR"/gapps/system_ext/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system_ext/etc/permissions/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 715 | 716 | $SUDO setfattr -n security.selinux -v "u:object_r:system_lib_file:s0" "$MOUNT_DIR"/product/lib || abort 717 | find "$WORK_DIR"/gapps/product/lib/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/lib/placeholder -exec setfattr -n security.selinux -v "u:object_r:system_lib_file:s0" {} \; || abort 718 | find "$WORK_DIR"/gapps/product/lib64/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/product/lib64/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_lib_file:s0" {} \; || abort 719 | find "$WORK_DIR"/gapps/system_ext/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system_ext/priv-app/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 720 | find "$WORK_DIR"/gapps/system_ext/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system_ext/etc/placeholder -type d -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 721 | find "$WORK_DIR"/gapps/system_ext/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I placeholder $SUDO find "$MOUNT_DIR"/system_ext/priv-app/placeholder -type f -exec setfattr -n security.selinux -v "u:object_r:system_file:s0" {} \; || abort 722 | fi 723 | 724 | $SUDO "$WORK_DIR"/magisk/magiskpolicy --load "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --save "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" "allow gmscore_app system_server_tmpfs filesystem getattr" "allow gmscore_app gpu_device dir search" || abort 725 | echo -e "Integrate $GAPPS_BRAND done\n" 726 | fi 727 | 728 | if [ "$GAPPS_BRAND" != 'none' ]; then 729 | if [ "$NOFIX_PROPS" ]; then 730 | echo -e "Skip fix $GAPPS_BRAND prop!\n$GAPPS_PROPS_MSG1\n$GAPPS_PROPS_MSG2\n$GAPPS_PROPS_MSG3\n" 731 | else 732 | echo "Fix $GAPPS_BRAND prop" 733 | $SUDO python3 fixGappsProp.py "$MOUNT_DIR" || abort 734 | echo -e "done\n" 735 | fi 736 | fi 737 | 738 | echo "Umount images" 739 | $SUDO find "$MOUNT_DIR" -exec touch -ht 200901010000.00 {} \; 740 | $SUDO umount -v "$MOUNT_DIR"/vendor 741 | $SUDO umount -v "$MOUNT_DIR"/product 742 | $SUDO umount -v "$MOUNT_DIR"/system_ext 743 | $SUDO umount -v "$MOUNT_DIR" 744 | echo -e "done\n" 745 | 746 | echo "Shrink images" 747 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/system.img || abort 748 | resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/system.img || abort 749 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort 750 | resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort 751 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/product.img || abort 752 | resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/product.img || abort 753 | e2fsck -pf "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort 754 | resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort 755 | echo -e "Shrink images done\n" 756 | 757 | echo "Remove signature and add scripts" 758 | $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 759 | cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR"/wsa/"$ARCH" || abort 760 | cp ../installer/Install.ps1 "$WORK_DIR"/wsa/"$ARCH" || abort 761 | cp ../installer/Run.bat "$WORK_DIR"/wsa/"$ARCH" || abort 762 | find "$WORK_DIR"/wsa/"$ARCH" -maxdepth 1 -mindepth 1 -printf "%P\n" > "$WORK_DIR"/wsa/"$ARCH"/filelist.txt || abort 763 | echo -e "Remove signature and add scripts done\n" 764 | 765 | echo "Generate info" 766 | 767 | if [[ "$ROOT_SOL" = "none" ]]; then 768 | name1="" 769 | elif [ "$ROOT_SOL" = "" ] || [ "$ROOT_SOL" = "magisk" ]; then 770 | name1="-with-magisk-$MAGISK_VERSION_NAME($MAGISK_VERSION_CODE)-$MAGISK_VER" 771 | else 772 | name1="-with-$ROOT_SOL-$MAGISK_VER" 773 | fi 774 | if [ "$GAPPS_BRAND" = "none" ]; then 775 | name2="-NoGApps" 776 | else 777 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 778 | name2="-$GAPPS_BRAND-${ANDROID_API_MAP[$ANDROID_API]}-${GAPPS_VARIANT}" 779 | else 780 | name2="-$GAPPS_BRAND-${ANDROID_API_MAP[$ANDROID_API]}" 781 | fi 782 | if [ "$GAPPS_BRAND" = "OpenGApps" ]; then 783 | echo -e "\033[0;31m:warning: Since $GAPPS_BRAND doesn't officially support Android 12.1 and 13 yet, lock the variant to pico! 784 | $GAPPS_BRAND may cause startup failure 785 | \033[0m" 786 | fi 787 | fi 788 | artifact_name="WSA_${WSA_VER}_${ARCH}_${WSA_REL}${name1}${name2}" 789 | if [ "$NOFIX_PROPS" = "yes" ]; then 790 | artifact_name+="-NoFixProps" 791 | fi 792 | if [ "$REMOVE_AMAZON" = "yes" ]; then 793 | artifact_name+="-RemovedAmazon" 794 | fi 795 | echo "$artifact_name" 796 | echo -e "\nFinishing building...." 797 | if [ -f "$OUTPUT_DIR" ]; then 798 | $SUDO rm -rf "${OUTPUT_DIR:?}" 799 | fi 800 | if [ ! -d "$OUTPUT_DIR" ]; then 801 | mkdir -p "$OUTPUT_DIR" 802 | fi 803 | OUTPUT_PATH="${OUTPUT_DIR:?}/$artifact_name" 804 | if [ "$COMPRESS_OUTPUT" ] || [ -n "$COMPRESS_FORMAT" ]; then 805 | mv "$WORK_DIR/wsa/$ARCH" "$WORK_DIR/wsa/$artifact_name" 806 | if [ -z "$COMPRESS_FORMAT" ]; then 807 | COMPRESS_FORMAT="7z" 808 | fi 809 | if [ -n "$COMPRESS_FORMAT" ]; then 810 | FILE_EXT=".$COMPRESS_FORMAT" 811 | if [ "$FILE_EXT" = ".xz" ]; then 812 | FILE_EXT=".tar$FILE_EXT" 813 | fi 814 | OUTPUT_PATH="$OUTPUT_PATH$FILE_EXT" 815 | fi 816 | rm -f "${OUTPUT_PATH:?}" || abort 817 | if [ "$COMPRESS_FORMAT" = "7z" ]; then 818 | echo "Compressing with 7z" 819 | 7z a "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort 820 | elif [ "$COMPRESS_FORMAT" = "xz" ]; then 821 | echo "Compressing with tar xz" 822 | if ! (tar -cP -I 'xz -9 -T0' -f "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name"); then 823 | echo "Out of memory? Trying again with single threads..." 824 | tar -cPJvf "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort 825 | fi 826 | elif [ "$COMPRESS_FORMAT" = "zip" ]; then 827 | 7z -tzip a "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort 828 | fi 829 | else 830 | rm -rf "${OUTPUT_PATH:?}" || abort 831 | cp -r "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_PATH" || abort 832 | fi 833 | echo -e "done\n" 834 | 835 | echo "Cleanup Work Directory" 836 | $SUDO rm -rf "${WORK_DIR:?}" 837 | echo "done" 838 | --------------------------------------------------------------------------------