mirror of
https://github.com/LSPosed/MagiskOnWSALocal.git
synced 2025-04-14 04:29:09 +00:00
Merge pull request #776 from LSPosed/lspinit
This commit is contained in:
commit
41aec53b2c
34 changed files with 419 additions and 1017 deletions
.gitignore
arm64
gapps/product
system/priv-app/VpnDialogs
bin
installer
linker
scripts
build.shextractMagisk.pyextractWSA.pyfixGappsProp.pygenerateGappsLink.pygenerateKernelSULink.pygenerateMagiskLink.pygenerateWSALinks.pygetWSAMajorVersion.pyinit.lsp.magisk.rcpost-fs-data.shsepolicy.rule
x64
gapps/product
system/priv-app/VpnDialogs
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
download
|
||||
output
|
||||
python3-env
|
||||
token
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This file is part of MagiskOnWSALocal.
|
||||
|
||||
MagiskOnWSALocal is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
MagiskOnWSALocal is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright (C) 2023 LSPosed Contributors
|
||||
-->
|
||||
<config>
|
||||
<component-override package="com.android.vending">
|
||||
<!-- Conflicts with WSA's built-in package verifier, disable to prevent boot loops. -->
|
||||
<component class="com.google.android.finsky.verifier.impl.PackageVerificationReceiver" enabled="false" />
|
||||
<!-- Disable stock OTA components if installed -->
|
||||
<component class="com.google.android.finsky.systemupdate.SystemUpdateSettingsContentProvider" enabled="false" />
|
||||
<component class="com.google.android.finsky.systemupdateactivity.SettingsSecurityEntryPoint" enabled="false" />
|
||||
<component class="com.google.android.finsky.systemupdateactivity.SystemUpdateActivity" enabled="false" />
|
||||
</component-override>
|
||||
<component-override package="com.google.android.gms">
|
||||
<component class="com.google.android.gms.update.phone.PopupDialog" enabled="false" />
|
||||
<component class="com.google.android.gms.update.OtaSuggestionSummaryProvider" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateActivity" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateGcmTaskService" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateService" enabled="false" />
|
||||
</component-override>
|
||||
</config>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/arm64/lspinit
Normal file
BIN
bin/arm64/lspinit
Normal file
Binary file not shown.
BIN
bin/x64/lspinit
Normal file
BIN
bin/x64/lspinit
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
# Copyright (C) 2024 LSPosed Contributors
|
||||
#
|
||||
|
||||
$Host.UI.RawUI.WindowTitle = "Installing MagiskOnWSA...."
|
||||
|
@ -48,11 +48,6 @@ Function Test-CommandExist {
|
|||
} #end function Test-CommandExist
|
||||
|
||||
Function Finish {
|
||||
Clear-Host
|
||||
If (Test-CommandExist Optimize-VHD) {
|
||||
Write-Output "Optimizing VHDX size...."
|
||||
Optimize-VHD ".\*.vhdx" -Mode Full
|
||||
}
|
||||
Clear-Host
|
||||
Start-Process "wsa://com.topjohnwu.magisk"
|
||||
Start-Process "wsa://com.android.vending"
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
896
scripts/build.sh
896
scripts/build.sh
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
# Copyright (C) 2024 LSPosed Contributors
|
||||
#
|
||||
|
||||
import sys
|
||||
|
@ -47,9 +47,8 @@ is_x86_64 = platform.machine() in ("AMD64", "x86_64")
|
|||
host_abi = "x64" if is_x86_64 else "arm64"
|
||||
arch = sys.argv[1]
|
||||
magisk_zip = sys.argv[2]
|
||||
workdir = Path(sys.argv[3]) / "magisk"
|
||||
if not Path(workdir).is_dir():
|
||||
workdir.mkdir()
|
||||
workdir = Path(sys.argv[3])
|
||||
workdir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
abi_map = {"x64": ["x86_64", "x86"], "arm64": ["arm64-v8a", "armeabi-v7a"]}
|
||||
|
||||
|
@ -65,40 +64,14 @@ with zipfile.ZipFile(magisk_zip) as zip:
|
|||
versionName = props.get("version")
|
||||
versionCode = props.get("versionCode")
|
||||
print(f"Magisk version: {versionName} ({versionCode})", flush=True)
|
||||
with open(os.environ['WSA_WORK_ENV'], 'r') as environ_file:
|
||||
env = Prop(environ_file.read())
|
||||
env.MAGISK_VERSION_NAME = versionName
|
||||
env.MAGISK_VERSION_CODE = versionCode
|
||||
with open(os.environ['WSA_WORK_ENV'], 'w') as environ_file:
|
||||
environ_file.write(str(env))
|
||||
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[host_abi][0] }/libmagiskpolicy.so", "magiskpolicy", ".")
|
||||
else:
|
||||
extract_as(
|
||||
zip, f"lib/{ abi_map[host_abi][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")
|
||||
if 'WSA_WORK_ENV' in os.environ and Path(os.environ['WSA_WORK_ENV']).is_file():
|
||||
with open(os.environ['WSA_WORK_ENV'], 'r') as environ_file:
|
||||
env = Prop(environ_file.read())
|
||||
env.MAGISK_VERSION_NAME = versionName
|
||||
env.MAGISK_VERSION_CODE = versionCode
|
||||
with open(os.environ['WSA_WORK_ENV'], 'w') as environ_file:
|
||||
environ_file.write(str(env))
|
||||
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")
|
||||
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskinit", "magisk")
|
||||
extract_as(zip, f"lib/{ abi_map[host_abi][0] }/libmagiskboot.so", "magiskboot", "magisk")
|
||||
|
|
|
@ -79,6 +79,10 @@ with zipfile.ZipFile(wsa_zip_path) as zip:
|
|||
if not Path(workdir / zip_name).is_file():
|
||||
print(f"unzipping {zip_name} to {workdir}", flush=True)
|
||||
zip_path = zip.extract(f, workdir)
|
||||
with zipfile.ZipFile(zip_path) as zip:
|
||||
stat = Path(zip_path).stat()
|
||||
print(f"unzipping from {zip_path}", flush=True)
|
||||
zip.extractall(archdir)
|
||||
ver_no = zip_name.split("_")
|
||||
long_ver = ver_no[1]
|
||||
ver = long_ver.split(".")
|
||||
|
@ -106,7 +110,3 @@ with zipfile.ZipFile(wsa_zip_path) as zip:
|
|||
l.extract(g, xmldir)
|
||||
elif re.search(u'Images/.+\.png', g.filename):
|
||||
l.extract(g, archdir)
|
||||
with zipfile.ZipFile(zip_path) as zip:
|
||||
stat = Path(zip_path).stat()
|
||||
print(f"unzipping from {zip_path}", flush=True)
|
||||
zip.extractall(archdir)
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
#
|
||||
# This file is part of MagiskOnWSALocal.
|
||||
#
|
||||
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# MagiskOnWSALocal is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
#
|
||||
|
||||
from __future__ import annotations
|
||||
from io import TextIOWrapper
|
||||
from typing import OrderedDict
|
||||
from pathlib import Path
|
||||
import sys
|
||||
class Prop(OrderedDict):
|
||||
def __init__(self, file: TextIOWrapper) -> None:
|
||||
super().__init__()
|
||||
for i, line in enumerate(file.read().splitlines(False)):
|
||||
if '=' in line:
|
||||
k, v = line.split('=', 1)
|
||||
self[k] = v
|
||||
else:
|
||||
self[f".{i}"] = line
|
||||
|
||||
def __str__(self) -> str:
|
||||
return '\n'.join([v if k.startswith('.') else f"{k}={v}" for k, v in self.items()])
|
||||
|
||||
def __iadd__(self, other: str) -> Prop:
|
||||
self[f".{len(self)}"] = other
|
||||
return self
|
||||
|
||||
|
||||
new_props = {
|
||||
("product", "brand"): "google",
|
||||
("product", "manufacturer"): "Google",
|
||||
("build", "product"): "redfin",
|
||||
("product", "name"): "redfin",
|
||||
("product", "device"): "redfin",
|
||||
("product", "model"): "Pixel 5",
|
||||
("build", "flavor"): "redfin-user"
|
||||
}
|
||||
|
||||
|
||||
def description(sec: str, p: Prop) -> str:
|
||||
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']}"
|
||||
|
||||
|
||||
def fingerprint(sec: str, p: Prop) -> str:
|
||||
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"]}"""
|
||||
|
||||
|
||||
def fix_prop(sec, prop):
|
||||
if not Path(prop).is_file():
|
||||
return
|
||||
|
||||
print(f"fixing {prop}", flush=True)
|
||||
with open(prop, 'r') as f:
|
||||
p = Prop(f)
|
||||
|
||||
p += "# extra prop added by MagiskOnWSA"
|
||||
|
||||
for k, v in new_props.items():
|
||||
p[f"ro.{k[0]}.{k[1]}"] = v
|
||||
|
||||
if k[0] == "build":
|
||||
p[f"ro.{sec}.{k[0]}.{k[1]}"] = v
|
||||
elif k[0] == "product":
|
||||
p[f"ro.{k[0]}.{sec}.{k[1]}"] = v
|
||||
|
||||
p["ro.build.description"] = description(sec, p)
|
||||
p[f"ro.build.fingerprint"] = fingerprint(sec, p)
|
||||
p[f"ro.{sec}.build.description"] = description(sec, p)
|
||||
p[f"ro.{sec}.build.fingerprint"] = fingerprint(sec, p)
|
||||
p[f"ro.bootimage.build.fingerprint"] = fingerprint(sec, p)
|
||||
|
||||
with open(prop, 'w') as f:
|
||||
f.write(str(p))
|
||||
|
||||
|
||||
sys_path = sys.argv[1]
|
||||
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():
|
||||
fix_prop(sec, prop)
|
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
# Copyright (C) 2024 LSPosed Contributors
|
||||
#
|
||||
|
||||
from datetime import datetime
|
||||
|
@ -26,62 +26,54 @@ import json
|
|||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class BearerAuth(requests.auth.AuthBase):
|
||||
def __init__(self, token):
|
||||
self.token = token
|
||||
|
||||
def __call__(self, r):
|
||||
r.headers["authorization"] = "Bearer " + self.token
|
||||
return r
|
||||
|
||||
|
||||
github_auth = None
|
||||
if Path.cwd().joinpath('token').exists():
|
||||
with open(Path.cwd().joinpath('token'), 'r') as token_file:
|
||||
github_auth = BearerAuth(token_file.read())
|
||||
print("Using token file for authentication", flush=True)
|
||||
arch = sys.argv[1]
|
||||
brand = sys.argv[2]
|
||||
variant = sys.argv[3]
|
||||
arg4 = sys.argv[4]
|
||||
download_dir = Path.cwd().parent / "download" if arg4 == "" else Path(arg4)
|
||||
tempScript = sys.argv[5]
|
||||
android_api = sys.argv[6]
|
||||
file_name = sys.argv[7]
|
||||
print(f"Generating {brand} download link: arch={arch} variant={variant}", flush=True)
|
||||
arg2 = sys.argv[2]
|
||||
download_dir = Path.cwd().parent / "download" if arg2 == "" else Path(arg2)
|
||||
tempScript = sys.argv[3]
|
||||
android_api = sys.argv[4]
|
||||
file_name = sys.argv[5]
|
||||
print(f"Generating GApps download link: arch={arch}", flush=True)
|
||||
abi_map = {"x64": "x86_64", "arm64": "arm64"}
|
||||
android_api_map = {"30": "11.0", "32": "12.1", "33": "13.0"}
|
||||
release = android_api_map[android_api]
|
||||
if brand == "OpenGApps":
|
||||
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"]
|
||||
DATE = j["archs"][abi_map[arch]]["date"]
|
||||
print(f"DATE={DATE}", flush=True)
|
||||
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')
|
||||
elif brand == "MindTheGapps":
|
||||
res = requests.get(
|
||||
f'https://sourceforge.net/projects/wsa-mtg/rss?path=/{abi_map[arch]}&limit=100')
|
||||
matched = re.search(f'https://.*{release}.*{abi_map[arch]}.*\.zip/download', res.text)
|
||||
if matched:
|
||||
link = matched.group().replace(
|
||||
'.zip/download', '.zip').replace('sourceforge.net/projects/wsa-mtg/files', 'downloads.sourceforge.net/project/wsa-mtg')
|
||||
else:
|
||||
print(f"Failed to fetch from SourceForge RSS, fallbacking to Github API...", flush=True)
|
||||
res = requests.get(f"https://api.github.com/repos/MindTheGapps/{release}.0-{abi_map[arch]}/releases/latest")
|
||||
json_data = json.loads(res.content)
|
||||
headers = res.headers
|
||||
x_ratelimit_remaining = headers["x-ratelimit-remaining"]
|
||||
if res.status_code == 200:
|
||||
assets = json_data["assets"]
|
||||
for asset in assets:
|
||||
if re.match(f'.*{release}.*{abi_map[arch]}.*\.zip$', asset["name"]) and asset["content_type"] == "application/zip":
|
||||
link = asset["browser_download_url"]
|
||||
break
|
||||
elif res.status_code == 403 and x_ratelimit_remaining == '0':
|
||||
message = json_data["message"]
|
||||
print(f"Github API Error: {message}", flush=True)
|
||||
ratelimit_reset = headers["x-ratelimit-reset"]
|
||||
ratelimit_reset = datetime.fromtimestamp(int(ratelimit_reset))
|
||||
print(f"The current rate limit window resets in {ratelimit_reset}", flush=True)
|
||||
exit(1)
|
||||
|
||||
print(f"download link: {link}", flush=True)
|
||||
|
||||
with open(download_dir/tempScript, 'a') as f:
|
||||
f.writelines(f'{link}\n')
|
||||
f.writelines(f' dir={download_dir}\n')
|
||||
f.writelines(f' out={file_name}\n')
|
||||
res = requests.get(f"https://api.github.com/repos/LSPosed/WSA-Addon/releases/latest", auth=github_auth)
|
||||
json_data = json.loads(res.content)
|
||||
headers = res.headers
|
||||
x_ratelimit_remaining = headers["x-ratelimit-remaining"]
|
||||
if res.status_code == 200:
|
||||
download_files = {}
|
||||
assets = json_data["assets"]
|
||||
for asset in assets:
|
||||
if re.match(f'gapps.*{release}.*\.rc$', asset["name"]):
|
||||
download_files[asset["name"]] = asset["browser_download_url"]
|
||||
elif re.match(f'gapps.*{release}.*{abi_map[arch]}.*\.img$', asset["name"]):
|
||||
download_files[asset["name"]] = asset["browser_download_url"]
|
||||
with open(download_dir/tempScript, 'a') as f:
|
||||
for key, value in download_files.items():
|
||||
print(f"download link: {value}\npath: {download_dir / key}\n", flush=True)
|
||||
f.writelines(value + '\n')
|
||||
f.writelines(f' dir={download_dir}\n')
|
||||
f.writelines(f' out={key}\n')
|
||||
elif res.status_code == 403 and x_ratelimit_remaining == '0':
|
||||
message = json_data["message"]
|
||||
print(f"Github API Error: {message}", flush=True)
|
||||
ratelimit_reset = headers["x-ratelimit-reset"]
|
||||
ratelimit_reset = datetime.fromtimestamp(int(ratelimit_reset))
|
||||
print(
|
||||
f"The current rate limit window resets in {ratelimit_reset}", flush=True)
|
||||
exit(1)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
# Copyright (C) 2024 LSPosed Contributors
|
||||
#
|
||||
|
||||
from datetime import datetime
|
||||
|
@ -27,6 +27,7 @@ import requests
|
|||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from packaging import version
|
||||
|
||||
|
||||
class Prop(OrderedDict):
|
||||
|
@ -53,20 +54,34 @@ tempScript = sys.argv[3]
|
|||
kernelVersion = sys.argv[4]
|
||||
file_name = sys.argv[5]
|
||||
abi_map = {"x64": "x86_64", "arm64": "arm64"}
|
||||
print(f"Generating KernelSU download link: arch={abi_map[arch]}, kernel version={kernelVersion}", flush=True)
|
||||
res = requests.get(f"https://api.github.com/repos/tiann/KernelSU/releases/latest")
|
||||
print(
|
||||
f"Generating KernelSU download link: arch={abi_map[arch]}, kernel version={kernelVersion}", flush=True)
|
||||
res = requests.get(
|
||||
f"https://api.github.com/repos/tiann/KernelSU/releases/latest")
|
||||
json_data = json.loads(res.content)
|
||||
headers = res.headers
|
||||
x_ratelimit_remaining = headers["x-ratelimit-remaining"]
|
||||
kernel_ver = 0
|
||||
if res.status_code == 200:
|
||||
link = ""
|
||||
assets = json_data["assets"]
|
||||
for asset in assets:
|
||||
if re.match(f'kernel-WSA-{abi_map[arch]}-{kernelVersion}.*\.zip$', asset["name"]) and asset["content_type"] == "application/zip":
|
||||
asset_name = asset["name"]
|
||||
if re.match(f'kernel-WSA-{abi_map[arch]}-{kernelVersion}.*\.zip$', asset_name) and asset["content_type"] == "application/zip":
|
||||
tmp_kernel_ver = re.search(
|
||||
u'\d{1}.\d{1,}.\d{1,}.\d{1,}', asset_name.split("-")[3]).group()
|
||||
if (kernel_ver == 0):
|
||||
kernel_ver = tmp_kernel_ver
|
||||
elif version.parse(kernel_ver) < version.parse(tmp_kernel_ver):
|
||||
kernel_ver = tmp_kernel_ver
|
||||
print(f"Kernel version: {kernel_ver}", flush=True)
|
||||
for asset in assets:
|
||||
if re.match(f'kernel-WSA-{abi_map[arch]}-{kernel_ver}.*\.zip$', asset["name"]) and asset["content_type"] == "application/zip":
|
||||
link = asset["browser_download_url"]
|
||||
break
|
||||
if link == "":
|
||||
print(f"Error: No KernelSU release found for arch={abi_map[arch]}, kernel version={kernelVersion}", flush=True)
|
||||
print(
|
||||
f"Error: No KernelSU release found for arch={abi_map[arch]}, kernel version={kernelVersion}", flush=True)
|
||||
exit(1)
|
||||
release_name = json_data["name"]
|
||||
with open(os.environ['WSA_WORK_ENV'], 'r') as environ_file:
|
||||
|
@ -79,7 +94,8 @@ elif res.status_code == 403 and x_ratelimit_remaining == '0':
|
|||
print(f"Github API Error: {message}", flush=True)
|
||||
ratelimit_reset = headers["x-ratelimit-reset"]
|
||||
ratelimit_reset = datetime.fromtimestamp(int(ratelimit_reset))
|
||||
print(f"The current rate limit window resets in {ratelimit_reset}", flush=True)
|
||||
print(
|
||||
f"The current rate limit window resets in {ratelimit_reset}", flush=True)
|
||||
exit(1)
|
||||
|
||||
print(f"download link: {link}", flush=True)
|
||||
|
|
|
@ -18,29 +18,73 @@
|
|||
# Copyright (C) 2023 LSPosed Contributors
|
||||
#
|
||||
|
||||
from datetime import datetime
|
||||
import re
|
||||
import sys
|
||||
|
||||
import json
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class BearerAuth(requests.auth.AuthBase):
|
||||
def __init__(self, token):
|
||||
self.token = token
|
||||
|
||||
def __call__(self, r):
|
||||
r.headers["authorization"] = "Bearer " + self.token
|
||||
return r
|
||||
|
||||
|
||||
github_auth = None
|
||||
if Path.cwd().joinpath('token').exists():
|
||||
with open(Path.cwd().joinpath('token'), 'r') as token_file:
|
||||
github_auth = BearerAuth(token_file.read())
|
||||
print("Using token file for authentication", flush=True)
|
||||
|
||||
magisk_ver = sys.argv[1]
|
||||
download_dir = Path.cwd().parent / "download" if sys.argv[2] == "" else Path(sys.argv[2])
|
||||
download_dir = Path.cwd().parent / \
|
||||
"download" if sys.argv[2] == "" else Path(sys.argv[2])
|
||||
tempScript = sys.argv[3]
|
||||
print(f"Generating Magisk download link: release type={magisk_ver}", flush=True)
|
||||
download_files = {}
|
||||
print(
|
||||
f"Generating Magisk download link: release type={magisk_ver}", flush=True)
|
||||
if not magisk_ver:
|
||||
magisk_ver = "stable"
|
||||
if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug":
|
||||
try:
|
||||
magisk_link = json.loads(requests.get(
|
||||
f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_ver}.json").content)['magisk']['link']
|
||||
download_files[f"magisk-{magisk_ver}.zip"] = magisk_link
|
||||
except Exception:
|
||||
print("Failed to fetch from GitHub API, fallbacking to jsdelivr...")
|
||||
magisk_link = json.loads(requests.get(
|
||||
f"https://fastly.jsdelivr.net/gh/topjohnwu/magisk-files@master/{magisk_ver}.json").content)['magisk']['link']
|
||||
print(f"download link: {magisk_link}", flush=True)
|
||||
download_files[f"magisk-{magisk_ver}.zip"] = magisk_link
|
||||
res = requests.get(
|
||||
f"https://api.github.com/repos/LSPosed/WSA-Addon/releases/latest", auth=github_auth)
|
||||
json_data = json.loads(res.content)
|
||||
headers = res.headers
|
||||
x_ratelimit_remaining = headers["x-ratelimit-remaining"]
|
||||
if res.status_code == 200:
|
||||
assets = json_data["assets"]
|
||||
for asset in assets:
|
||||
if re.match(f'cust.img$', asset["name"]):
|
||||
download_files[asset["name"]] = asset["browser_download_url"]
|
||||
break
|
||||
|
||||
elif res.status_code == 403 and x_ratelimit_remaining == '0':
|
||||
message = json_data["message"]
|
||||
print(f"Github API Error: {message}", flush=True)
|
||||
ratelimit_reset = headers["x-ratelimit-reset"]
|
||||
ratelimit_reset = datetime.fromtimestamp(int(ratelimit_reset))
|
||||
print(
|
||||
f"The current rate limit window resets in {ratelimit_reset}", flush=True)
|
||||
exit(1)
|
||||
with open(download_dir/tempScript, 'a') as f:
|
||||
f.writelines(f'{magisk_link}\n')
|
||||
f.writelines(f' dir={download_dir}\n')
|
||||
f.writelines(f' out=magisk-{magisk_ver}.zip\n')
|
||||
for key, value in download_files.items():
|
||||
print(
|
||||
f"download link: {value}\npath: {download_dir / key}\n", flush=True)
|
||||
f.writelines(value + '\n')
|
||||
f.writelines(f' dir={download_dir}\n')
|
||||
f.writelines(f' out={key}\n')
|
||||
|
|
|
@ -15,12 +15,11 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
# Copyright (C) 2024 LSPosed Contributors
|
||||
#
|
||||
|
||||
import html
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
@ -61,7 +60,7 @@ download_dir = Path.cwd().parent / \
|
|||
"download" if sys.argv[3] == "" else Path(sys.argv[3])
|
||||
ms_account_conf = download_dir/".ms_account"
|
||||
tempScript = sys.argv[4]
|
||||
skip_wsa_download = sys.argv[5] == "no" if len(sys.argv) >= 6 else False
|
||||
skip_wsa_download = sys.argv[5] == "1" if len(sys.argv) >= 6 else False
|
||||
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
|
||||
user = ''
|
||||
session = Session()
|
||||
|
@ -70,7 +69,8 @@ if ms_account_conf.is_file():
|
|||
with open(ms_account_conf, "r") as f:
|
||||
conf = Prop(f.read())
|
||||
user = conf.get('user_code')
|
||||
print(f"Generating WSA download link: arch={arch} release_type={release_name}\n", flush=True)
|
||||
print(
|
||||
f"Generating WSA download link: arch={arch} release_type={release_name}\n", flush=True)
|
||||
with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f:
|
||||
cookie_content = f.read().format(user)
|
||||
|
||||
|
@ -146,8 +146,9 @@ threads = []
|
|||
wsa_build_ver = 0
|
||||
for filename, values in identities.items():
|
||||
if re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", filename):
|
||||
tmp_wsa_build_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group()
|
||||
if(wsa_build_ver == 0):
|
||||
tmp_wsa_build_ver = re.search(
|
||||
u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group()
|
||||
if (wsa_build_ver == 0):
|
||||
wsa_build_ver = tmp_wsa_build_ver
|
||||
elif version.parse(wsa_build_ver) < version.parse(tmp_wsa_build_ver):
|
||||
wsa_build_ver = tmp_wsa_build_ver
|
||||
|
@ -162,25 +163,21 @@ for filename, values in identities.items():
|
|||
out_file_name = f"{values[1]}_{arch}.appx"
|
||||
out_file = download_dir / out_file_name
|
||||
elif not skip_wsa_download and re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", filename):
|
||||
tmp_wsa_build_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group()
|
||||
if(wsa_build_ver != tmp_wsa_build_ver):
|
||||
tmp_wsa_build_ver = re.search(
|
||||
u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group()
|
||||
if (wsa_build_ver != tmp_wsa_build_ver):
|
||||
continue
|
||||
version_splitted = wsa_build_ver.split(".")
|
||||
major_ver = version_splitted[0]
|
||||
minor_ver = version_splitted[1]
|
||||
build_ver = version_splitted[2]
|
||||
revision_ver = version_splitted[3]
|
||||
with open(os.environ['WSA_WORK_ENV'], 'r') as environ_file:
|
||||
env = Prop(environ_file.read())
|
||||
env.WSA_VER = wsa_build_ver
|
||||
env.WSA_MAJOR_VER = major_ver
|
||||
with open(os.environ['WSA_WORK_ENV'], 'w') as environ_file:
|
||||
environ_file.write(str(env))
|
||||
out_file_name = f"wsa-{release_type}.zip"
|
||||
out_file = download_dir / out_file_name
|
||||
else:
|
||||
continue
|
||||
th = Thread(target=send_req, args=(values[0][0], values[0][1], out_file_name))
|
||||
th = Thread(target=send_req, args=(
|
||||
values[0][0], values[0][1], out_file_name))
|
||||
threads.append(th)
|
||||
th.daemon = True
|
||||
th.start()
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
#
|
||||
# This file is part of MagiskOnWSALocal.
|
||||
#
|
||||
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# MagiskOnWSALocal is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright (C) 2023 LSPosed Contributors
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
arch = sys.argv[1]
|
||||
|
||||
zip_name = ""
|
||||
wsa_zip_path= Path(sys.argv[2])
|
||||
|
||||
with zipfile.ZipFile(wsa_zip_path) as zip:
|
||||
for f in zip.filelist:
|
||||
if arch in f.filename.lower():
|
||||
zip_name = f.filename
|
||||
break
|
||||
ver_no = zip_name.split("_")
|
||||
long_ver = ver_no[1]
|
||||
ver = long_ver.split(".")
|
||||
major_ver = ver[0]
|
||||
print(major_ver)
|
2
scripts/init.lsp.magisk.rc
Normal file
2
scripts/init.lsp.magisk.rc
Normal file
|
@ -0,0 +1,2 @@
|
|||
on post-fs-data
|
||||
exec u:r:magisk:s0 0 0 -- /system/bin/sh ${MAGISKTMP}/post-fs-data.sh
|
44
scripts/post-fs-data.sh
Normal file
44
scripts/post-fs-data.sh
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
MAGISKTMP=/sbin
|
||||
[ -d /sbin ] || MAGISKTMP=/debug_ramdisk
|
||||
MAGISKBIN=/data/adb/magisk
|
||||
if [ ! -d /data/adb ]; then
|
||||
mkdir -m 700 /data/adb
|
||||
chcon u:object_r:adb_data_file:s0 /data/adb
|
||||
fi
|
||||
if [ ! -d $MAGISKBIN ]; then
|
||||
# shellcheck disable=SC2174
|
||||
mkdir -p -m 755 $MAGISKBIN
|
||||
chcon u:object_r:system_file:s0 $MAGISKBIN
|
||||
fi
|
||||
ABI=$(getprop ro.product.cpu.abi)
|
||||
for file in busybox magiskpolicy magiskboot magiskinit; do
|
||||
[ -x "$MAGISKBIN/$file" ] || {
|
||||
unzip -d $MAGISKBIN -oj $MAGISKTMP/stub.apk "lib/$ABI/lib$file.so"
|
||||
mv $MAGISKBIN/lib$file.so $MAGISKBIN/$file
|
||||
chmod 755 "$MAGISKBIN/$file"
|
||||
}
|
||||
done
|
||||
for file in util_functions.sh boot_patch.sh; do
|
||||
[ -x "$MAGISKBIN/$file" ] || {
|
||||
unzip -d $MAGISKBIN -oj $MAGISKTMP/stub.apk "assets/$file"
|
||||
chmod 755 "$MAGISKBIN/$file"
|
||||
}
|
||||
done
|
||||
for file in "$MAGISKTMP"/*; do
|
||||
if echo "$file" | grep -Eq "lsp_.+\.img"; then
|
||||
foldername=$(basename "$file" .img)
|
||||
mkdir -p "$MAGISKTMP/$foldername"
|
||||
mount -t auto -o ro,loop "$file" "$MAGISKTMP/$foldername"
|
||||
"$MAGISKTMP/$foldername/post-fs-data.sh" &
|
||||
fi
|
||||
done
|
||||
wait
|
||||
for file in "$MAGISKTMP"/*; do
|
||||
if echo "$file" | grep -Eq "lsp_.+\.img"; then
|
||||
foldername=$(basename "$file" .img)
|
||||
umount "$MAGISKTMP/$foldername"
|
||||
rm -rf "${MAGISKTMP:?}/${foldername:?}"
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
5
scripts/sepolicy.rule
Normal file
5
scripts/sepolicy.rule
Normal file
|
@ -0,0 +1,5 @@
|
|||
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 media_rw_data_file } filesystem getattr
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This file is part of MagiskOnWSALocal.
|
||||
|
||||
MagiskOnWSALocal is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
MagiskOnWSALocal is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright (C) 2023 LSPosed Contributors
|
||||
-->
|
||||
<config>
|
||||
<component-override package="com.android.vending">
|
||||
<!-- Conflicts with WSA's built-in package verifier, disable to prevent boot loops. -->
|
||||
<component class="com.google.android.finsky.verifier.impl.PackageVerificationReceiver" enabled="false" />
|
||||
<!-- Disable stock OTA components if installed -->
|
||||
<component class="com.google.android.finsky.systemupdate.SystemUpdateSettingsContentProvider" enabled="false" />
|
||||
<component class="com.google.android.finsky.systemupdateactivity.SettingsSecurityEntryPoint" enabled="false" />
|
||||
<component class="com.google.android.finsky.systemupdateactivity.SystemUpdateActivity" enabled="false" />
|
||||
</component-override>
|
||||
<component-override package="com.google.android.gms">
|
||||
<component class="com.google.android.gms.update.phone.PopupDialog" enabled="false" />
|
||||
<component class="com.google.android.gms.update.OtaSuggestionSummaryProvider" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateActivity" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateGcmTaskService" enabled="false" />
|
||||
<component class="com.google.android.gms.update.SystemUpdateService" enabled="false" />
|
||||
</component-override>
|
||||
</config>
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue