Skip to content

Commit

Permalink
All work done in local host.
Browse files Browse the repository at this point in the history
Remove Action.
  • Loading branch information
Howard20181 committed Aug 14, 2022
1 parent 79f2d86 commit 555c643
Show file tree
Hide file tree
Showing 11 changed files with 790 additions and 751 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text eol=lf
*.exe binary
718 changes: 0 additions & 718 deletions .github/workflows/magisk.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
download
output
43 changes: 10 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,15 @@
- Merged all language packs
- Support managing start menu icons (manually installing [WSAHelper](https://github.com/LSPosed/WSAHelper/releases/latest) to use this feature)

## Video Guide

https://user-images.githubusercontent.com/5022927/145696886-e13ebfc1-ff25-4410-893e-d3e517af70ea.mp4

## Text Guide

1. Star (if you like) and fork this repo (keep it PUBLIC, private repo is not supported)
1. Go to the **Action** tab in your forked repo
![Action Tab](https://docs.github.com/assets/images/help/repository/actions-tab.png)
1. In the left sidebar, click the **Build WSA** workflow.
![Workflow](https://docs.github.com/assets/images/actions-select-workflow.png)
1. Above the list of workflow runs, select **Run workflow**
![Run Workflow](https://docs.github.com/assets/images/actions-workflow-dispatch.png)
1. Select the version of Magisk and select the [OpenGApps variant](https://github.com/opengapps/opengapps/wiki#variants) (none is no OpenGApps) you like, select the root solution (none means no root), select WSA version and its architecture (mostly x64) and click **Run workflow**
![Run Workflow](https://docs.github.com/assets/images/actions-manually-run-workflow.png)
1. Wait for the action to complete and download the artifact **DO NOT download it via multithread downloaders like IDM or ADM**
![Download](https://docs.github.com/assets/images/help/repository/artifact-drop-down-updated.png)
1. Unzip the artifact
- The size shown in the webpage is uncompressed size and the zip you download will be compressed. So the size of the zip will be much less than the size shown in the webpage.
1. Clone the repo to local
1. Run `scripts/run.sh`
1. Select the version of Magisk and select the [OpenGApps variant](https://github.com/opengapps/opengapps/wiki#variants) you like, select the root solution (none means no root), select WSA version and its architecture (mostly x64)
1. Wait for the script to complete and the artifact will in `output` folder

1. Move the artifact to a places you like
1. Right-click `Install.ps1` and select `Run with PowerShell`
- If you previously have a MagiskOnWSA installation, it will automatically uninstall the previous while **preserving all userdata** and install the new one, so don't worry about your data.
- 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.) (If you want to restore the icons to start menu, please install and use [WSAHelper](https://github.com/LSPosed/WSAHelper/releases/latest).)
Expand All @@ -46,26 +36,13 @@ https://user-images.githubusercontent.com/5022927/145696886-e13ebfc1-ff25-4410-8

## FAQ

- Actions workflow task `Delete workflow runs` run Failed

Check workflow permissions, should be `Read and write permissions`

![permissions](https://user-images.githubusercontent.com/40033067/168649322-dadaafc9-dd31-4922-afe1-8aa933b7b036.png)

Read the [Github Docs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions) to find out how to change this setting

- Why should we delete old workflow runs?

Keeping old workflow runs can take up a lot of storage resources and is suspected to be abusive, which can lead to banning.
- Can I delete the unzipped folder?
- Can I delete the installed folder?

No.
- Why the size of the zip does not match the one shown?

The zip you downloaded is compressed and Github is showing the uncompressed size.
- How can I update WSA to new version?

Rerun the Github action, download the new artifact, replace the content of your previous installation and rerun `Install.ps1`. Don't worry, your data will be preserved.
Delete `download` folder
Rerun the script, replace the content of your previous installation and rerun `Install.ps1`. Don't worry, your data will be preserved.
- How can I get the logcat from WSA?

`%LOCALAPPDATA%\Packages\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe\LocalState\diagnostics\logcat`
Expand Down Expand Up @@ -93,7 +70,7 @@ https://user-images.githubusercontent.com/5022927/145696886-e13ebfc1-ff25-4410-8
- How can I get rid of Magisk?

Choose `none` as root solution.
- Github Action script is updated, how can I synchronize it?
- Github script is updated, how can I synchronize it?

1. In your fork repository, click `fetch upstream`
![fetch](https://docs.github.com/assets/cb-33284/images/help/repository/fetch-upstream-drop-down.png)
Expand Down
43 changes: 43 additions & 0 deletions scripts/downloadGapps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/python

import sys

import requests
import zipfile
import os
import urllib.request
import json
import re
from pathlib import Path

if not os.path.exists(Path.cwd().parent / "download"):
os.makedirs(Path.cwd().parent / "download")
download_dir = Path.cwd().parent / "download"

arch = sys.argv[1]
# TODO: Keep it pico since other variants of opengapps are unable to boot successfully
variant = sys.argv[2] if 0 else "pico"
abi_map = {"x64": "x86_64", "arm64": "arm64"}
# TODO: keep it 11.0 since opengapps does not support 12+ yet
# As soon as opengapps is available for 12+, we need to get the sdk/release from build.prop and
# download the corresponding version
release = "11.0"
try:
res = requests.get(f"https://api.opengapps.org/list")
j = json.loads(res.content)
link = {i["name"]: i for i in j["archs"][abi_map[arch]]
["apis"][release]["variants"]}[variant]["zip"]
except Exception:
print("Failed to fetch from opengapps api, fallbacking to sourceforge rss...")
res = requests.get(
f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100')
link = re.search(f'https://.*{abi_map[arch]}/.*{release}.*{variant}.*\.zip/download', res.text).group().replace(
'.zip/download', '.zip').replace('sourceforge.net/projects/opengapps/files', 'downloads.sourceforge.net/project/opengapps')

print(f"downloading link: {link}", flush=True)

out_file = download_dir / "gapps.zip"

if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file)
print("done", flush=True)
75 changes: 75 additions & 0 deletions scripts/downloadMagisk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/python

import sys

import urllib.request
import zipfile
import os
import json
import requests
from pathlib import Path

magisk_apk = sys.argv[2]

if not os.path.exists(Path.cwd().parent / "download"):
os.makedirs(Path.cwd().parent / "download")
download_dir = Path.cwd().parent / "download"

if not os.path.exists(Path.cwd().parent / "workdir" / "magisk"):
os.makedirs(Path.cwd().parent / "workdir" / "magisk")
workdir = Path.cwd().parent / "workdir" / "magisk"

if not magisk_apk:
magisk_apk = "stable"
if magisk_apk == "stable" or magisk_apk == "beta" or magisk_apk == "canary" or magisk_apk == "debug":
magisk_apk = json.loads(requests.get(
f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_apk}.json").content)['magisk']['link']

out_file = download_dir / "magisk.zip"

arch = sys.argv[1]

abi_map = {"x64": ["x86_64", "x86"], "arm64": ["arm64-v8a", "armeabi-v7a"]}

if not os.path.isfile(out_file):
urllib.request.urlretrieve(magisk_apk, out_file)


def extract_as(zip, name, as_name, dir):
info = zip.getinfo(name)
info.filename = as_name
zip.extract(info, workdir / dir)


with zipfile.ZipFile(out_file) as zip:
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libmagisk64.so", "magisk64", "magisk")
extract_as(
zip, f"lib/{ abi_map[arch][1] }/libmagisk32.so", "magisk32", "magisk")
standalone_policy = False
try:
zip.getinfo(f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so")
standalone_policy = True
except:
pass
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskinit", "magisk")
if standalone_policy:
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libmagiskpolicy.so", "magiskpolicy", "magisk")
else:
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskpolicy", "magisk")
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libmagiskboot.so", "magiskboot", "magisk")
extract_as(
zip, f"lib/{ abi_map[arch][0] }/libbusybox.so", "busybox", "magisk")
if standalone_policy:
extract_as(
zip, f"lib/{ abi_map['x64'][0] }/libmagiskpolicy.so", "magiskpolicy", ".")
else:
extract_as(
zip, f"lib/{ abi_map['x64'][0] }/libmagiskinit.so", "magiskpolicy", ".")
extract_as(zip, f"assets/boot_patch.sh", "boot_patch.sh", "magisk")
extract_as(zip, f"assets/util_functions.sh",
"util_functions.sh", "magisk")
90 changes: 90 additions & 0 deletions scripts/downloadWSA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/python

import sys

import requests
from xml.dom import minidom
import html
import warnings
import re
import zipfile
import os
import urllib.request
from pathlib import Path

warnings.filterwarnings("ignore")

arch = sys.argv[1]
release_type_map = {"retail": "Retail", "release preview": "RP",
"insider slow": "WIS", "insider fast": "WIF"}
release_type = release_type_map[sys.argv[2]] if sys.argv[2] != "" else "Retail"

cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
print("arch=" + arch + " release_type=" + release_type)

with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f:
cookie_content = f.read()

out = requests.post(
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
data=cookie_content,
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
verify=False
)
doc = minidom.parseString(out.text)
cookie = doc.getElementsByTagName('EncryptedData')[0].firstChild.nodeValue

print(cookie)

with open(Path.cwd().parent / "xml/WUIDRequest.xml", "r") as f:
cat_id_content = f.read().format(cookie, cat_id, release_type)

out = requests.post(
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx',
data=cat_id_content,
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
verify=False
)

doc = minidom.parseString(html.unescape(out.text))

filenames = {}
for node in doc.getElementsByTagName('Files'):
filenames[node.parentNode.parentNode.getElementsByTagName(
'ID')[0].firstChild.nodeValue] = f"{node.firstChild.attributes['InstallerSpecificIdentifier'].value}_{node.firstChild.attributes['FileName'].value}"
pass

identities = []
for node in doc.getElementsByTagName('SecuredFragment'):
filename = filenames[node.parentNode.parentNode.parentNode.getElementsByTagName('ID')[
0].firstChild.nodeValue]
update_identity = node.parentNode.parentNode.firstChild
identities += [(update_identity.attributes['UpdateID'].value,
update_identity.attributes['RevisionNumber'].value, filename)]

with open(Path.cwd().parent / "xml/FE3FileUrl.xml", "r") as f:
file_content = f.read()
if not os.path.exists(Path.cwd().parent / "download"):
os.makedirs(Path.cwd().parent / "download")
for i, v, f in identities:
if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f):
out_file = Path.cwd().parent / "download/xaml.appx"
elif re.match(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx", f):
out_file = Path.cwd().parent / "download/vclibs.appx"
elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", f):
out_file = Path.cwd().parent / "download/wsa.zip"
else:
continue
out = requests.post(
'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured',
data=file_content.format(i, v, release_type),
headers={'Content-Type': 'application/soap+xml; charset=utf-8'},
verify=False
)
doc = minidom.parseString(out.text)
for l in doc.getElementsByTagName("FileLocation"):
url = l.getElementsByTagName("Url")[0].firstChild.nodeValue
if len(url) != 99:
if not os.path.isfile(out_file):
print(f"downloading link: {url} to {out_file}", flush=True)
urllib.request.urlretrieve(url, out_file)
60 changes: 60 additions & 0 deletions scripts/extractWSA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/python

import sys

import requests
from xml.dom import minidom
import html
import warnings
import re
import zipfile
import os
import urllib.request
from pathlib import Path

warnings.filterwarnings("ignore")

arch = sys.argv[1]

if not os.path.exists(Path.cwd().parent / "workdir" / "wsa"):
os.makedirs(Path.cwd().parent / "workdir" / "wsa")
zip_name = ""
workdir = Path.cwd().parent / "workdir" / "wsa"
with zipfile.ZipFile(Path.cwd().parent / "download/wsa.zip") as zip:
for f in zip.filelist:
if arch in f.filename.lower():
zip_name = f.filename
if not os.path.isfile(workdir / zip_name):
zip_path = workdir / zip_name
print(f"unzipping to {workdir}", flush=True)
zip.extract(f, workdir)
ver_no = zip_name.split("_")
long_ver = ver_no[1]
ver = long_ver.split(".")
main_ver = ver[0]
with open(os.environ['WSA_WORK_ENV'], 'a') as g:
g.write(f'WSA_VER={long_ver}\n')
with open(os.environ['WSA_WORK_ENV'], 'a') as g:
g.write(f'WSA_MAIN_VER={main_ver}\n')
rel = ver_no[3].split(".")
rell = str(rel[0])
with open(os.environ['WSA_WORK_ENV'], 'a') as g:
g.write(f'WSA_REL={rell}\n')
if 'language' in f.filename.lower() or 'scale' in f.filename.lower():
name = f.filename.split("-", 1)[1].split(".")[0]
zip.extract(f, workdir)
with zipfile.ZipFile(workdir / f.filename) as l:
for g in l.filelist:
if g.filename == 'resources.pri':
g.filename = f'{name}.pri'
l.extract(g, workdir / 'pri')
print(f"extract resource pack {g.filename}")
elif g.filename == 'AppxManifest.xml':
g.filename = f'{name}.xml'
l.extract(g, workdir / 'xml')
with zipfile.ZipFile(zip_path) as zip:
if not os.path.isdir(workdir / arch):
print(f"unzipping from {zip_path}", flush=True)
zip.extractall(workdir / arch)

print("done", flush=True)
Loading

0 comments on commit 555c643

Please sign in to comment.