forked from LSPosed/MagiskOnWSALocal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
790 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text eol=lf | ||
*.exe binary |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
download | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.