mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-07 19:53:50 +05:00
feat: add separate util commands for patching and signing of apk
This commit is contained in:
parent
df74e0cac2
commit
33df23c86a
2 changed files with 42 additions and 18 deletions
54
main.py
54
main.py
|
@ -12,26 +12,11 @@ parser = argparse.ArgumentParser(prog='anixart patcher')
|
||||||
parser.add_argument("--no-decompile", action='store_true')
|
parser.add_argument("--no-decompile", action='store_true')
|
||||||
parser.add_argument("--no-compile", action='store_true')
|
parser.add_argument("--no-compile", action='store_true')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
parser.add_argument("--patch", action='store_true')
|
||||||
args = parser.parse_args()
|
parser.add_argument("--sign", action='store_true')
|
||||||
|
|
||||||
check_and_download_all_tools()
|
|
||||||
check_java_version()
|
|
||||||
|
|
||||||
apks = get_apks()
|
|
||||||
if not apks:
|
|
||||||
log.fatal(f"apks folder is empty")
|
|
||||||
exit(1)
|
|
||||||
apk = select_apk(apks)
|
|
||||||
if not apk:
|
|
||||||
log.info('cancelled')
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
start_time = time()
|
|
||||||
|
|
||||||
if not args.no_decompile:
|
|
||||||
decompile_apk(apk)
|
|
||||||
|
|
||||||
|
def patch():
|
||||||
patches = get_patches()
|
patches = get_patches()
|
||||||
patches = select_patches(patches)
|
patches = select_patches(patches)
|
||||||
statuses = apply_patches(patches)
|
statuses = apply_patches(patches)
|
||||||
|
@ -45,6 +30,39 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
console.print(f"{status['name']}: ✘", style="bold red")
|
console.print(f"{status['name']}: ✘", style="bold red")
|
||||||
statuses_err.append(status["name"])
|
statuses_err.append(status["name"])
|
||||||
|
|
||||||
|
return patches, statuses_ok, statuses_err
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
check_and_download_all_tools()
|
||||||
|
check_java_version()
|
||||||
|
|
||||||
|
if not args.patch:
|
||||||
|
apks = get_apks()
|
||||||
|
if not apks:
|
||||||
|
log.fatal(f"apks folder is empty")
|
||||||
|
exit(1)
|
||||||
|
apk = select_apk(apks)
|
||||||
|
if not apk:
|
||||||
|
log.info('cancelled')
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
patch()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if args.sign:
|
||||||
|
sign_apk(f"{apk.removesuffix('.apk')}-patched.apk")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
start_time = time()
|
||||||
|
|
||||||
|
if not args.no_decompile:
|
||||||
|
decompile_apk(apk)
|
||||||
|
|
||||||
|
patches, statuses_ok, statuses_err = patch()
|
||||||
|
|
||||||
if not args.no_compile:
|
if not args.no_compile:
|
||||||
compile_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
compile_apk(f"{apk.removesuffix(".apk")}-patched.apk")
|
||||||
|
|
|
@ -79,6 +79,12 @@ def compile_apk(apk: str):
|
||||||
|
|
||||||
def sign_apk(apk: str):
|
def sign_apk(apk: str):
|
||||||
log.info(f"sign and align apk: `{apk}`")
|
log.info(f"sign and align apk: `{apk}`")
|
||||||
|
|
||||||
|
if os.path.exists(f"{config['folders']['dist']}/{apk.removesuffix('.apk')}-aligned.apk"):
|
||||||
|
os.remove(f"{config['folders']['dist']}/{apk.removesuffix('.apk')}-aligned.apk")
|
||||||
|
if os.path.exists(f"{config['folders']['dist']}/{apk.removesuffix('.apk')}-aligned-signed.apk"):
|
||||||
|
os.remove(f"{config['folders']['dist']}/{apk.removesuffix('.apk')}-aligned-signed.apk")
|
||||||
|
|
||||||
command = ""
|
command = ""
|
||||||
try:
|
try:
|
||||||
command = (
|
command = (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue